From a8544b65b293ea9e46a223fd036873e5d87e745d Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 6 May 2014 13:20:00 -0500 Subject: [PATCH 001/240] log addition of relationships to debug only --- .../maven/atlas/graph/spi/neo4j/AbstractNeo4JEGraphDriver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/AbstractNeo4JEGraphDriver.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/AbstractNeo4JEGraphDriver.java index 01efb76a..08176855 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/AbstractNeo4JEGraphDriver.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/AbstractNeo4JEGraphDriver.java @@ -636,7 +636,7 @@ private Map> addRelationshipsInternal( final Projec .getArtifactId() ) ); } - logger.info( "+= {} ({})", relationship, rel ); + logger.debug( "+= {} ({})", relationship, rel ); } else { From c57ccb9ab80f865d1d13ebea8596f916a58c4e90 Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 19 May 2014 17:48:07 -0500 Subject: [PATCH 002/240] add toString() for BomRelationship --- .../commonjava/maven/atlas/graph/rel/BomRelationship.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java index 62a21cfc..05e2c78d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java @@ -94,4 +94,10 @@ public ProjectRelationship selectTarget( final ProjectVersion return new BomRelationship( getSources(), d, ref, getIndex() ); } + + @Override + public String toString() + { + return String.format( "BomRelationship [%s => %s]", getDeclaring(), getTarget() ); + } } From 9a2a7af990aab6949575b7d5cc0c6a445aa94370 Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 21 May 2014 09:51:18 -0500 Subject: [PATCH 003/240] make sure that graph paths terminating at the root node have that in the start node, at least...even if they don't have any relationships, which will still allow them to give useful information about the target of the path. --- .../spi/neo4j/AbstractNeo4JEGraphDriver.java | 187 ++++++++++++------ .../graph/spi/neo4j/model/CyclePath.java | 55 ++++-- .../graph/spi/neo4j/model/Neo4jGraphPath.java | 107 ++++++++-- .../spi/neo4j/traverse/AtlasCollector.java | 36 ++-- .../traverse/SubPathsCollectingVisitor.java | 15 +- .../maven/atlas/ident/ref/ArtifactRef.java | 11 ++ .../atlas/ident/ref/InvalidRefException.java | 6 + .../maven/atlas/ident/ref/ProjectRef.java | 5 + .../atlas/ident/ref/ProjectVersionRef.java | 8 + .../maven/atlas/graph/EGraphManager.java | 105 ++++++---- .../graph/traverse/AncestryTraversalTCK.java | 9 +- 11 files changed, 379 insertions(+), 165 deletions(-) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/AbstractNeo4JEGraphDriver.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/AbstractNeo4JEGraphDriver.java index 08176855..56e3b46f 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/AbstractNeo4JEGraphDriver.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/AbstractNeo4JEGraphDriver.java @@ -121,6 +121,8 @@ public abstract class AbstractNeo4JEGraphDriver private static final String BASE_CONFIG_NODE = "_base"; + private static final String MKEY_FORMAT = "%d/%s/%s:%s"; + private final GraphView globalView; // private static final String GRAPH_ATLAS_TYPES_CLAUSE = join( GraphRelType.atlasRelationshipTypes(), "|" ); @@ -161,7 +163,8 @@ public abstract class AbstractNeo4JEGraphDriver private final GraphAdminImpl adminAccess; - protected AbstractNeo4JEGraphDriver( GraphWorkspaceConfiguration config, final GraphDatabaseService graph, final boolean useShutdownHook ) + protected AbstractNeo4JEGraphDriver( GraphWorkspaceConfiguration config, final GraphDatabaseService graph, + final boolean useShutdownHook ) { this.adminAccess = new GraphAdminImpl( this ); @@ -253,7 +256,8 @@ public void printStats() } @Override - public Collection> getRelationshipsDeclaredBy( final GraphView view, final ProjectVersionRef ref ) + public Collection> getRelationshipsDeclaredBy( final GraphView view, + final ProjectVersionRef ref ) { checkClosed(); @@ -286,7 +290,8 @@ private void checkClosed() } @Override - public Collection> getRelationshipsTargeting( final GraphView view, final ProjectVersionRef ref ) + public Collection> getRelationshipsTargeting( final GraphView view, + final ProjectVersionRef ref ) { checkClosed(); @@ -365,11 +370,6 @@ public Set getAllProjects( final GraphView view ) .query( GAV, "*" ), cache ) ); } - private void updateView( final GraphView view ) - { - updateView( view, new ConversionCache() ); - } - private void updateView( final GraphView view, final ConversionCache cache ) { if ( view.getRoots() == null || view.getRoots() @@ -437,7 +437,8 @@ public Map, GraphPathInfo> getPathMapTargeting( final GraphView vie checkClosed(); if ( !registerView( view ) ) { - throw new IllegalArgumentException( "You must specify at least one root GAV in order to retrieve path-related info." ); + throw new IllegalArgumentException( + "You must specify at least one root GAV in order to retrieve path-related info." ); } final Set endNodes = getNodes( refs ); @@ -472,11 +473,17 @@ public ProjectVersionRef getPathTargetRef( final GraphPath path ) if ( !( path instanceof Neo4jGraphPath ) ) { - throw new IllegalArgumentException( "GraphPath instances must be of type Neo4jGraphPath. Was: " + path.getClass() - .getName() ); + throw new IllegalArgumentException( "GraphPath instances must be of type Neo4jGraphPath. Was: " + + path.getClass() + .getName() ); } final long rid = ( (Neo4jGraphPath) path ).getLastRelationshipId(); + if ( rid < 0 ) + { + return null; + } + final Relationship rel = graph.getRelationshipById( rid ); final Node target = rel.getEndNode(); @@ -489,7 +496,8 @@ public Set>> getAllPathsTo( final GraphView view, fi checkClosed(); if ( !registerView( view ) ) { - throw new IllegalArgumentException( "You must specify at least one root GAV in order to retrieve path-related info." ); + throw new IllegalArgumentException( + "You must specify at least one root GAV in order to retrieve path-related info." ); } final Set endNodes = getNodes( refs ); @@ -569,7 +577,8 @@ private Map> addRelationshipsInternal( final Projec { // FIXME: This means we're discarding a rejected relationship without passing it back...NOT GOOD // However, some code assumes rejects are cycles...also not good. - logger.error( String.format( "Failed to create node for project ref: %s. Reason: %s", ref, e.getMessage() ), e ); + logger.error( String.format( "Failed to create node for project ref: %s. Reason: %s", ref, + e.getMessage() ), e ); continue nextRel; } } @@ -605,7 +614,8 @@ private Map> addRelationshipsInternal( final Projec { final Node to = nodes[1]; - logger.debug( "Creating graph relationship for: {} between node: {} and node: {}", rel, from, to ); + logger.debug( "Creating graph relationship for: {} between node: {} and node: {}", rel, from, + to ); final GraphRelType grt = GraphRelType.map( rel.getType(), rel.isManaged() ); @@ -628,12 +638,14 @@ private Map> addRelationshipsInternal( final Projec { graph.index() .forRelationships( MANAGED_GA ) - .add( relationship, MANAGED_KEY, - String.format( "%d/%s/%s:%s", relationship.getStartNode() - .getId(), rel.getType() - .name(), rel.getTarget() - .getGroupId(), rel.getTarget() - .getArtifactId() ) ); + .add( relationship, + MANAGED_KEY, + String.format( MKEY_FORMAT, relationship.getStartNode() + .getId(), rel.getType() + .name(), rel.getTarget() + .getGroupId(), + rel.getTarget() + .getArtifactId() ) ); } logger.debug( "+= {} ({})", relationship, rel ); @@ -701,7 +713,8 @@ public boolean introducesCycle( final GraphView view, final ProjectRelationship< logger.debug( "Checking for existence of path from: {} to: {} in global database", fromNode, toNode ); final PathExistenceVisitor collector = new PathExistenceVisitor( toNode ); - collectAtlasRelationships( view, collector, Collections.singleton( fromNode ), false, Uniqueness.RELATIONSHIP_GLOBAL ); + collectAtlasRelationships( view, collector, Collections.singleton( fromNode ), false, + Uniqueness.RELATIONSHIP_GLOBAL ); return collector.isFound(); } @@ -740,8 +753,8 @@ private Node newProjectNode( final ProjectVersionRef ref ) return node; } - private Relationship select( final Relationship old, final GraphView view, final Node viewNode, final GraphPathInfo pathInfo, - final Neo4jGraphPath path ) + private Relationship select( final Relationship old, final GraphView view, final Node viewNode, + final GraphPathInfo pathInfo, final Neo4jGraphPath path ) { final ViewIndexes indexes = new ViewIndexes( graph.index(), view ); @@ -838,7 +851,8 @@ private Relationship select( final Relationship old, final GraphView view, final // } @Override - public void traverse( final GraphView view, final ProjectNetTraversal traversal, final EProjectNet net, final ProjectVersionRef root ) + public void traverse( final GraphView view, final ProjectNetTraversal traversal, final EProjectNet net, + final ProjectVersionRef root ) throws GraphDriverException { final Node rootNode = getNode( root ); @@ -881,8 +895,8 @@ public void traverse( final GraphView view, final ProjectNetTraversal traversal, @SuppressWarnings( { "rawtypes", "unchecked" } ) final MembershipWrappedTraversalEvaluator checker = - new MembershipWrappedTraversalEvaluator( Collections.singleton( rootNode.getId() ), traversal, view, viewNode, adminAccess, i, - relTypes ); + new MembershipWrappedTraversalEvaluator( Collections.singleton( rootNode.getId() ), traversal, view, + viewNode, adminAccess, i, relTypes ); checker.setConversionCache( cache ); @@ -1215,12 +1229,13 @@ private Set getRoots( final GraphView view, final boolean defaultToAll ) return nodes; } - private void collectAtlasRelationships( final GraphView view, final TraverseVisitor visitor, final Set start, final boolean sorted, - final Uniqueness uniqueness ) + private void collectAtlasRelationships( final GraphView view, final TraverseVisitor visitor, final Set start, + final boolean sorted, final Uniqueness uniqueness ) { if ( start == null || start.isEmpty() ) { - throw new UnsupportedOperationException( "Cannot collect atlas nodes/relationships via traversal without at least one 'from' node!" ); + throw new UnsupportedOperationException( + "Cannot collect atlas nodes/relationships via traversal without at least one 'from' node!" ); } // logger.info( "Traversing for aggregation using: {} from roots: {}", checker.getClass() @@ -1242,7 +1257,8 @@ private void collectAtlasRelationships( final GraphView view, final TraverseVisi final Node viewNode = getViewNode( view ); - final AtlasCollector checker = new AtlasCollector( visitor, start, view, viewNode, adminAccess, relTypes ); + final AtlasCollector checker = + new AtlasCollector( visitor, start, view, viewNode, adminAccess, relTypes ); description = description.expand( checker ) .evaluator( checker ); @@ -1488,12 +1504,15 @@ public ExecutionResult executeFrom( final String cypher, final ProjectVersionRef } @Override - public ExecutionResult executeFrom( final String cypher, final Map params, final ProjectVersionRef... roots ) + public ExecutionResult executeFrom( final String cypher, final Map params, + final ProjectVersionRef... roots ) throws GraphDriverException { if ( cypher.startsWith( "START" ) ) { - throw new GraphDriverException( "Leave off the START clause when supplying ProjectVersionRef instances as query roots:\n'{}'", cypher ); + throw new GraphDriverException( + "Leave off the START clause when supplying ProjectVersionRef instances as query roots:\n'{}'", + cypher ); } final StringBuilder sb = new StringBuilder(); @@ -1526,12 +1545,15 @@ public ExecutionResult executeFrom( final String cypher, final ProjectRelationsh } @Override - public ExecutionResult executeFrom( final String cypher, final Map params, final ProjectRelationship rootRel ) + public ExecutionResult executeFrom( final String cypher, final Map params, + final ProjectRelationship rootRel ) throws GraphDriverException { if ( cypher.startsWith( "START" ) ) { - throw new GraphDriverException( "Leave off the START clause when supplying ProjectRelationship instances as query roots:\n'{}'", cypher ); + throw new GraphDriverException( + "Leave off the START clause when supplying ProjectRelationship instances as query roots:\n'{}'", + cypher ); } String id = "*"; @@ -1562,7 +1584,8 @@ public ExecutionResult execute( final String cypher, final Map p final String query = cypher.replaceAll( "(\\s)\\s+", "$1" ); - final ExecutionResult result = params == null ? queryEngine.execute( query ) : queryEngine.execute( query, params ); + final ExecutionResult result = + params == null ? queryEngine.execute( query ) : queryEngine.execute( query, params ); // logger.info( "Execution plan:\n{}", result.executionPlanDescription() ); @@ -1675,14 +1698,16 @@ public void addDisconnectedProject( final ProjectVersionRef ref ) @Deprecated @Override public Set> getDirectRelationshipsFrom( final GraphView view, final ProjectVersionRef from, - final boolean includeManagedInfo, final RelationshipType... types ) + final boolean includeManagedInfo, + final RelationshipType... types ) { return getDirectRelationshipsFrom( view, from, includeManagedInfo, true, types ); } @Override public Set> getDirectRelationshipsFrom( final GraphView view, final ProjectVersionRef from, - final boolean includeManagedInfo, final boolean includeConcreteInfo, + final boolean includeManagedInfo, + final boolean includeConcreteInfo, final RelationshipType... types ) { final Node node = getNode( from ); @@ -1705,7 +1730,8 @@ public Set> getDirectRelationshipsFrom( final GraphView v } } - final Iterable relationships = node.getRelationships( Direction.OUTGOING, grts.toArray( new GraphRelType[grts.size()] ) ); + final Iterable relationships = + node.getRelationships( Direction.OUTGOING, grts.toArray( new GraphRelType[grts.size()] ) ); if ( relationships != null ) { @@ -1735,18 +1761,21 @@ public Set> getDirectRelationshipsFrom( final GraphView v */ @Deprecated @Override - public Set> getDirectRelationshipsTo( final GraphView view, final ProjectVersionRef to, final boolean includeManagedInfo, + public Set> getDirectRelationshipsTo( final GraphView view, final ProjectVersionRef to, + final boolean includeManagedInfo, final RelationshipType... types ) { return getDirectRelationshipsTo( view, to, includeManagedInfo, true, types ); } @Override - public Set> getDirectRelationshipsTo( final GraphView view, final ProjectVersionRef to, final boolean includeManagedInfo, - final boolean includeConcreteInfo, final RelationshipType... types ) + public Set> getDirectRelationshipsTo( final GraphView view, final ProjectVersionRef to, + final boolean includeManagedInfo, + final boolean includeConcreteInfo, + final RelationshipType... types ) { - logger.debug( "Finding relationships targeting: {} (filter: {}, managed: {}, types: {})", to, view.getFilter(), includeManagedInfo, - Arrays.asList( types ) ); + logger.debug( "Finding relationships targeting: {} (filter: {}, managed: {}, types: {})", to, view.getFilter(), + includeManagedInfo, Arrays.asList( types ) ); final Node node = getNode( to ); if ( node == null ) { @@ -1769,7 +1798,8 @@ public Set> getDirectRelationshipsTo( final GraphView vie logger.debug( "Using graph-relationship types: {}", grts ); - final Iterable relationships = node.getRelationships( Direction.INCOMING, grts.toArray( new GraphRelType[grts.size()] ) ); + final Iterable relationships = + node.getRelationships( Direction.INCOMING, grts.toArray( new GraphRelType[grts.size()] ) ); final ConversionCache cache = new ConversionCache(); if ( relationships != null ) @@ -1852,7 +1882,8 @@ public void deleteRelationshipsDeclaredBy( final ProjectVersionRef ref ) } @Override - public ProjectVersionRef getManagedTargetFor( final ProjectVersionRef target, final GraphPath path, final RelationshipType type ) + public ProjectVersionRef getManagedTargetFor( final ProjectVersionRef target, final GraphPath path, + final RelationshipType type ) { if ( path == null ) { @@ -1861,8 +1892,9 @@ public ProjectVersionRef getManagedTargetFor( final ProjectVersionRef target, fi if ( !( path instanceof Neo4jGraphPath ) ) { - throw new IllegalArgumentException( "GraphPath instances must be of type Neo4jGraphPath. Was: " + path.getClass() - .getName() ); + throw new IllegalArgumentException( "GraphPath instances must be of type Neo4jGraphPath. Was: " + + path.getClass() + .getName() ); } final RelationshipIndex idx = graph.index() @@ -1876,18 +1908,21 @@ public ProjectVersionRef getManagedTargetFor( final ProjectVersionRef target, fi { final Relationship r = graph.getRelationshipById( id ); - final String mkey = String.format( "%d/%s/%s:%s", r.getStartNode() - .getId(), type.name(), target.getGroupId(), target.getArtifactId() ); + final String mkey = + String.format( MKEY_FORMAT, r.getStartNode() + .getId(), type.name(), target.getGroupId(), target.getArtifactId() ); // logger.info( "Searching for m-key: {}", mkey ); final IndexHits hits = idx.get( MANAGED_KEY, mkey ); if ( hits != null && hits.hasNext() ) { - final ProjectVersionRef ref = toProjectVersionRef( hits.next() - .getEndNode(), cache ); + final Relationship hit = hits.next(); + final ProjectVersionRef ref = toProjectVersionRef( hit.getEndNode(), cache ); + + final ProjectRelationship rel = Conversions.toProjectRelationship( hit, cache ); + logger.info( "[MUTATION] {} => {} (via: {})", target, ref, rel ); - // logger.info( "Found it: {}", ref ); return ref; } @@ -1916,11 +1951,14 @@ public List getPathRefs( final GraphView view, final GraphPat { if ( path != null && !( path instanceof Neo4jGraphPath ) ) { - throw new IllegalArgumentException( "Cannot get refs for: " + path + ". This is not a Neo4jGraphPathKey instance!" ); + throw new IllegalArgumentException( "Cannot get refs for: " + path + + ". This is not a Neo4jGraphPathKey instance!" ); } + final ConversionCache cache = new ConversionCache(); + final Neo4jGraphPath gp = (Neo4jGraphPath) path; - final List> rels = convertToRelationships( gp, adminAccess, new ConversionCache() ); + final List> rels = convertToRelationships( gp, adminAccess, cache ); final List refs = new ArrayList( rels.size() + 2 ); for ( final ProjectRelationship rel : rels ) { @@ -1933,13 +1971,28 @@ public List getPathRefs( final GraphView view, final GraphPat .asProjectVersionRef() ); } + if ( refs.isEmpty() ) + { + final Node node = graph.getNodeById( gp.getStartNodeId() ); + final ProjectVersionRef ref = toProjectVersionRef( node, cache ); + if ( ref != null ) + { + refs.add( ref ); + } + } + return refs; } @Override public GraphPath createPath( final ProjectRelationship... rels ) { - final long[] relIds = new long[rels.length]; + if ( rels.length < 1 ) + { + return null; + } + + final Relationship[] rs = new Relationship[rels.length]; for ( int i = 0; i < rels.length; i++ ) { final Relationship r = getRelationship( rels[i] ); @@ -1948,10 +2001,10 @@ public GraphPath createPath( final ProjectRelationship... rels ) return null; } - relIds[i] = r.getId(); + rs[i] = r; } - return new Neo4jGraphPath( relIds ); + return new Neo4jGraphPath( rs ); } @Override @@ -1959,7 +2012,8 @@ public GraphPath createPath( final GraphPath parent, final ProjectRelation { if ( parent != null && !( parent instanceof Neo4jGraphPath ) ) { - throw new IllegalArgumentException( "Cannot get child path-key for: " + parent + ". This is not a Neo4jGraphPathKey instance!" ); + throw new IllegalArgumentException( "Cannot get child path-key for: " + parent + + ". This is not a Neo4jGraphPathKey instance!" ); } Relationship r = getRelationship( rel ); @@ -1993,7 +2047,7 @@ public GraphPath createPath( final GraphPath parent, final ProjectRelation } } - return new Neo4jGraphPath( (Neo4jGraphPath) parent, r.getId() ); + return new Neo4jGraphPath( (Neo4jGraphPath) parent, r ); } @Override @@ -2255,11 +2309,12 @@ public boolean registerView( final GraphView view ) if ( view.getRoots() == null || view.getRoots() .isEmpty() ) { - logger.info( "Cannot track membership in view! It has no root GAVs.\nView: {} (short id: {})", view.getLongId(), view.getShortId() ); + logger.info( "Cannot track membership in view! It has no root GAVs.\nView: {} (short id: {})", + view.getLongId(), view.getShortId() ); return false; } - updateView( view ); + updateView( view, new ConversionCache() ); return true; } @@ -2293,7 +2348,8 @@ private Node getViewNode( final GraphView view ) confIdx.add( viewNode, VIEW_ID, view.getShortId() ); - logger.debug( "Setting cycle-detection PENDING for new viewNode: {} of: {}", viewNode, view.getShortId() ); + logger.debug( "Setting cycle-detection PENDING for new viewNode: {} of: {}", viewNode, + view.getShortId() ); Conversions.setCycleDetectionPending( viewNode, true ); Conversions.setMembershipDetectionPending( viewNode, true ); @@ -2324,7 +2380,8 @@ private Node getViewNode( final GraphView view ) } @Override - public void registerViewSelection( final GraphView view, final ProjectRef ref, final ProjectVersionRef projectVersionRef ) + public void registerViewSelection( final GraphView view, final ProjectRef ref, + final ProjectVersionRef projectVersionRef ) { checkClosed(); if ( !registerView( view ) ) @@ -2518,8 +2575,8 @@ public Relationship getRelationship( final long rid ) } @Override - public Relationship select( final Relationship r, final GraphView view, final Node viewNode, final GraphPathInfo viewPathInfo, - final Neo4jGraphPath viewPath ) + public Relationship select( final Relationship r, final GraphView view, final Node viewNode, + final GraphPathInfo viewPathInfo, final Neo4jGraphPath viewPath ) { return driver.select( r, view, viewNode, viewPathInfo, viewPath ); } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/CyclePath.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/CyclePath.java index 642f1408..a270a0c9 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/CyclePath.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/CyclePath.java @@ -10,14 +10,16 @@ ******************************************************************************/ package org.commonjava.maven.atlas.graph.spi.neo4j.model; +import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import org.neo4j.graphdb.Path; +import org.neo4j.graphdb.Relationship; public class CyclePath - extends Neo4jGraphPath + implements Iterable { public static final class CycleIterator @@ -76,7 +78,8 @@ else if ( next == start ) throw new IndexOutOfBoundsException( next + " is the starting point for this iteration!" ); } - throw new IndexOutOfBoundsException( next + " is the next index, but the array has only " + ids.length + " items!" ); + throw new IndexOutOfBoundsException( next + " is the next index, but the array has only " + ids.length + + " items!" ); } @Override @@ -89,24 +92,39 @@ public void remove() private int entryPoint = 0; + private final long[] ids; + public CyclePath( final long[] ids ) { - super( ids ); + this.ids = ids; } public CyclePath( final List ids ) { - super( ids ); + this.ids = new long[ids.size()]; + for ( int i = 0; i < ids.size(); i++ ) + { + this.ids[i] = ids.get( i ); + } } public CyclePath( final Path path ) { - super( path ); + final List ids = new ArrayList(); + for ( final Relationship r : path.relationships() ) + { + ids.add( r.getId() ); + } + + this.ids = new long[ids.size()]; + for ( int i = 0; i < ids.size(); i++ ) + { + this.ids[i] = ids.get( i ); + } } public void setEntryPoint( final long entryPoint ) { - final long[] ids = super.getRelationshipIds(); for ( int i = 0; i < ids.length; i++ ) { if ( ids[i] == entryPoint ) @@ -125,26 +143,21 @@ public void clearEntryPoint() @Override public Iterator iterator() { - return new CycleIterator( super.getRelationshipIds(), entryPoint ); + return new CycleIterator( ids, entryPoint ); } - @Override public long getLastRelationshipId() { - final long[] ids = super.getRelationshipIds(); - final int last = entryPoint > 0 ? entryPoint - 1 : ids.length - 1; return ids[last]; } - @Override public long getFirstRelationshipId() { - return super.getRelationshipIds()[entryPoint]; + return ids[entryPoint]; } - @Override public long[] getRelationshipIds() { // if ( entryPoint == 0 ) @@ -152,7 +165,7 @@ public long[] getRelationshipIds() // return getRawRelationshipIds(); // } - final long[] ids = new long[getRawRelationshipIds().length]; + final long[] ids = new long[this.ids.length]; final Iterator iterator = iterator(); int i = 0; @@ -169,7 +182,6 @@ public int hashCode() { final int prime = 37; - final long[] ids = super.getRelationshipIds(); if ( ids.length == 0 ) { return prime; @@ -216,9 +228,7 @@ public boolean equals( final Object obj ) } final CyclePath other = (CyclePath) obj; - final long[] ids = getRawRelationshipIds(); - final long[] oids = other.getRawRelationshipIds(); - if ( ids.length != oids.length ) + if ( ids.length != other.ids.length ) { return false; } @@ -243,7 +253,6 @@ else if ( ids.length == 0 ) public CycleIterator identityIterator() { - final long[] ids = super.getRelationshipIds(); final long[] sorted = new long[ids.length]; System.arraycopy( ids, 0, sorted, 0, ids.length ); @@ -264,7 +273,7 @@ public CycleIterator identityIterator() private long[] getRawRelationshipIds() { - return super.getRelationshipIds(); + return ids; } public CyclePath reorientToEntryPoint() @@ -287,7 +296,6 @@ public CyclePath reorientToEntryPoint() return new CyclePath( reoriented ); } - @Override public String getKey() { final StringBuilder sb = new StringBuilder(); @@ -312,4 +320,9 @@ public String toString() return "CyclePath [" + getKey() + "]"; } + public int length() + { + return ids.length; + } + } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java index f1b7cb2d..a8b72ad6 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java @@ -17,6 +17,7 @@ import org.apache.commons.codec.digest.DigestUtils; import org.commonjava.maven.atlas.graph.model.GraphPath; +import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Path; import org.neo4j.graphdb.Relationship; @@ -26,27 +27,53 @@ public class Neo4jGraphPath private final long[] relationships; - public Neo4jGraphPath( final long... relationshipIds ) - { - this.relationships = relationshipIds; - } + private final long startNode; + + private final long endNode; - public Neo4jGraphPath( final Neo4jGraphPath parent, final long... relationshipIds ) + public Neo4jGraphPath( final Neo4jGraphPath parent, final Relationship... relationships ) { if ( parent == null ) { - relationships = relationshipIds; + throw new NullPointerException( "Parent path cannot be null" ); + } + + this.startNode = parent.startNode; + if ( relationships.length > 0 ) + { + this.endNode = relationships[relationships.length - 1].getEndNode() + .getId(); } else { - relationships = new long[parent.relationships.length + relationshipIds.length]; - System.arraycopy( parent.relationships, 0, relationships, 0, parent.relationships.length ); - System.arraycopy( relationshipIds, 0, relationships, parent.relationships.length, relationshipIds.length ); + this.endNode = parent.endNode; + } + + final int parentLen = parent.relationships.length; + + this.relationships = new long[parentLen + relationships.length]; + + if ( parentLen > 0 ) + { + System.arraycopy( parent.relationships, 0, this.relationships, 0, parent.relationships.length ); + } + + if ( this.relationships.length > 0 ) + { + for ( int i = parentLen; i < this.relationships.length; i++ ) + { + this.relationships[i] = relationships[i - parentLen].getId(); + } } } public Neo4jGraphPath( final Path path ) { + this.startNode = path.startNode() + .getId(); + this.endNode = path.endNode() + .getId(); + final List ids = new ArrayList(); for ( final Relationship r : path.relationships() ) { @@ -60,20 +87,57 @@ public Neo4jGraphPath( final Path path ) } } - public Neo4jGraphPath( final List ids ) + public Neo4jGraphPath( final Node start, final Node end, final long[] rids ) { - this.relationships = new long[ids.size()]; - for ( int i = 0; i < ids.size(); i++ ) + this.startNode = start.getId(); + this.endNode = end.getId(); + this.relationships = rids; + } + + public Neo4jGraphPath( final Relationship[] relationships ) + { + if ( relationships.length > 0 ) { - this.relationships[i] = ids.get( i ); + this.startNode = relationships[0].getStartNode() + .getId(); + + this.endNode = relationships[relationships.length - 1].getEndNode() + .getId(); + } + else + { + throw new IllegalArgumentException( + "Cannot initialize path with zero relationships and no explicit start node!" ); + } + + this.relationships = new long[relationships.length]; + + final int i = 0; + for ( final Relationship relationship : relationships ) + { + this.relationships[i] = relationship.getId(); } } + private Neo4jGraphPath( final Neo4jGraphPath parent, final long endNode, final long[] newRelationships ) + { + this.startNode = parent.startNode; + this.endNode = endNode; + + final int parentLen = parent.relationships.length; + + this.relationships = new long[parentLen + newRelationships.length]; + + System.arraycopy( parent.relationships, 0, this.relationships, 0, parentLen ); + System.arraycopy( newRelationships, 0, this.relationships, parentLen, newRelationships.length ); + } + public Neo4jGraphPath append( final Neo4jGraphPath childPath ) { if ( length() > 0 && getLastRelationshipId() != childPath.getFirstRelationshipId() ) { - throw new IllegalArgumentException( "Cannot splice " + childPath + " onto " + this + ". They don't overlap on last/first relationshipId!" ); + throw new IllegalArgumentException( "Cannot splice " + childPath + " onto " + this + + ". They don't overlap on last/first relationshipId!" ); } if ( childPath.length() < 2 ) @@ -84,7 +148,17 @@ public Neo4jGraphPath append( final Neo4jGraphPath childPath ) final long[] ids = new long[childPath.length() - 1]; System.arraycopy( childPath.getRelationshipIds(), 1, ids, 0, ids.length ); - return new Neo4jGraphPath( this, ids ); + return new Neo4jGraphPath( this, childPath.endNode, ids ); + } + + public long getStartNodeId() + { + return startNode; + } + + public long getEndNodeId() + { + return endNode; } @Override @@ -149,7 +223,8 @@ public void remove() @Override public String toString() { - return String.format( "%s [relationships=%s]", getClass().getSimpleName(), Arrays.toString( relationships ) ); + return String.format( "%s [relationships=%s, from=%s, to=%s]", getClass().getSimpleName(), + Arrays.toString( relationships ), startNode, endNode ); } @Override diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java index 61a729de..f33b27f0 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java @@ -64,15 +64,15 @@ public final class AtlasCollector private GraphRelType[] types; - public AtlasCollector( final TraverseVisitor visitor, final Node start, final GraphView view, final Node viewNode, final GraphAdmin admin, - final GraphRelType... types ) + public AtlasCollector( final TraverseVisitor visitor, final Node start, final GraphView view, final Node viewNode, + final GraphAdmin admin, final GraphRelType... types ) { this( visitor, Collections.singleton( start ), view, viewNode, admin ); this.types = types; } - public AtlasCollector( final TraverseVisitor visitor, final Set startNodes, final GraphView view, final Node viewNode, - final GraphAdmin admin, final GraphRelType... types ) + public AtlasCollector( final TraverseVisitor visitor, final Set startNodes, final GraphView view, + final Node viewNode, final GraphAdmin admin, final GraphRelType... types ) { this.visitor = visitor; this.viewNode = viewNode; @@ -85,8 +85,9 @@ public AtlasCollector( final TraverseVisitor visitor, final Set startNodes this.view = view; } - public AtlasCollector( final TraverseVisitor visitor, final Set startNodes, final GraphView view, final Node viewNode, - final GraphAdmin admin, final GraphRelType[] types, final Direction direction ) + public AtlasCollector( final TraverseVisitor visitor, final Set startNodes, final GraphView view, + final Node viewNode, final GraphAdmin admin, final GraphRelType[] types, + final Direction direction ) { this( visitor, startNodes, view, viewNode, admin, types ); this.direction = direction; @@ -138,7 +139,8 @@ public final Iterable expand( final Path path, final BranchState s if ( cyclePath != null ) { final Relationship injector = path.lastRelationship(); - logger.debug( "Detected cycle in progress for path: {} at relationship: {}\n Cycle path is: {}", path, injector, cyclePath ); + logger.debug( "Detected cycle in progress for path: {} at relationship: {}\n Cycle path is: {}", path, + injector, cyclePath ); visitor.cycleDetected( cyclePath, injector ); } @@ -175,8 +177,7 @@ public final Iterable expand( final Path path, final BranchState s logger.debug( "Getting relationships from node: {} ({}) with type in [{}] and direction: {} (path: {})", path.endNode(), path.endNode() - .getProperty( GAV ), new JoinString( ", ", childTypes ), direction, - path ); + .getProperty( GAV ), new JoinString( ", ", childTypes ), direction, path ); final Iterable relationships = path.endNode() .getRelationships( direction, childTypes ); @@ -196,20 +197,23 @@ public final Iterable expand( final Path path, final BranchState s final Relationship selected = admin.select( r, view, viewNode, pathInfo, graphPath ); if ( selected == null ) { - logger.debug( "selection failed for: {} at {}. Likely, this is filter rejection from: {}", r, graphPath, pathInfo ); + logger.debug( "selection failed for: {} at {}. Likely, this is filter rejection from: {}", r, + graphPath, pathInfo ); continue; } // if no selection happened and r is a selection-only relationship, skip it. if ( selected == r && admin.isSelection( r, viewNode ) ) { - logger.debug( "{} is NOT the result of selection, yet it is marked as a selection relationship. Path: {}", r, path ); + logger.debug( "{} is NOT the result of selection, yet it is marked as a selection relationship. Path: {}", + r, path ); continue; } if ( !accepted( selected, view, cache ) ) { - logger.debug( "{} NOT accepted, likely due to incompatible POM location or source URI. Path: {}", r, path ); + logger.debug( "{} NOT accepted, likely due to incompatible POM location or source URI. Path: {}", + r, path ); continue; } @@ -223,10 +227,11 @@ public final Iterable expand( final Path path, final BranchState s final ProjectRelationship rel = toProjectRelationship( r, cache ); - final Neo4jGraphPath nextPath = new Neo4jGraphPath( graphPath, r.getId() ); + final Neo4jGraphPath nextPath = new Neo4jGraphPath( graphPath, r ); final GraphPathInfo nextPathInfo = pathInfo.getChildPathInfo( rel ); - logger.debug( "Including child: {} with next-path: {} and childPathInfo: {} from parent path: {}", r, nextPath, nextPathInfo, path ); + logger.debug( "Including child: {} with next-path: {} and childPathInfo: {} from parent path: {}", r, + nextPath, nextPathInfo, path ); visitor.includingChild( r, nextPath, nextPathInfo, path ); logger.debug( "+= {}", wrap( r ) ); @@ -267,7 +272,8 @@ public final Evaluation evaluate( final Path path ) @Override public PathExpander reverse() { - final AtlasCollector collector = new AtlasCollector( visitor, startNodes, view, viewNode, admin, types, direction.reverse() ); + final AtlasCollector collector = + new AtlasCollector( visitor, startNodes, view, viewNode, admin, types, direction.reverse() ); collector.setConversionCache( cache ); collector.setUseSelections( useSelections ); diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/SubPathsCollectingVisitor.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/SubPathsCollectingVisitor.java index 8071e942..8289d934 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/SubPathsCollectingVisitor.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/SubPathsCollectingVisitor.java @@ -60,22 +60,25 @@ public boolean includeChildren( final Path path, final Neo4jGraphPath graphPath, final Neo4jGraphPath gp = new Neo4jGraphPath( path ); final long[] allRids = gp.getRelationshipIds(); int i = 0; + Relationship start = null; for ( ; i < allRids.length; i++ ) { - final Relationship r = admin.getRelationship( allRids[i] ); - if ( viaNodes.contains( r.getEndNode() - .getId() ) ) + start = admin.getRelationship( allRids[i] ); + if ( viaNodes.contains( start.getEndNode() + .getId() ) ) { - logger.debug( "found via-node ending: {}", r ); + logger.debug( "found via-node ending: {}", start ); break; } } - if ( i < allRids.length - 1 ) + if ( start != null && i < allRids.length - 1 ) { final long[] rids = new long[allRids.length - i]; System.arraycopy( allRids, i, rids, 0, rids.length ); - paths.add( new Neo4jGraphPath( rids ) ); + + final Relationship last = admin.getRelationship( allRids[allRids.length - 1] ); + paths.add( new Neo4jGraphPath( start.getStartNode(), last.getEndNode(), rids ) ); } } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java index b1771cff..41df7dc6 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java @@ -16,6 +16,17 @@ import org.commonjava.maven.atlas.ident.version.SingleVersion; import org.commonjava.maven.atlas.ident.version.VersionSpec; +/** + * Represents an artifact, in Maven parlance. A tangible result of a build, which is typically made available in a Maven repository for others + * to consume. NOTE: a POM file is both a piece of metadata AND an artifact in the Maven world! + * + * Artifacts are based on the GAV coordinate for the project release, but also contain a type and optionally, a classifier. Type defaults to 'jar'. + * + * @see {@link ProjectRef} + * @see {@link ProjectVersionRef} + * + * @author jdcasey + */ public class ArtifactRef extends ProjectVersionRef implements Serializable diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/InvalidRefException.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/InvalidRefException.java index 36d251e1..77f8818a 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/InvalidRefException.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/InvalidRefException.java @@ -12,6 +12,12 @@ import java.util.IllegalFormatException; +/** + * Thrown to signal an invalid reference to another project. This happens most commonly when a groupId, artifactId, or version string is left blank + * or null. + * + * @author jdcasey + */ public class InvalidRefException extends RuntimeException { diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java index 716382b7..aaeb1c40 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java @@ -14,6 +14,11 @@ import java.io.Serializable; +/** + * Reference to a whole project (or module, in terms of Maven builds). This reference is not specific to a release of the project (see {@link ProjectVersionRef}). + * + * @author jdcasey + */ public class ProjectRef implements Serializable, Comparable { diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java index 006aabb3..4032dcc5 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java @@ -19,6 +19,14 @@ import org.commonjava.maven.atlas.ident.version.VersionSpec; import org.commonjava.maven.atlas.ident.version.VersionUtils; +/** + * Reference to a particular release of a project (or module, in terms of Maven builds). A release may contain many artifacts (see {@link ArtifactRef}). + * + * @see {@link ProjectRef} + * @see {@link ArtifactRef} + * + * @author jdcasey + */ public class ProjectVersionRef extends ProjectRef implements VersionedRef, Serializable diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/EGraphManager.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/EGraphManager.java index 53cbf7fb..7304820f 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/EGraphManager.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/EGraphManager.java @@ -72,7 +72,8 @@ public EGraphManager( final GraphWorkspaceFactory workspaceFactory ) this.workspaceFactory = workspaceFactory; } - public Set> storeRelationships( final GraphWorkspace workspace, final ProjectRelationship... rels ) + public Set> storeRelationships( final GraphWorkspace workspace, + final ProjectRelationship... rels ) throws GraphDriverException { logger.debug( "Storing relationships for: {}\n\n {}", workspace.getId(), new JoinString( "\n ", rels ) ); @@ -80,7 +81,8 @@ public Set> storeRelationships( final GraphWorkspace work .addRelationships( rels ); } - public Set> storeRelationships( final GraphWorkspace workspace, final Collection> rels ) + public Set> storeRelationships( final GraphWorkspace workspace, + final Collection> rels ) throws GraphDriverException { logger.debug( "Storing relationships for: {}\n\n {}", workspace.getId(), new JoinString( "\n ", rels ) ); @@ -116,13 +118,14 @@ public EProjectGraph getGraph( final GraphWorkspace workspace, final ProjectVers return getGraph( workspace, null, null, project ); } - public EProjectGraph getGraph( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, final ProjectVersionRef project ) + public EProjectGraph getGraph( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, + final ProjectVersionRef project ) { return getGraph( workspace, filter, null, project ); } - public EProjectGraph getGraph( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, final GraphMutator mutator, - final ProjectVersionRef project ) + public EProjectGraph getGraph( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, + final GraphMutator mutator, final ProjectVersionRef project ) { return getGraph( new GraphView( workspace, filter, mutator, project ) ); } @@ -134,12 +137,15 @@ public EProjectGraph getGraph( final GraphView view ) public EProjectNet getWeb( final GraphWorkspace workspace, final Collection refs ) { - return getWeb( workspace, null, null, refs == null ? new ProjectVersionRef[0] : refs.toArray( new ProjectVersionRef[refs.size()] ) ); + return getWeb( workspace, null, null, + refs == null ? new ProjectVersionRef[0] : refs.toArray( new ProjectVersionRef[refs.size()] ) ); } - public EProjectNet getWeb( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, final Collection refs ) + public EProjectNet getWeb( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, + final Collection refs ) { - return getWeb( workspace, null, null, refs == null ? new ProjectVersionRef[0] : refs.toArray( new ProjectVersionRef[refs.size()] ) ); + return getWeb( workspace, null, null, + refs == null ? new ProjectVersionRef[0] : refs.toArray( new ProjectVersionRef[refs.size()] ) ); } public EProjectWeb getWeb( final GraphWorkspace workspace, final ProjectVersionRef... refs ) @@ -147,28 +153,29 @@ public EProjectWeb getWeb( final GraphWorkspace workspace, final ProjectVersionR return getWeb( workspace, null, null, refs ); } - public EProjectWeb getWeb( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, final ProjectVersionRef... refs ) + public EProjectWeb getWeb( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, + final ProjectVersionRef... refs ) { return getWeb( workspace, filter, null, refs ); } - public EProjectWeb getWeb( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, final GraphMutator mutator, - final ProjectVersionRef... refs ) + public EProjectWeb getWeb( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, + final GraphMutator mutator, final ProjectVersionRef... refs ) { return getWeb( new GraphView( workspace, filter, mutator, refs ) ); } public EProjectWeb getWeb( final GraphView view ) { - final GraphDatabaseDriver dbDriver = view.getWorkspace() - .getDatabase(); - for ( final ProjectVersionRef ref : view.getRoots() ) - { - if ( !dbDriver.containsProject( view, ref ) || dbDriver.isMissing( view, ref ) ) - { - return null; - } - } + // final GraphDatabaseDriver dbDriver = view.getWorkspace() + // .getDatabase(); + // for ( final ProjectVersionRef ref : view.getRoots() ) + // { + // if ( !dbDriver.containsProject( view, ref ) || dbDriver.isMissing( view, ref ) ) + // { + // return null; + // } + // } return new EProjectWeb( view ); } @@ -260,39 +267,46 @@ public boolean containsGraph( final GraphWorkspace workspace, final ProjectVersi .containsProject( null, ref ); } - public boolean containsGraph( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, final ProjectVersionRef ref ) + public boolean containsGraph( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, + final ProjectVersionRef ref ) { return containsGraph( workspace, filter, null, ref ); } - public boolean containsGraph( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, final GraphMutator mutator, - final ProjectVersionRef ref ) + public boolean containsGraph( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, + final GraphMutator mutator, final ProjectVersionRef ref ) { return containsGraph( new GraphView( workspace, filter, mutator, ref ), ref ); } public Set> findDirectRelationshipsFrom( final GraphView view, final ProjectVersionRef from, - final boolean includeManagedInfo, final RelationshipType... types ) + final boolean includeManagedInfo, + final RelationshipType... types ) { return view.getDatabase() .getDirectRelationshipsFrom( view, from, includeManagedInfo, true, types ); } - public Set> findDirectRelationshipsTo( final GraphView view, final ProjectVersionRef to, final boolean includeManagedInfo, + public Set> findDirectRelationshipsTo( final GraphView view, final ProjectVersionRef to, + final boolean includeManagedInfo, final RelationshipType... types ) { return view.getDatabase() .getDirectRelationshipsTo( view, to, includeManagedInfo, true, types ); } - public Set> findDirectRelationshipsFrom( final GraphWorkspace workspace, final ProjectVersionRef from, - final boolean includeManagedInfo, final RelationshipType... types ) + public Set> findDirectRelationshipsFrom( final GraphWorkspace workspace, + final ProjectVersionRef from, + final boolean includeManagedInfo, + final RelationshipType... types ) { return findDirectRelationshipsFrom( new GraphView( workspace ), from, includeManagedInfo, types ); } - public Set> findDirectRelationshipsTo( final GraphWorkspace workspace, final ProjectVersionRef to, - final boolean includeManagedInfo, final RelationshipType... types ) + public Set> findDirectRelationshipsTo( final GraphWorkspace workspace, + final ProjectVersionRef to, + final boolean includeManagedInfo, + final RelationshipType... types ) { return findDirectRelationshipsTo( new GraphView( workspace ), to, includeManagedInfo, types ); } @@ -347,7 +361,8 @@ public Map getMetadata( final GraphWorkspace workspace, final Pr return result; } - public Map getMetadata( final GraphWorkspace workspace, final ProjectVersionRef ref, final Set keys ) + public Map getMetadata( final GraphWorkspace workspace, final ProjectVersionRef ref, + final Set keys ) { final Map result = new HashMap(); final Map metadata = workspace.getDatabase() @@ -375,10 +390,12 @@ public Map getMetadata( final GraphWorkspace workspace, final Pr return result; } - public Map, Set> collateByMetadata( final GraphWorkspace workspace, final Set refs, + public Map, Set> collateByMetadata( final GraphWorkspace workspace, + final Set refs, final Set keys ) { - final Map, Set> result = new HashMap, Set>(); + final Map, Set> result = + new HashMap, Set>(); for ( final ProjectVersionRef ref : refs ) { final Map metadata = getMetadata( workspace, ref, keys ); @@ -395,7 +412,8 @@ public Map, Set> collateByMetadata( final return result; } - public void addMetadata( final GraphWorkspace workspace, final EProjectKey key, final String name, final String value ) + public void addMetadata( final GraphWorkspace workspace, final EProjectKey key, final String name, + final String value ) throws GraphDriverException { workspace.getDatabase() @@ -409,14 +427,16 @@ public void setMetadata( final GraphWorkspace workspace, final EProjectKey key, .setMetadata( key.getProject(), metadata ); } - public void addMetadata( final GraphWorkspace workspace, final ProjectVersionRef project, final String name, final String value ) + public void addMetadata( final GraphWorkspace workspace, final ProjectVersionRef project, final String name, + final String value ) throws GraphDriverException { workspace.getDatabase() .addMetadata( project, name, value ); } - public void setMetadata( final GraphWorkspace workspace, final ProjectVersionRef project, final Map metadata ) + public void setMetadata( final GraphWorkspace workspace, final ProjectVersionRef project, + final Map metadata ) throws GraphDriverException { workspace.getDatabase() @@ -484,7 +504,8 @@ public synchronized void close() } catch ( final IOException e ) { - new GraphDriverException( "Failed to close workspace: {}.", e, wsid ).printStackTrace( new PrintWriter( sw ) ); + new GraphDriverException( "Failed to close workspace: {}.", e, wsid ).printStackTrace( new PrintWriter( + sw ) ); if ( sb.length() > 0 ) { sb.append( "\n\n" ); @@ -511,7 +532,8 @@ public void detached( final GraphWorkspace ws ) } catch ( final GraphDriverException e ) { - logger.error( String.format( "Failed to store workspace %s on detach. Reason: %s", ws.getId(), e.getMessage() ), e ); + logger.error( String.format( "Failed to store workspace %s on detach. Reason: %s", ws.getId(), + e.getMessage() ), e ); } } } @@ -529,7 +551,8 @@ public void closed( final GraphWorkspace workspace ) } catch ( final IOException e ) { - logger.error( String.format( "Failed to delete temporary workspace: %s. Reason: %s", workspace.getId(), e.getMessage() ), e ); + logger.error( String.format( "Failed to delete temporary workspace: %s. Reason: %s", workspace.getId(), + e.getMessage() ), e ); } } else @@ -540,7 +563,8 @@ public void closed( final GraphWorkspace workspace ) } catch ( final GraphDriverException e ) { - logger.error( String.format( "Failed to store updates for workspace: %s. Reason: %s", workspace, e.getMessage() ), e ); + logger.error( String.format( "Failed to store updates for workspace: %s. Reason: %s", workspace, + e.getMessage() ), e ); } } } @@ -584,7 +608,8 @@ public ProjectVersionRef getPathTargetRef( final GraphView view, final GraphPath .getPathTargetRef( path ); } - public GraphPath createPath( final GraphView view, final GraphPath parentPath, final ProjectRelationship relationship ) + public GraphPath createPath( final GraphView view, final GraphPath parentPath, + final ProjectRelationship relationship ) { return view.getDatabase() .createPath( parentPath, relationship ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/AncestryTraversalTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/AncestryTraversalTCK.java index fd8e9ece..4c92887d 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/AncestryTraversalTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/AncestryTraversalTCK.java @@ -46,8 +46,13 @@ public void traverseTwoAncestors() final URI source = sourceURI(); /* @formatter:off */ - final EProjectGraph graph = getManager().createGraph( simpleWorkspace(), new EProjectDirectRelationships.Builder( new EProjectKey( source, myRef ) ).build() ); - graph.addAll( Arrays.asList( new ParentRelationship( source, myRef, parentRef ), new ParentRelationship( source, parentRef, grandRef ), new ParentRelationship( source, grandRef ) ) ); + final EProjectGraph graph = getManager().createGraph( simpleWorkspace(), + new EProjectDirectRelationships.Builder( new EProjectKey( source, myRef ) ).build() ); + + graph.addAll( Arrays.asList( + new ParentRelationship( source, myRef, parentRef ), + new ParentRelationship( source, parentRef, grandRef ), + new ParentRelationship( source, grandRef ) ) ); /* @formatter:on */ final Set projects = graph.getAllProjects(); From 1b3c2140944d99c4ed14879c19a2a8861b8d62cf Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 21 May 2014 09:55:11 -0500 Subject: [PATCH 004/240] reformatting. --- codestyle.xml | 291 ++++++++++++++++++ .../spi/jung/CycleDetectionTraversal.java | 3 +- .../graph/spi/jung/JungEGraphDriver.java | 96 ++++-- .../graph/spi/jung/JungWorkspaceFactory.java | 3 +- .../spi/jung/PathDetectionTraversal.java | 3 +- .../spi/neo4j/FileNeo4JEGraphDriver.java | 3 +- .../atlas/graph/spi/neo4j/GraphAdmin.java | 3 +- .../atlas/graph/spi/neo4j/GraphRelType.java | 3 +- .../atlas/graph/spi/neo4j/PathComparator.java | 6 +- .../atlas/graph/spi/neo4j/io/Conversions.java | 36 ++- .../traverse/AbstractTraverseVisitor.java | 3 +- .../MembershipWrappedTraversalEvaluator.java | 11 +- .../neo4j/traverse/PathExistenceVisitor.java | 3 +- .../spi/neo4j/traverse/TraversalUtils.java | 4 +- .../spi/neo4j/update/CycleCacheUpdater.java | 3 +- .../graph/spi/neo4j/update/ViewUpdater.java | 10 +- .../graph/spi/neo4j/CypherQueriesTest.java | 6 +- .../maven/atlas/ident/DependencyScope.java | 10 +- .../maven/atlas/ident/ref/ArtifactRef.java | 12 +- .../maven/atlas/ident/ref/ProjectRef.java | 9 +- .../atlas/ident/ref/ProjectVersionRef.java | 18 +- .../ident/ref/VersionlessArtifactRef.java | 9 +- .../maven/atlas/ident/util/IdentityUtils.java | 16 +- .../InvalidVersionSpecificationException.java | 3 +- .../atlas/ident/version/SingleVersion.java | 9 +- .../ident/version/part/VersionPhrase.java | 12 +- .../graph/filter/AbstractTypedFilter.java | 30 +- .../atlas/graph/filter/DependencyFilter.java | 13 +- .../graph/filter/DependencyOnlyFilter.java | 7 +- .../graph/filter/PluginDependencyFilter.java | 3 +- .../filter/PluginDependencyOnlyFilter.java | 3 +- .../graph/filter/PluginRuntimeFilter.java | 4 +- .../model/EProjectDirectRelationships.java | 33 +- .../atlas/graph/model/EProjectGraph.java | 9 +- .../maven/atlas/graph/model/EProjectWeb.java | 17 +- .../atlas/graph/model/GraphPathInfo.java | 3 +- .../maven/atlas/graph/model/GraphView.java | 27 +- .../mutate/ManagedDependencyMutator.java | 8 +- .../atlas/graph/mutate/NoOpGraphMutator.java | 3 +- .../graph/mutate/VersionManagerMutator.java | 3 +- .../atlas/graph/rel/BomRelationship.java | 3 +- .../graph/rel/DependencyRelationship.java | 32 +- .../graph/rel/ExtensionRelationship.java | 6 +- .../atlas/graph/rel/ParentRelationship.java | 3 +- .../rel/PluginDependencyRelationship.java | 37 ++- .../atlas/graph/rel/PluginRelationship.java | 26 +- .../atlas/graph/rel/RelationshipType.java | 5 +- .../atlas/graph/spi/GraphDatabaseDriver.java | 18 +- .../traverse/AbstractFilteringTraversal.java | 18 +- .../graph/traverse/BuildOrderTraversal.java | 3 +- .../TransitiveDependencyTraversal.java | 6 +- .../graph/traverse/print/ListPrinter.java | 4 +- .../print/StructurePrintingTraversal.java | 17 +- .../traverse/print/TargetRefPrinter.java | 8 +- .../graph/traverse/print/TreePrinter.java | 9 +- .../atlas/graph/util/RelationshipUtils.java | 215 ++++++++----- .../GraphWorkspaceConfiguration.java | 3 +- .../atlas/tck/graph/AbstractSPI_TCK.java | 7 +- .../atlas/tck/graph/SubGraphSelectionTCK.java | 18 +- .../traverse/BuildOrderTraversalTCK.java | 24 +- .../TransitiveDependencyTraversalTCK.java | 4 +- 61 files changed, 870 insertions(+), 344 deletions(-) create mode 100644 codestyle.xml diff --git a/codestyle.xml b/codestyle.xml new file mode 100644 index 00000000..9e8c5134 --- /dev/null +++ b/codestyle.xml @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTraversal.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTraversal.java index c4ceaab3..1d4db618 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTraversal.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTraversal.java @@ -38,7 +38,8 @@ public List getCycles() } @Override - public boolean preCheck( final ProjectRelationship relationship, final List> path, final int pass ) + public boolean preCheck( final ProjectRelationship relationship, final List> path, + final int pass ) { if ( rel.getDeclaring() .equals( rel.getTarget() diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungEGraphDriver.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungEGraphDriver.java index 0e231943..d0131801 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungEGraphDriver.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungEGraphDriver.java @@ -71,7 +71,8 @@ public class JungEGraphDriver private final Map> metadataOwners = new HashMap>(); - private final Map> metadata = new HashMap>(); + private final Map> metadata = + new HashMap>(); private final Set cycles = new HashSet(); @@ -85,13 +86,15 @@ public JungEGraphDriver( final GraphWorkspaceConfiguration config ) } @Override - public Collection> getRelationshipsDeclaredBy( final GraphView view, final ProjectVersionRef ref ) + public Collection> getRelationshipsDeclaredBy( final GraphView view, + final ProjectVersionRef ref ) { return imposeSelections( view, graph.getOutEdges( ref.asProjectVersionRef() ) ); } @Override - public Collection> getRelationshipsTargeting( final GraphView view, final ProjectVersionRef ref ) + public Collection> getRelationshipsTargeting( final GraphView view, + final ProjectVersionRef ref ) { return imposeSelections( view, graph.getInEdges( ref.asProjectVersionRef() ) ); } @@ -102,7 +105,8 @@ public Collection> getAllRelationships( final GraphView v return imposeSelections( view, graph.getEdges() ); } - private Collection> imposeSelections( final GraphView view, final Collection> edges ) + private Collection> imposeSelections( final GraphView view, + final Collection> edges ) { if ( edges == null || edges.isEmpty() ) { @@ -210,7 +214,8 @@ else if ( !graph.containsVertex( target ) ) addGA( target ); } - final List> edges = new ArrayList>( graph.findEdgeSet( rel.getDeclaring(), target ) ); + final List> edges = + new ArrayList>( graph.findEdgeSet( rel.getDeclaring(), target ) ); if ( !edges.contains( rel ) ) { // logger.info( "Adding edge: %s -> %s", rel.getDeclaring(), target ); @@ -281,7 +286,8 @@ public Set>> getAllPathsTo( final GraphView view, fi if ( roots == null ) { LoggerFactory.getLogger( getClass() ) - .warn( "Cannot retrieve paths targeting {}. No roots specified for this project network!", new JoinString( ", ", refs ) ); + .warn( "Cannot retrieve paths targeting {}. No roots specified for this project network!", + new JoinString( ", ", refs ) ); return null; } @@ -319,7 +325,8 @@ public Set getAllProjects( final GraphView view ) } @Override - public void traverse( final GraphView view, final ProjectNetTraversal traversal, final EProjectNet net, final ProjectVersionRef root ) + public void traverse( final GraphView view, final ProjectNetTraversal traversal, final EProjectNet net, + final ProjectVersionRef root ) throws GraphDriverException { final int passes = traversal.getRequiredPasses(); @@ -346,13 +353,14 @@ public void traverse( final GraphView view, final ProjectNetTraversal traversal, } // TODO: Implement without recursion. - private void dfsTraverse( final GraphView view, final ProjectNetTraversal traversal, final int pass, final ProjectVersionRef root ) + private void dfsTraverse( final GraphView view, final ProjectNetTraversal traversal, final int pass, + final ProjectVersionRef root ) { dfsIterate( view, root, traversal, new JungGraphPath( root ), new GraphPathInfo( view ), pass ); } - private void dfsIterate( final GraphView view, final ProjectVersionRef node, final ProjectNetTraversal traversal, final JungGraphPath path, - final GraphPathInfo pathInfo, final int pass ) + private void dfsIterate( final GraphView view, final ProjectVersionRef node, final ProjectNetTraversal traversal, + final JungGraphPath path, final GraphPathInfo pathInfo, final int pass ) { final List> edges = getSortedOutEdges( view, node ); if ( edges != null ) @@ -391,15 +399,16 @@ private void dfsIterate( final GraphView view, final ProjectVersionRef node, fin } // TODO: Implement without recursion. - private void bfsTraverse( final GraphView view, final ProjectNetTraversal traversal, final int pass, final ProjectVersionRef root ) + private void bfsTraverse( final GraphView view, final ProjectNetTraversal traversal, final int pass, + final ProjectVersionRef root ) { final GraphPathInfo pathInfo = new GraphPathInfo( view ); bfsIterate( view, Collections.singletonMap( new JungGraphPath( root ), pathInfo ), traversal, pass ); } - private void bfsIterate( final GraphView view, final Map thisLayer, final ProjectNetTraversal traversal, - final int pass ) + private void bfsIterate( final GraphView view, final Map thisLayer, + final ProjectNetTraversal traversal, final int pass ) { final Map nextLayer = new LinkedHashMap(); @@ -433,7 +442,8 @@ private void bfsIterate( final GraphView view, final Map> getSortedOutEdges( final GraphView view, fi RelationshipUtils.filterTerminalParents( unsorted ); - final List> sorted = new ArrayList>( imposeSelections( view, unsorted ) ); + final List> sorted = + new ArrayList>( imposeSelections( view, unsorted ) ); Collections.sort( sorted, RelationshipComparator.INSTANCE ); return sorted; @@ -498,7 +509,8 @@ private List> getSortedOutEdges( final GraphView view, fi @Override public boolean containsProject( final GraphView view, final ProjectVersionRef ref ) { - return graph.containsVertex( ref.asProjectVersionRef() ) && !incompleteSubgraphs.contains( ref.asProjectVersionRef() ); + return graph.containsVertex( ref.asProjectVersionRef() ) + && !incompleteSubgraphs.contains( ref.asProjectVersionRef() ); } @Override @@ -849,21 +861,26 @@ public void addDisconnectedProject( final ProjectVersionRef ref ) @Deprecated @Override public Set> getDirectRelationshipsFrom( final GraphView view, final ProjectVersionRef from, - final boolean includeManagedInfo, final RelationshipType... types ) + final boolean includeManagedInfo, + final RelationshipType... types ) { return getDirectRelationshipsFrom( view, from, includeManagedInfo, true, types ); } @Override public Set> getDirectRelationshipsFrom( final GraphView view, final ProjectVersionRef from, - final boolean includeManagedInfo, final boolean includeConcreteInfo, + final boolean includeManagedInfo, + final boolean includeConcreteInfo, final RelationshipType... types ) { - return getMatchingRelationships( graph.getOutEdges( from.asProjectVersionRef() ), view, includeManagedInfo, includeConcreteInfo, types ); + return getMatchingRelationships( graph.getOutEdges( from.asProjectVersionRef() ), view, includeManagedInfo, + includeConcreteInfo, types ); } - private Set> getMatchingRelationships( final Collection> edges, final GraphView view, - final boolean includeManagedInfo, final boolean includeConcreteInfo, + private Set> getMatchingRelationships( final Collection> edges, + final GraphView view, + final boolean includeManagedInfo, + final boolean includeConcreteInfo, final RelationshipType... types ) { if ( edges == null ) @@ -917,24 +934,29 @@ private Set> getMatchingRelationships( final Collection

> getDirectRelationshipsTo( final GraphView view, final ProjectVersionRef to, final boolean includeManagedInfo, + public Set> getDirectRelationshipsTo( final GraphView view, final ProjectVersionRef to, + final boolean includeManagedInfo, final RelationshipType... types ) { return getDirectRelationshipsTo( view, to, includeManagedInfo, true, types ); } @Override - public Set> getDirectRelationshipsTo( final GraphView view, final ProjectVersionRef to, final boolean includeManagedInfo, - final boolean includeConcreteInfo, final RelationshipType... types ) + public Set> getDirectRelationshipsTo( final GraphView view, final ProjectVersionRef to, + final boolean includeManagedInfo, + final boolean includeConcreteInfo, + final RelationshipType... types ) { // logger.info( "Getting relationships targeting: %s (types: %s)", to, join( types, ", " ) ); - return getMatchingRelationships( graph.getInEdges( to.asProjectVersionRef() ), view, includeManagedInfo, includeConcreteInfo, types ); + return getMatchingRelationships( graph.getInEdges( to.asProjectVersionRef() ), view, includeManagedInfo, + includeConcreteInfo, types ); } @Override public Set getProjectsMatching( final GraphView eProjectNetView, final ProjectRef projectRef ) { - return byGA.containsKey( projectRef.asProjectRef() ) ? byGA.get( projectRef.asProjectRef() ) : Collections. emptySet(); + return byGA.containsKey( projectRef.asProjectRef() ) ? byGA.get( projectRef.asProjectRef() ) + : Collections. emptySet(); } @Override @@ -961,7 +983,8 @@ public void printStats() } @Override - public ProjectVersionRef getManagedTargetFor( final ProjectVersionRef target, final GraphPath path, final RelationshipType type ) + public ProjectVersionRef getManagedTargetFor( final ProjectVersionRef target, final GraphPath path, + final RelationshipType type ) { if ( path == null ) { @@ -970,7 +993,9 @@ public ProjectVersionRef getManagedTargetFor( final ProjectVersionRef target, fi if ( !( path instanceof JungGraphPath ) ) { - throw new IllegalArgumentException( "Cannot process GraphPath's from other implementations. (Non-Jung GraphPath detected: " + path + ")" ); + throw new IllegalArgumentException( + "Cannot process GraphPath's from other implementations. (Non-Jung GraphPath detected: " + + path + ")" ); } final ProjectRef targetGA = target.asProjectRef(); @@ -1026,7 +1051,8 @@ public GraphPath createPath( final GraphPath parent, final ProjectRelation if ( parent != null && !( parent instanceof JungGraphPath ) ) { - throw new IllegalArgumentException( "Cannot get child path for: " + parent + ". This is not a JungGraphPath instance!" ); + throw new IllegalArgumentException( "Cannot get child path for: " + parent + + ". This is not a JungGraphPath instance!" ); } return new JungGraphPath( (JungGraphPath) parent, child ); @@ -1148,7 +1174,8 @@ public boolean registerView( final GraphView view ) } @Override - public void registerViewSelection( final GraphView view, final ProjectRef ref, final ProjectVersionRef projectVersionRef ) + public void registerViewSelection( final GraphView view, final ProjectRef ref, + final ProjectVersionRef projectVersionRef ) { // NOP } @@ -1162,7 +1189,8 @@ public Map, GraphPathInfo> getPathMapTargeting( final GraphView vie if ( roots == null ) { LoggerFactory.getLogger( getClass() ) - .warn( "Cannot retrieve paths targeting {}. No roots specified for this project network!", new JoinString( ", ", refs ) ); + .warn( "Cannot retrieve paths targeting {}. No roots specified for this project network!", + new JoinString( ", ", refs ) ); return null; } @@ -1188,7 +1216,8 @@ public ProjectVersionRef getPathTargetRef( final GraphPath path ) { if ( path != null && !( path instanceof JungGraphPath ) ) { - throw new IllegalArgumentException( "Cannot get target GAV for: " + path + ". This is not a JungGraphPath instance!" ); + throw new IllegalArgumentException( "Cannot get target GAV for: " + path + + ". This is not a JungGraphPath instance!" ); } return ( (JungGraphPath) path ).getTargetGAV(); @@ -1199,7 +1228,8 @@ public List getPathRefs( final GraphView view, final GraphPat { if ( path != null && !( path instanceof JungGraphPath ) ) { - throw new IllegalArgumentException( "Cannot get target GAV for: " + path + ". This is not a JungGraphPath instance!" ); + throw new IllegalArgumentException( "Cannot get target GAV for: " + path + + ". This is not a JungGraphPath instance!" ); } final JungGraphPath gp = (JungGraphPath) path; diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungWorkspaceFactory.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungWorkspaceFactory.java index 42b309ab..123d08b2 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungWorkspaceFactory.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungWorkspaceFactory.java @@ -45,7 +45,8 @@ public GraphWorkspace createWorkspace( final String id, final GraphWorkspaceConf public GraphWorkspace createWorkspace( final GraphWorkspaceConfiguration config ) throws GraphDriverException { - final GraphWorkspace ws = new GraphWorkspace( Long.toString( System.currentTimeMillis() ), new JungEGraphDriver( config ) ); + final GraphWorkspace ws = + new GraphWorkspace( Long.toString( System.currentTimeMillis() ), new JungEGraphDriver( config ) ); workspaces.put( ws.getId(), ws ); return ws; } diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java index a9302235..e00ef53a 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java @@ -60,7 +60,8 @@ public Set getPaths() } @Override - public boolean preCheck( final ProjectRelationship relationship, final List> path, final int pass ) + public boolean preCheck( final ProjectRelationship relationship, final List> path, + final int pass ) { JungGraphPath jpath; GraphPathInfo pathInfo; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JEGraphDriver.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JEGraphDriver.java index 5a391620..a3fab242 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JEGraphDriver.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JEGraphDriver.java @@ -26,7 +26,8 @@ public FileNeo4JEGraphDriver( final GraphWorkspaceConfiguration config, final Fi this( config, dbPath, true ); } - public FileNeo4JEGraphDriver( final GraphWorkspaceConfiguration config, final File dbPath, final boolean useShutdownHook ) + public FileNeo4JEGraphDriver( final GraphWorkspaceConfiguration config, final File dbPath, + final boolean useShutdownHook ) { super( config, new GraphDatabaseFactory().newEmbeddedDatabase( dbPath.getAbsolutePath() ), useShutdownHook ); } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphAdmin.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphAdmin.java index 4408bb19..e1faa420 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphAdmin.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphAdmin.java @@ -26,7 +26,8 @@ public interface GraphAdmin Relationship getRelationship( long rid ); - Relationship select( Relationship r, GraphView view, Node viewNode, GraphPathInfo viewPathInfo, Neo4jGraphPath viewPath ); + Relationship select( Relationship r, GraphView view, Node viewNode, GraphPathInfo viewPathInfo, + Neo4jGraphPath viewPath ); RelationshipIndex getRelationshipIndex( String name ); diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphRelType.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphRelType.java index c0bc07d6..21914bd7 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphRelType.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphRelType.java @@ -65,7 +65,8 @@ public org.commonjava.maven.atlas.graph.rel.RelationshipType atlasType() return atlasType; } - public static GraphRelType map( final org.commonjava.maven.atlas.graph.rel.RelationshipType type, final boolean managed ) + public static GraphRelType map( final org.commonjava.maven.atlas.graph.rel.RelationshipType type, + final boolean managed ) { for ( final GraphRelType mapper : values() ) { diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java index f7eaf40f..65d82e80 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java @@ -36,8 +36,10 @@ private PathComparator() @Override public int compare( final Path first, final Path second ) { - final List> firstRels = Conversions.convertToRelationships( first.relationships(), cache ); - final List> secondRels = Conversions.convertToRelationships( second.relationships(), cache ); + final List> firstRels = + Conversions.convertToRelationships( first.relationships(), cache ); + final List> secondRels = + Conversions.convertToRelationships( second.relationships(), cache ); return pathComparator.compare( firstRels, secondRels ); } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java index 7166f33f..973722d4 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java @@ -209,7 +209,8 @@ public static List convertToProjects( final Iterable no return refs; } - public static List> convertToRelationships( final Iterable relationships, final ConversionCache cache ) + public static List> convertToRelationships( final Iterable relationships, + final ConversionCache cache ) { final List> rels = new ArrayList>(); for ( final Relationship relationship : relationships ) @@ -224,7 +225,8 @@ public static List> convertToRelationships( final Iterabl return rels; } - public static List> convertToRelationships( final Iterable relationships, final GraphAdmin admin, + public static List> convertToRelationships( final Iterable relationships, + final GraphAdmin admin, final ConversionCache cache ) { final List> rels = new ArrayList>(); @@ -482,7 +484,8 @@ public static ProjectRelationship toProjectRelationship( final Relationship r } result = - new DependencyRelationship( source, pomLocation, from, artifact, scope, index, managed, excludes.toArray( new ProjectRef[] {} ) ); + new DependencyRelationship( source, pomLocation, from, artifact, scope, index, managed, + excludes.toArray( new ProjectRef[] {} ) ); break; } case PLUGIN_DEP: @@ -492,7 +495,9 @@ public static ProjectRelationship toProjectRelationship( final Relationship r final String pg = getStringProperty( PLUGIN_GROUP_ID, rel ); final boolean managed = getBooleanProperty( IS_MANAGED, rel ); - result = new PluginDependencyRelationship( source, pomLocation, from, new ProjectRef( pg, pa ), artifact, index, managed ); + result = + new PluginDependencyRelationship( source, pomLocation, from, new ProjectRef( pg, pa ), artifact, + index, managed ); break; } case PLUGIN: @@ -572,7 +577,8 @@ public static String getStringProperty( final String prop, final PropertyContain return null; } - public static Set getURISetProperty( final String prop, final PropertyContainer container, final URI defaultValue ) + public static Set getURISetProperty( final String prop, final PropertyContainer container, + final URI defaultValue ) { final Set result = new HashSet(); @@ -603,7 +609,8 @@ public static Set getURISetProperty( final String prop, final PropertyConta return result; } - public static void addToURISetProperty( final Collection uris, final String prop, final PropertyContainer container ) + public static void addToURISetProperty( final Collection uris, final String prop, + final PropertyContainer container ) { if ( uris == null || uris.isEmpty() ) { @@ -619,7 +626,8 @@ public static void addToURISetProperty( final Collection uris, final String container.setProperty( prop, toStringArray( existing ) ); } - public static void removeFromURISetProperty( final Collection uris, final String prop, final PropertyContainer container ) + public static void removeFromURISetProperty( final Collection uris, final String prop, + final PropertyContainer container ) { if ( uris == null || uris.isEmpty() || !container.hasProperty( prop ) ) { @@ -669,7 +677,8 @@ public static Boolean getBooleanProperty( final String prop, final PropertyConta return null; } - public static Boolean getBooleanProperty( final String prop, final PropertyContainer container, final Boolean defaultValue ) + public static Boolean getBooleanProperty( final String prop, final PropertyContainer container, + final Boolean defaultValue ) { if ( container.hasProperty( prop ) ) { @@ -733,7 +742,8 @@ public static String removeConfigProperty( final String key, final PropertyConta return old; } - public static String getConfigProperty( final String key, final PropertyContainer container, final String defaultValue ) + public static String getConfigProperty( final String key, final PropertyContainer container, + final String defaultValue ) { final String result = getStringProperty( CONFIG_PROPERTY_PREFIX + key, container ); @@ -798,7 +808,8 @@ public static String getMetadata( final String key, final PropertyContainer cont return getStringProperty( METADATA_PREFIX + key, container ); } - public static void toNodeProperties( final String cycleId, final String rawCycleId, final Set refs, final Node node ) + public static void toNodeProperties( final String cycleId, final String rawCycleId, + final Set refs, final Node node ) { node.setProperty( NODE_TYPE, NodeType.CYCLE.name() ); node.setProperty( CYCLE_ID, cycleId ); @@ -1043,8 +1054,9 @@ public static GraphView retrieveView( final Node viewNode, final ConversionCache } catch ( final IOException e ) { - throw new IllegalStateException( "Cannot construct ObjectInputStream to wrap ByteArrayInputStream containing " + data.length + " bytes!", - e ); + throw new IllegalStateException( + "Cannot construct ObjectInputStream to wrap ByteArrayInputStream containing " + + data.length + " bytes!", e ); } catch ( final ClassNotFoundException e ) { diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AbstractTraverseVisitor.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AbstractTraverseVisitor.java index 81750f08..fda7df49 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AbstractTraverseVisitor.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AbstractTraverseVisitor.java @@ -56,7 +56,8 @@ public boolean includeChildren( final Path path, final Neo4jGraphPath graphPath, } @Override - public void includingChild( final Relationship child, final Neo4jGraphPath childPath, final GraphPathInfo childPathInfo, final Path parentPath ) + public void includingChild( final Relationship child, final Neo4jGraphPath childPath, + final GraphPathInfo childPathInfo, final Path parentPath ) { } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java index 35f3bfa9..1c09900d 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java @@ -62,8 +62,9 @@ public class MembershipWrappedTraversalEvaluator private final GraphRelType[] types; - public MembershipWrappedTraversalEvaluator( final Set rootIds, final ProjectNetTraversal traversal, final GraphView view, - final Node viewNode, final GraphAdmin admin, final int pass, final GraphRelType... types ) + public MembershipWrappedTraversalEvaluator( final Set rootIds, final ProjectNetTraversal traversal, + final GraphView view, final Node viewNode, final GraphAdmin admin, + final int pass, final GraphRelType... types ) { this.rootIds = rootIds; this.traversal = traversal; @@ -74,7 +75,8 @@ public MembershipWrappedTraversalEvaluator( final Set rootIds, final Proje this.types = types; } - private MembershipWrappedTraversalEvaluator( final MembershipWrappedTraversalEvaluator ev, final boolean reversedExpander ) + private MembershipWrappedTraversalEvaluator( final MembershipWrappedTraversalEvaluator ev, + final boolean reversedExpander ) { this.rootIds = ev.rootIds; this.traversal = ev.traversal; @@ -107,7 +109,8 @@ public Evaluation evaluate( final Path path ) { final ProjectRelationship lastRel = Conversions.toProjectRelationship( rel, cache ); - final List> relPath = Conversions.convertToRelationships( path.relationships(), cache ); + final List> relPath = + Conversions.convertToRelationships( path.relationships(), cache ); if ( relPath.indexOf( lastRel ) == relPath.size() - 1 ) { // logger.warn( "\n\n\n\n\nREMOVING last-relationship: {} from path!\n\n\n\n\n" ); diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathExistenceVisitor.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathExistenceVisitor.java index ca235874..4f1042ee 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathExistenceVisitor.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathExistenceVisitor.java @@ -41,7 +41,8 @@ public boolean isEnabledFor( final Path path ) } @Override - public void includingChild( final Relationship child, final Neo4jGraphPath childPath, final GraphPathInfo childPathInfo, final Path parentPath ) + public void includingChild( final Relationship child, final Neo4jGraphPath childPath, + final GraphPathInfo childPathInfo, final Path parentPath ) { final Node end = child.getEndNode(); if ( this.end.getId() == end.getId() ) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java index a91cfdf1..70de4d29 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java @@ -95,8 +95,8 @@ public static boolean accepted( final Relationship r, final GraphView view, fina if ( !found ) { - debug( "REJECTED: Found relationship in path with de-selected source-repository URI: {} (r={}, permissable sources: {})", s, r, - sources ); + debug( "REJECTED: Found relationship in path with de-selected source-repository URI: {} (r={}, permissable sources: {})", + s, r, sources ); return false; } } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java index 16c2513d..a05e72db 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java @@ -51,7 +51,8 @@ public class CycleCacheUpdater private final GraphAdmin admin; - public CycleCacheUpdater( final GraphView view, final Node viewNode, final GraphAdmin admin, final ConversionCache cache ) + public CycleCacheUpdater( final GraphView view, final Node viewNode, final GraphAdmin admin, + final ConversionCache cache ) { this.view = view; this.viewNode = viewNode; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java index a79935ce..b67bccc9 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java @@ -57,7 +57,8 @@ public class ViewUpdater private Node stopNode; - public ViewUpdater( final GraphView view, final Node viewNode, final ViewIndexes indexes, final ConversionCache cache, final GraphAdmin admin ) + public ViewUpdater( final GraphView view, final Node viewNode, final ViewIndexes indexes, + final ConversionCache cache, final GraphAdmin admin ) { this.viewNode = viewNode; this.indexes = indexes; @@ -66,8 +67,8 @@ public ViewUpdater( final GraphView view, final Node viewNode, final ViewIndexes this.cycleUpdater = new CycleCacheUpdater( view, viewNode, admin, cache ); } - public ViewUpdater( final Node stopNode, final GraphView view, final Node viewNode, final ViewIndexes indexes, final ConversionCache cache, - final GraphAdmin admin ) + public ViewUpdater( final Node stopNode, final GraphView view, final Node viewNode, final ViewIndexes indexes, + final ConversionCache cache, final GraphAdmin admin ) { this.stopNode = stopNode; this.viewNode = viewNode; @@ -133,7 +134,8 @@ public boolean processAddedRelationships( final Map } @Override - public void includingChild( final Relationship child, final Neo4jGraphPath childPath, final GraphPathInfo childPathInfo, final Path parentPath ) + public void includingChild( final Relationship child, final Neo4jGraphPath childPath, + final GraphPathInfo childPathInfo, final Path parentPath ) { cachePath( childPath, childPathInfo ); } diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/CypherQueriesTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/CypherQueriesTest.java index 748cbd7f..a9fefcb1 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/CypherQueriesTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/CypherQueriesTest.java @@ -61,7 +61,8 @@ public void projectsWithVariableFlag_PartialQuery() final ProjectVersionRef selected = new ProjectVersionRef( varDep, "1.0-20130314.161200-1" ); final URI source = sourceURI(); - final GraphWorkspace workspace = getManager().createWorkspace( new GraphWorkspaceConfiguration().withSource( source ) ); + final GraphWorkspace workspace = + getManager().createWorkspace( new GraphWorkspaceConfiguration().withSource( source ) ); GraphView view = new GraphView( workspace, project ); /* @formatter:off */ @@ -108,7 +109,8 @@ public void projectsWithVariableFlagQuery() final ProjectVersionRef selected = new ProjectVersionRef( varDep, "1.0-20130314.161200-1" ); final URI source = sourceURI(); - final GraphWorkspace workspace = getManager().createWorkspace( new GraphWorkspaceConfiguration().withSource( source ) ); + final GraphWorkspace workspace = + getManager().createWorkspace( new GraphWorkspaceConfiguration().withSource( source ) ); GraphView view = new GraphView( workspace, project ); /* @formatter:off */ diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/DependencyScope.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/DependencyScope.java index 097699d5..f7addd00 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/DependencyScope.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/DependencyScope.java @@ -18,8 +18,14 @@ public enum DependencyScope { - _import( "import" ), toolchain, provided, embedded, compile( provided, embedded ), runtime( compile ), system, test( provided, embedded, compile, - runtime, system ); + _import( "import" ), + toolchain, + provided, + embedded, + compile( provided, embedded ), + runtime( compile ), + system, + test( provided, embedded, compile, runtime, system ); private final Set implied; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java index 41df7dc6..c12bb6e1 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java @@ -38,8 +38,8 @@ public class ArtifactRef private final boolean optional; - public ArtifactRef( final String groupId, final String artifactId, final VersionSpec version, final String type, final String classifier, - final boolean optional ) + public ArtifactRef( final String groupId, final String artifactId, final VersionSpec version, final String type, + final String classifier, final boolean optional ) { super( groupId, artifactId, version ); this.optional = optional; @@ -60,8 +60,8 @@ public ArtifactRef( final ProjectVersionRef ref, final TypeAndClassifier tc, fin this.optional = optional; } - public ArtifactRef( final String groupId, final String artifactId, final String versionSpec, final String type, final String classifier, - final boolean optional ) + public ArtifactRef( final String groupId, final String artifactId, final String versionSpec, final String type, + final String classifier, final boolean optional ) throws InvalidVersionSpecificationException { super( groupId, artifactId, versionSpec ); @@ -155,8 +155,8 @@ else if ( !tc.equals( other.tc ) ) @Override public String toString() { - return String.format( "%s:%s:%s:%s%s", getGroupId(), getArtifactId(), getType(), getVersionString(), ( getClassifier() == null ? "" : ":" - + getClassifier() ) ); + return String.format( "%s:%s:%s:%s%s", getGroupId(), getArtifactId(), getType(), getVersionString(), + ( getClassifier() == null ? "" : ":" + getClassifier() ) ); } @Override diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java index aaeb1c40..c5168f9d 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java @@ -35,7 +35,8 @@ public ProjectRef( final String groupId, final String artifactId ) { if ( isEmpty( groupId ) || isEmpty( artifactId ) ) { - throw new InvalidRefException( "ProjectId must contain non-empty groupId AND artifactId. (Given: '" + groupId + "':'" + artifactId + "')" ); + throw new InvalidRefException( "ProjectId must contain non-empty groupId AND artifactId. (Given: '" + + groupId + "':'" + artifactId + "')" ); } this.groupId = groupId; @@ -47,7 +48,8 @@ public static ProjectRef parse( final String ga ) final String[] parts = ga.split( ":" ); if ( parts.length < 2 || isEmpty( parts[0] ) || isEmpty( parts[1] ) ) { - throw new InvalidRefException( "ProjectRef must contain non-empty groupId AND artifactId. (Given: '" + ga + "')" ); + throw new InvalidRefException( "ProjectRef must contain non-empty groupId AND artifactId. (Given: '" + ga + + "')" ); } return new ProjectRef( parts[0], parts[1] ); @@ -83,7 +85,8 @@ public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final return asVersionlessArtifactRef( type, classifier, false ); } - public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier, final boolean optional ) + public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier, + final boolean optional ) { return new VersionlessArtifactRef( this, type, classifier, optional ); } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java index 4032dcc5..77795479 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java @@ -50,12 +50,14 @@ public ProjectVersionRef( final ProjectRef ref, final String versionSpec ) this( ref.getGroupId(), ref.getArtifactId(), versionSpec ); } - ProjectVersionRef( final String groupId, final String artifactId, final VersionSpec versionSpec, final String versionString ) + ProjectVersionRef( final String groupId, final String artifactId, final VersionSpec versionSpec, + final String versionString ) { super( groupId, artifactId ); if ( versionSpec == null && versionString == null ) { - throw new InvalidRefException( "Version spec AND string cannot both be null for '" + groupId + ":" + artifactId + "'" ); + throw new InvalidRefException( "Version spec AND string cannot both be null for '" + groupId + ":" + + artifactId + "'" ); } this.versionString = versionString; @@ -78,7 +80,9 @@ public static ProjectVersionRef parse( final String gav ) final String[] parts = gav.split( ":" ); if ( parts.length < 3 || isEmpty( parts[0] ) || isEmpty( parts[1] ) || isEmpty( parts[2] ) ) { - throw new InvalidRefException( "ProjectVersionRef must contain non-empty groupId, artifactId, AND version. (Given: '" + gav + "')" ); + throw new InvalidRefException( + "ProjectVersionRef must contain non-empty groupId, artifactId, AND version. (Given: '" + + gav + "')" ); } return new ProjectVersionRef( parts[0], parts[1], parts[2] ); @@ -86,7 +90,9 @@ public static ProjectVersionRef parse( final String gav ) public ProjectVersionRef asProjectVersionRef() { - return ProjectVersionRef.class.equals( getClass() ) ? this : new ProjectVersionRef( getGroupId(), getArtifactId(), getVersionSpecRaw(), + return ProjectVersionRef.class.equals( getClass() ) ? this : new ProjectVersionRef( getGroupId(), + getArtifactId(), + getVersionSpecRaw(), getVersionStringRaw() ); } @@ -179,8 +185,8 @@ public ProjectVersionRef selectVersion( final SingleVersion version, final boole if ( !force && !versionSpec.contains( version ) ) { - throw new IllegalArgumentException( "Specified version: " + version.renderStandard() + " is not contained in spec: " - + versionSpec.renderStandard() ); + throw new IllegalArgumentException( "Specified version: " + version.renderStandard() + + " is not contained in spec: " + versionSpec.renderStandard() ); } return newRef( getGroupId(), getArtifactId(), version ); diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java index d2fe2838..0f43f054 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java @@ -35,7 +35,8 @@ public VersionlessArtifactRef( final ArtifactRef ref ) this.tc = ref.getTypeAndClassifier(); } - public VersionlessArtifactRef( final ProjectRef ref, final String type, final String classifier, final boolean optional ) + public VersionlessArtifactRef( final ProjectRef ref, final String type, final String classifier, + final boolean optional ) { super( ref.getGroupId(), ref.getArtifactId() ); this.optional = optional; @@ -49,7 +50,8 @@ public VersionlessArtifactRef( final ProjectRef ref, final TypeAndClassifier tc, this.optional = optional; } - public VersionlessArtifactRef( final String groupId, final String artifactId, final String type, final String classifier, final boolean optional ) + public VersionlessArtifactRef( final String groupId, final String artifactId, final String type, + final String classifier, final boolean optional ) throws InvalidVersionSpecificationException { super( groupId, artifactId ); @@ -146,7 +148,8 @@ public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final } @Override - public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier, final boolean optional ) + public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier, + final boolean optional ) { final TypeAndClassifier tc = new TypeAndClassifier( type, classifier ); if ( VersionlessArtifactRef.class.equals( getClass() ) && this.tc.equals( tc ) && this.optional == optional ) diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/IdentityUtils.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/IdentityUtils.java index 765e6972..210b077c 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/IdentityUtils.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/IdentityUtils.java @@ -34,14 +34,15 @@ public static ArtifactRef artifact( final ProjectVersionRef ref ) return new ArtifactRef( ref, null, null, false ); } - public static ArtifactRef artifact( final String groupId, final String artifactId, final String version, final String type, - final String classifier, final boolean optional ) + public static ArtifactRef artifact( final String groupId, final String artifactId, final String version, + final String type, final String classifier, final boolean optional ) throws InvalidVersionSpecificationException { return new ArtifactRef( projectVersion( groupId, artifactId, version ), type, classifier, optional ); } - public static ArtifactRef artifact( final ProjectVersionRef dep, final String type, final String classifier, final boolean optional ) + public static ArtifactRef artifact( final ProjectVersionRef dep, final String type, final String classifier, + final boolean optional ) { return new ArtifactRef( dep, type, classifier, optional ); } @@ -51,7 +52,8 @@ public static ProjectVersionRef projectVersion( final String src ) final String[] parts = src.split( ":" ); if ( parts.length != 3 ) { - throw new IllegalArgumentException( "Invalid: '" + src + "'. Must contain exactly three fields separated by ':'" ); + throw new IllegalArgumentException( "Invalid: '" + src + + "'. Must contain exactly three fields separated by ':'" ); } try @@ -60,7 +62,8 @@ public static ProjectVersionRef projectVersion( final String src ) } catch ( final InvalidVersionSpecificationException e ) { - throw new IllegalArgumentException( "Invalid: '" + src + "'. Version: '" + parts[2] + "' is invalid: " + e.getMessage(), e ); + throw new IllegalArgumentException( "Invalid: '" + src + "'. Version: '" + parts[2] + "' is invalid: " + + e.getMessage(), e ); } } @@ -75,7 +78,8 @@ public static ProjectRef project( final String src ) final String[] parts = src.split( ":" ); if ( parts.length < 2 ) { - throw new IllegalArgumentException( "Invalid: '" + src + "'. Must contain at least two fields separated by ':'" ); + throw new IllegalArgumentException( "Invalid: '" + src + + "'. Must contain at least two fields separated by ':'" ); } return new ProjectRef( parts[0], parts[1] ); diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/InvalidVersionSpecificationException.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/InvalidVersionSpecificationException.java index 4aa02b66..40f740be 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/InvalidVersionSpecificationException.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/InvalidVersionSpecificationException.java @@ -21,7 +21,8 @@ public class InvalidVersionSpecificationException private String version; - public InvalidVersionSpecificationException( final String version, final String message, final Throwable cause, final Object... params ) + public InvalidVersionSpecificationException( final String version, final String message, final Throwable cause, + final Object... params ) { super( "'" + version + "': " + message, cause ); this.params = params; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/SingleVersion.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/SingleVersion.java index f82f1051..f5ac07ef 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/SingleVersion.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/SingleVersion.java @@ -84,7 +84,8 @@ private List parsePhrases( final List p ) final VersionPart part = parts.get( i ); final VersionPart next = i >= parts.size() - 1 ? null : parts.get( i + 1 ); - if ( ( part instanceof SeparatorPart ) && ( VersionPartSeparator.DASH == ( (SeparatorPart) part ).getValue() ) ) + if ( ( part instanceof SeparatorPart ) + && ( VersionPartSeparator.DASH == ( (SeparatorPart) part ).getValue() ) ) { if ( prev != null && !( prev instanceof StringPart ) ) { @@ -112,7 +113,8 @@ private List parsePhrases( final List p ) i++; } } - else if ( ( ( part instanceof SnapshotPart ) || ( part instanceof StringPart ) ) && prev != null + else if ( ( ( part instanceof SnapshotPart ) || ( part instanceof StringPart ) ) + && prev != null && ( !( prev instanceof SeparatorPart ) || ( ( (SeparatorPart) prev ).getValue() != VersionPartSeparator.DASH ) ) ) { VersionPartSeparator sep = null; @@ -235,7 +237,8 @@ private void validate( final List parts ) { if ( part != parts.get( parts.size() - 1 ) && part instanceof SnapshotPart ) { - throw new InvalidVersionSpecificationException( rawExpression, "Snapshot marker MUST appear at the end of the version" ); + throw new InvalidVersionSpecificationException( rawExpression, + "Snapshot marker MUST appear at the end of the version" ); } } } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPhrase.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPhrase.java index 3ba1b75c..ccdd1a62 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPhrase.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPhrase.java @@ -66,7 +66,8 @@ else if ( part instanceof SeparatorPart ) { silenced = true; } - else if ( ( part instanceof StringPart ) && ( (StringPart) part ).getZeroCompareIndex() == StringPart.ADJ_ZERO_EQUIV_INDEX ) + else if ( ( part instanceof StringPart ) + && ( (StringPart) part ).getZeroCompareIndex() == StringPart.ADJ_ZERO_EQUIV_INDEX ) { silenced = true; } @@ -167,7 +168,8 @@ private void validate( final List parts ) { if ( part != parts.get( parts.size() - 1 ) && part instanceof SnapshotPart ) { - throw new InvalidVersionSpecificationException( renderStandard( parts ), "Snapshot marker MUST appear at the end of the version" ); + throw new InvalidVersionSpecificationException( renderStandard( parts ), + "Snapshot marker MUST appear at the end of the version" ); } } } @@ -186,8 +188,10 @@ public VersionPhrase getBaseVersion() } catch ( final InvalidVersionSpecificationException e ) { - throw new InvalidVersionSpecificationException( e.getVersion(), "Cannot create base version for non-release: %s. Reason: %s", e, - e.getVersion(), e.getMessage() ); + throw new InvalidVersionSpecificationException( + e.getVersion(), + "Cannot create base version for non-release: %s. Reason: %s", + e, e.getVersion(), e.getMessage() ); } } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java index 6d8d3b0f..17042168 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java @@ -45,8 +45,8 @@ public abstract class AbstractTypedFilter private transient String shortId; - protected AbstractTypedFilter( final RelationshipType type, final RelationshipType descendantType, final boolean includeManagedInfo, - final boolean includeConcreteInfo ) + protected AbstractTypedFilter( final RelationshipType type, final RelationshipType descendantType, + final boolean includeManagedInfo, final boolean includeConcreteInfo ) { this.types = Collections.unmodifiableSet( Collections.singleton( type ) ); this.descendantTypes = Collections.unmodifiableSet( Collections.singleton( descendantType ) ); @@ -54,12 +54,13 @@ protected AbstractTypedFilter( final RelationshipType type, final RelationshipTy this.includeConcreteInfo = includeConcreteInfo; } - protected AbstractTypedFilter( final RelationshipType type, final Collection descendantTypes, final boolean includeManagedInfo, - final boolean includeConcreteInfo ) + protected AbstractTypedFilter( final RelationshipType type, final Collection descendantTypes, + final boolean includeManagedInfo, final boolean includeConcreteInfo ) { if ( type == null ) { - this.types = Collections.unmodifiableSet( new HashSet( Arrays.asList( RelationshipType.values() ) ) ); + this.types = + Collections.unmodifiableSet( new HashSet( Arrays.asList( RelationshipType.values() ) ) ); } else { @@ -68,7 +69,8 @@ protected AbstractTypedFilter( final RelationshipType type, final Collection( Arrays.asList( RelationshipType.values() ) ) ); + this.descendantTypes = + Collections.unmodifiableSet( new HashSet( Arrays.asList( RelationshipType.values() ) ) ); } else { @@ -79,12 +81,14 @@ protected AbstractTypedFilter( final RelationshipType type, final Collection types, final Collection descendantTypes, + protected AbstractTypedFilter( final Collection types, + final Collection descendantTypes, final boolean includeManagedInfo, final boolean includeConcreteInfo ) { if ( types == null || types.isEmpty() ) { - this.types = Collections.unmodifiableSet( new HashSet( Arrays.asList( RelationshipType.values() ) ) ); + this.types = + Collections.unmodifiableSet( new HashSet( Arrays.asList( RelationshipType.values() ) ) ); } else { @@ -93,7 +97,8 @@ protected AbstractTypedFilter( final Collection types, final C if ( descendantTypes == null || descendantTypes.isEmpty() ) { - this.descendantTypes = Collections.unmodifiableSet( new HashSet( Arrays.asList( RelationshipType.values() ) ) ); + this.descendantTypes = + Collections.unmodifiableSet( new HashSet( Arrays.asList( RelationshipType.values() ) ) ); } else { @@ -104,12 +109,13 @@ protected AbstractTypedFilter( final Collection types, final C this.includeConcreteInfo = includeConcreteInfo; } - protected AbstractTypedFilter( final RelationshipType type, final boolean hasDescendants, final boolean includeManagedInfo, - final boolean includeConcreteInfo ) + protected AbstractTypedFilter( final RelationshipType type, final boolean hasDescendants, + final boolean includeManagedInfo, final boolean includeConcreteInfo ) { if ( type == null ) { - this.types = Collections.unmodifiableSet( new HashSet( Arrays.asList( RelationshipType.values() ) ) ); + this.types = + Collections.unmodifiableSet( new HashSet( Arrays.asList( RelationshipType.values() ) ) ); } else { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java index 6390e741..c54464e3 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java @@ -48,14 +48,15 @@ public DependencyFilter( final DependencyScope scope ) this( scope, ScopeTransitivity.maven, false, true, true, null ); } - public DependencyFilter( final DependencyScope scope, final ScopeTransitivity scopeTransitivity, final boolean includeManaged, - final boolean includeConcrete, final Set excludes ) + public DependencyFilter( final DependencyScope scope, final ScopeTransitivity scopeTransitivity, + final boolean includeManaged, final boolean includeConcrete, final Set excludes ) { this( scope, scopeTransitivity, includeManaged, includeConcrete, true, excludes ); } - public DependencyFilter( final DependencyScope scope, final ScopeTransitivity scopeTransitivity, final boolean includeManaged, - final boolean includeConcrete, final boolean useImpliedScopes, final Set excludes ) + public DependencyFilter( final DependencyScope scope, final ScopeTransitivity scopeTransitivity, + final boolean includeManaged, final boolean includeConcrete, + final boolean useImpliedScopes, final Set excludes ) { super( RelationshipType.DEPENDENCY, true, includeManaged, includeConcrete ); this.useImpliedScopes = useImpliedScopes; @@ -128,8 +129,8 @@ public ProjectRelationshipFilter getChildFilter( final ProjectRelationship pa newExcludes = ex; } - return new DependencyFilter( nextScope, scopeTransitivity, includeManagedRelationships(), includeConcreteRelationships(), - useImpliedScopes, newExcludes ); + return new DependencyFilter( nextScope, scopeTransitivity, includeManagedRelationships(), + includeConcreteRelationships(), useImpliedScopes, newExcludes ); } return this; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java index 8054a20c..b5884c77 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java @@ -43,8 +43,8 @@ public DependencyOnlyFilter( final DependencyScope... scopes ) this( false, true, true, scopes ); } - public DependencyOnlyFilter( final boolean includeManaged, final boolean includeConcrete, final boolean useImpliedScope, - final DependencyScope... scopes ) + public DependencyOnlyFilter( final boolean includeManaged, final boolean includeConcrete, + final boolean useImpliedScope, final DependencyScope... scopes ) { super( RelationshipType.DEPENDENCY, false, includeManaged, includeConcrete ); @@ -66,7 +66,8 @@ public boolean doAccept( final ProjectRelationship rel ) { if ( scope == s || ( useImpliedScope && s.implies( scope ) ) ) { - if ( ( dr.isManaged() && includeManagedRelationships() ) || ( !dr.isManaged() && includeConcreteRelationships() ) ) + if ( ( dr.isManaged() && includeManagedRelationships() ) + || ( !dr.isManaged() && includeConcreteRelationships() ) ) { return true; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyFilter.java index d5f9e020..484f1656 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyFilter.java @@ -34,7 +34,8 @@ public PluginDependencyFilter( final PluginRelationship plugin ) this( plugin, false, true ); } - public PluginDependencyFilter( final PluginRelationship plugin, final boolean includeManaged, final boolean includeConcrete ) + public PluginDependencyFilter( final PluginRelationship plugin, final boolean includeManaged, + final boolean includeConcrete ) { super( RelationshipType.PLUGIN_DEP, RelationshipType.DEPENDENCY, includeManaged, includeConcrete ); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyOnlyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyOnlyFilter.java index f991ceee..ad7c1368 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyOnlyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyOnlyFilter.java @@ -32,7 +32,8 @@ public PluginDependencyOnlyFilter( final PluginRelationship plugin ) this( plugin, false, true ); } - public PluginDependencyOnlyFilter( final PluginRelationship plugin, final boolean includeManaged, final boolean includeConcrete ) + public PluginDependencyOnlyFilter( final PluginRelationship plugin, final boolean includeManaged, + final boolean includeConcrete ) { super( RelationshipType.PLUGIN_DEP, false, includeManaged, includeConcrete ); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java index 1c67140f..365d79c5 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java @@ -47,8 +47,8 @@ public ProjectRelationshipFilter getChildFilter( final ProjectRelationship pa final PluginRelationship plugin = (PluginRelationship) parent; child = - new OrFilter( new DependencyFilter( DependencyScope.runtime ), new PluginDependencyFilter( plugin, true, true ), - ParentFilter.EXCLUDE_TERMINAL_PARENTS ); + new OrFilter( new DependencyFilter( DependencyScope.runtime ), + new PluginDependencyFilter( plugin, true, true ), ParentFilter.EXCLUDE_TERMINAL_PARENTS ); } else { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java index 249aac75..91d8bdd5 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java @@ -60,9 +60,13 @@ public class EProjectDirectRelationships private final Map> pluginDependencies; - public EProjectDirectRelationships( final EProjectKey key, final ParentRelationship parent, final List boms, - final List dependencies, final List plugins, - final List managedDependencies, final List managedPlugins, + public EProjectDirectRelationships( final EProjectKey key, + final ParentRelationship parent, + final List boms, + final List dependencies, + final List plugins, + final List managedDependencies, + final List managedPlugins, final List extensions, final Map> pluginDependencies ) { @@ -131,7 +135,8 @@ public final Map> getPlug return pluginDependencies; } - public final List getPluginDependencies( final ProjectVersionRef plugin, final boolean managed ) + public final List getPluginDependencies( final ProjectVersionRef plugin, + final boolean managed ) { final PluginRelationship pr = new PluginRelationship( key.getSource(), getProjectRef(), plugin, 0, managed ); return pluginDependencies.get( pr ); @@ -213,8 +218,8 @@ public EProjectDirectRelationships build() parent = new ParentRelationship( key.getSource(), key.getProject() ); } - return new EProjectDirectRelationships( key, parent, boms, dependencies, plugins, managedDependencies, managedPlugins, extensions, - pluginDependencies ); + return new EProjectDirectRelationships( key, parent, boms, dependencies, plugins, managedDependencies, + managedPlugins, extensions, pluginDependencies ); } public Builder withParent( final ProjectVersionRef parent ) @@ -354,8 +359,10 @@ public Builder withPluginDependencies( final Collection pdrs = pluginDependencies.get( pr ); @@ -463,10 +470,11 @@ public int getNextExtensionIndex() return extensions.size(); } - public Builder withDependency( final ProjectVersionRef ref, final String type, final String classifier, final DependencyScope scope, - final boolean managed ) + public Builder withDependency( final ProjectVersionRef ref, final String type, final String classifier, + final DependencyScope scope, final boolean managed ) { - withDependencies( new DependencyRelationship( key.getSource(), key.getProject(), new ArtifactRef( ref, type, classifier, false ), scope, + withDependencies( new DependencyRelationship( key.getSource(), key.getProject(), + new ArtifactRef( ref, type, classifier, false ), scope, getNextDependencyIndex( managed ), managed ) ); return this; @@ -474,7 +482,8 @@ public Builder withDependency( final ProjectVersionRef ref, final String type, f public Builder withPlugin( final ProjectVersionRef ref, final boolean managed ) { - withPlugins( new PluginRelationship( key.getSource(), key.getProject(), ref, getNextPluginIndex( managed ), managed ) ); + withPlugins( new PluginRelationship( key.getSource(), key.getProject(), ref, getNextPluginIndex( managed ), + managed ) ); return this; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectGraph.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectGraph.java index ef113b7f..67fd6459 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectGraph.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectGraph.java @@ -46,8 +46,8 @@ public EProjectGraph( final GraphWorkspace session, final ProjectVersionRef ref this.project = ref; } - public EProjectGraph( final GraphWorkspace session, final ProjectRelationshipFilter filter, final GraphMutator mutator, - final ProjectVersionRef ref ) + public EProjectGraph( final GraphWorkspace session, final ProjectRelationshipFilter filter, + final GraphMutator mutator, final ProjectVersionRef ref ) { this.view = new GraphView( session, filter, mutator, ref ); this.project = ref; @@ -142,8 +142,9 @@ public > Set addAll( final Collection rel final Set result = new HashSet( rels ); - final Set> rejected = view.getDatabase() - .addRelationships( rels.toArray( new ProjectRelationship[] {} ) ); + final Set> rejected = + view.getDatabase() + .addRelationships( rels.toArray( new ProjectRelationship[] {} ) ); result.removeAll( rejected ); if ( !result.isEmpty() ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectWeb.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectWeb.java index 0633d876..37c3f0b8 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectWeb.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectWeb.java @@ -36,8 +36,8 @@ public class EProjectWeb private final GraphView view; - public EProjectWeb( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, final GraphMutator mutator, - final ProjectVersionRef... refs ) + public EProjectWeb( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, + final GraphMutator mutator, final ProjectVersionRef... refs ) { this.view = new GraphView( workspace, filter, mutator, refs ); } @@ -135,8 +135,9 @@ public > Set addAll( final Collection rel final Set result = new HashSet( rels ); - final Set> rejected = view.getDatabase() - .addRelationships( rels.toArray( new ProjectRelationship[] {} ) ); + final Set> rejected = + view.getDatabase() + .addRelationships( rels.toArray( new ProjectRelationship[] {} ) ); result.removeAll( rejected ); if ( !result.isEmpty() ) @@ -261,8 +262,9 @@ public Set getCycles() @Override public Set> getRelationshipsTargeting( final ProjectVersionRef ref ) { - final Collection> rels = view.getDatabase() - .getRelationshipsTargeting( view, ref.asProjectVersionRef() ); + final Collection> rels = + view.getDatabase() + .getRelationshipsTargeting( view, ref.asProjectVersionRef() ); if ( rels == null ) { return Collections.emptySet(); @@ -360,7 +362,8 @@ public GraphView getView() public EProjectNet filteredInstance( final ProjectRelationshipFilter filter ) throws GraphDriverException { - return new EProjectWeb( view.getWorkspace(), filter, view.getMutator(), getRoots().toArray( new ProjectVersionRef[] {} ) ); + return new EProjectWeb( view.getWorkspace(), filter, view.getMutator(), + getRoots().toArray( new ProjectVersionRef[] {} ) ); } @Override diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPathInfo.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPathInfo.java index 227afc6e..182f84cf 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPathInfo.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPathInfo.java @@ -133,7 +133,8 @@ else if ( !mutator.equals( other.mutator ) ) public String getKey() { - return ( filter == null ? "none" : filter.getCondensedId() ) + "/" + ( mutator == null ? "none" : mutator.getCondensedId() ); + return ( filter == null ? "none" : filter.getCondensedId() ) + "/" + + ( mutator == null ? "none" : mutator.getCondensedId() ); } public void reattach( final GraphView view ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphView.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphView.java index ec05c167..95cc5219 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphView.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphView.java @@ -69,14 +69,14 @@ public class GraphView private transient String shortId; - public GraphView( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, final GraphMutator mutator, - final Collection roots ) + public GraphView( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, + final GraphMutator mutator, final Collection roots ) { this( workspace, filter, mutator, null, roots ); } - public GraphView( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, final GraphMutator mutator, - final ProjectVersionRef... roots ) + public GraphView( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, + final GraphMutator mutator, final ProjectVersionRef... roots ) { this( workspace, filter, mutator, null, roots ); } @@ -91,8 +91,9 @@ public GraphView( final GraphWorkspace workspace, final ProjectVersionRef... roo this( workspace, null, null, null, roots ); } - public GraphView( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, final GraphMutator mutator, - final Map selections, final Collection roots ) + public GraphView( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, + final GraphMutator mutator, final Map selections, + final Collection roots ) { this.filter = filter; this.selections = selections; @@ -102,8 +103,9 @@ public GraphView( final GraphWorkspace workspace, final ProjectRelationshipFilte workspace.registerView( this ); } - public GraphView( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, final GraphMutator mutator, - final Map selections, final ProjectVersionRef... roots ) + public GraphView( final GraphWorkspace workspace, final ProjectRelationshipFilter filter, + final GraphMutator mutator, final Map selections, + final ProjectVersionRef... roots ) { this.filter = filter; this.selections = selections; @@ -113,12 +115,14 @@ public GraphView( final GraphWorkspace workspace, final ProjectRelationshipFilte workspace.registerView( this ); } - public GraphView( final GraphWorkspace workspace, final Map selections, final Collection roots ) + public GraphView( final GraphWorkspace workspace, final Map selections, + final Collection roots ) { this( workspace, null, null, selections, roots ); } - public GraphView( final GraphWorkspace workspace, final Map selections, final ProjectVersionRef... roots ) + public GraphView( final GraphWorkspace workspace, final Map selections, + final ProjectVersionRef... roots ) { this( workspace, null, null, selections, roots ); } @@ -389,7 +393,8 @@ public GraphWorkspace addListener( final GraphWorkspaceListener listener ) public boolean hasSelection( final ProjectVersionRef ref ) { - return selections == null ? false : selections.containsKey( ref ) || selections.containsKey( ref.asProjectRef() ); + return selections == null ? false : selections.containsKey( ref ) + || selections.containsKey( ref.asProjectRef() ); } public String renderSelections() diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java index 89fb46c0..43676021 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java @@ -24,7 +24,8 @@ public class ManagedDependencyMutator private static final long serialVersionUID = 1L; @Override - public ProjectRelationship selectFor( final ProjectRelationship rel, final GraphPath path, final GraphView view ) + public ProjectRelationship selectFor( final ProjectRelationship rel, final GraphPath path, + final GraphView view ) { if ( rel.getType() != RelationshipType.DEPENDENCY ) { @@ -35,8 +36,9 @@ public ProjectRelationship selectFor( final ProjectRelationship rel, final ProjectRelationship mutated = super.selectFor( rel, path, view ); if ( mutated == null || mutated == rel ) { - final ProjectVersionRef managed = view.getDatabase() - .getManagedTargetFor( rel.getTarget(), path, RelationshipType.DEPENDENCY ); + final ProjectVersionRef managed = + view.getDatabase() + .getManagedTargetFor( rel.getTarget(), path, RelationshipType.DEPENDENCY ); if ( managed != null ) { mutated = rel.selectTarget( managed ); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java index 31279ba4..9ee2c794 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java @@ -27,7 +27,8 @@ private NoOpGraphMutator() } @Override - public ProjectRelationship selectFor( final ProjectRelationship rel, final GraphPath path, final GraphView view ) + public ProjectRelationship selectFor( final ProjectRelationship rel, final GraphPath path, + final GraphView view ) { return rel; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java index 15102736..429eb3d9 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java @@ -28,7 +28,8 @@ public class VersionManagerMutator private transient String shortId; @Override - public ProjectRelationship selectFor( final ProjectRelationship rel, final GraphPath path, final GraphView view ) + public ProjectRelationship selectFor( final ProjectRelationship rel, final GraphPath path, + final GraphView view ) { final ProjectRef target = rel.getTarget() .asProjectRef(); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java index 05e2c78d..6c30f730 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java @@ -27,7 +27,8 @@ public class BomRelationship private static final long serialVersionUID = 1L; - public BomRelationship( final Set sources, final ProjectVersionRef d, final ProjectVersionRef t, final int index ) + public BomRelationship( final Set sources, final ProjectVersionRef d, final ProjectVersionRef t, + final int index ) { // BOMs are actually marked as concrete...somewhat counter-intuitive, // but they're structural, so managed isn't quite correct (despite diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java index e2004091..839c99e8 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java @@ -34,32 +34,37 @@ public final class DependencyRelationship private final Set excludes; - public DependencyRelationship( final URI source, final ProjectVersionRef declaring, final ArtifactRef target, final DependencyScope scope, - final int index, final boolean managed, final ProjectRef... excludes ) + public DependencyRelationship( final URI source, final ProjectVersionRef declaring, final ArtifactRef target, + final DependencyScope scope, final int index, final boolean managed, + final ProjectRef... excludes ) { super( source, RelationshipType.DEPENDENCY, declaring, target, index, managed ); this.scope = scope == null ? DependencyScope.compile : scope; this.excludes = new HashSet( Arrays.asList( excludes ) ); } - public DependencyRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, final ArtifactRef target, - final DependencyScope scope, final int index, final boolean managed, final ProjectRef... excludes ) + public DependencyRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, + final ArtifactRef target, final DependencyScope scope, final int index, + final boolean managed, final ProjectRef... excludes ) { super( source, pomLocation, RelationshipType.DEPENDENCY, declaring, target, index, managed ); this.scope = scope == null ? DependencyScope.compile : scope; this.excludes = new HashSet( Arrays.asList( excludes ) ); } - public DependencyRelationship( final Collection sources, final ProjectVersionRef declaring, final ArtifactRef target, - final DependencyScope scope, final int index, final boolean managed, final ProjectRef... excludes ) + public DependencyRelationship( final Collection sources, final ProjectVersionRef declaring, + final ArtifactRef target, final DependencyScope scope, final int index, + final boolean managed, final ProjectRef... excludes ) { super( sources, RelationshipType.DEPENDENCY, declaring, target, index, managed ); this.scope = scope == null ? DependencyScope.compile : scope; this.excludes = new HashSet( Arrays.asList( excludes ) ); } - public DependencyRelationship( final Collection sources, final URI pomLocation, final ProjectVersionRef declaring, final ArtifactRef target, - final DependencyScope scope, final int index, final boolean managed, final ProjectRef... excludes ) + public DependencyRelationship( final Collection sources, final URI pomLocation, + final ProjectVersionRef declaring, final ArtifactRef target, + final DependencyScope scope, final int index, final boolean managed, + final ProjectRef... excludes ) { super( sources, pomLocation, RelationshipType.DEPENDENCY, declaring, target, index, managed ); this.scope = scope == null ? DependencyScope.compile : scope; @@ -74,7 +79,8 @@ public final DependencyScope getScope() @Override public synchronized ProjectRelationship cloneFor( final ProjectVersionRef projectRef ) { - return new DependencyRelationship( getSources(), getPomLocation(), projectRef, getTarget(), scope, getIndex(), isManaged() ); + return new DependencyRelationship( getSources(), getPomLocation(), projectRef, getTarget(), scope, getIndex(), + isManaged() ); } @Override @@ -112,8 +118,8 @@ public boolean equals( final Object obj ) @Override public String toString() { - return String.format( "DependencyRelationship [%s => %s (managed=%s, scope=%s, index=%s)]", getDeclaring(), getTarget(), isManaged(), scope, - getIndex() ); + return String.format( "DependencyRelationship [%s => %s (managed=%s, scope=%s, index=%s)]", getDeclaring(), + getTarget(), isManaged(), scope, getIndex() ); } @Override @@ -174,7 +180,9 @@ public ProjectRelationship selectTarget( final ProjectVersionRef re { final ProjectVersionRef d = getDeclaring(); ArtifactRef t = getTarget(); - t = (ArtifactRef) ( ( ref instanceof ArtifactRef ) ? ref : new ArtifactRef( ref, t.getType(), t.getClassifier(), t.isOptional() ) ); + t = + (ArtifactRef) ( ( ref instanceof ArtifactRef ) ? ref : new ArtifactRef( ref, t.getType(), + t.getClassifier(), t.isOptional() ) ); return new DependencyRelationship( getSources(), getPomLocation(), d, t, getScope(), getIndex(), isManaged(), getExcludes().toArray( new ProjectRef[] {} ) ); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java index 8d79dc1e..f9af24e3 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java @@ -25,12 +25,14 @@ public final class ExtensionRelationship private static final long serialVersionUID = 1L; - public ExtensionRelationship( final URI source, final ProjectVersionRef declaring, final ProjectVersionRef target, final int index ) + public ExtensionRelationship( final URI source, final ProjectVersionRef declaring, final ProjectVersionRef target, + final int index ) { super( source, RelationshipType.EXTENSION, declaring, target, index ); } - public ExtensionRelationship( final Collection sources, final ProjectVersionRef declaring, final ProjectVersionRef target, final int index ) + public ExtensionRelationship( final Collection sources, final ProjectVersionRef declaring, + final ProjectVersionRef target, final int index ) { super( sources, RelationshipType.EXTENSION, declaring, target, index ); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java index ec232a60..851e18c6 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java @@ -38,7 +38,8 @@ public ParentRelationship( final URI source, final ProjectVersionRef declaring, super( source, RelationshipType.PARENT, declaring, target, 0 ); } - public ParentRelationship( final Collection sources, final ProjectVersionRef declaring, final ProjectVersionRef target ) + public ParentRelationship( final Collection sources, final ProjectVersionRef declaring, + final ProjectVersionRef target ) { super( sources, RelationshipType.PARENT, declaring, target, 0 ); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java index b5ffd528..d4947d21 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java @@ -28,22 +28,24 @@ public final class PluginDependencyRelationship private final ProjectRef plugin; - public PluginDependencyRelationship( final URI source, final ProjectVersionRef declaring, final ProjectRef plugin, final ArtifactRef target, - final int index, final boolean managed ) + public PluginDependencyRelationship( final URI source, final ProjectVersionRef declaring, final ProjectRef plugin, + final ArtifactRef target, final int index, final boolean managed ) { super( source, RelationshipType.PLUGIN_DEP, declaring, target, index, managed ); this.plugin = plugin; } - public PluginDependencyRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, final ProjectRef plugin, - final ArtifactRef target, final int index, final boolean managed ) + public PluginDependencyRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, + final ProjectRef plugin, final ArtifactRef target, final int index, + final boolean managed ) { super( source, pomLocation, RelationshipType.PLUGIN_DEP, declaring, target, index, managed ); this.plugin = plugin; } - public PluginDependencyRelationship( final Collection sources, final URI pomLocation, final ProjectVersionRef declaring, - final ProjectRef plugin, final ArtifactRef target, final int index, final boolean managed ) + public PluginDependencyRelationship( final Collection sources, final URI pomLocation, + final ProjectVersionRef declaring, final ProjectRef plugin, + final ArtifactRef target, final int index, final boolean managed ) { super( sources, pomLocation, RelationshipType.PLUGIN_DEP, declaring, target, index, managed ); this.plugin = plugin; @@ -57,7 +59,8 @@ public final ProjectRef getPlugin() @Override public synchronized ProjectRelationship cloneFor( final ProjectVersionRef projectRef ) { - return new PluginDependencyRelationship( getSources(), getPomLocation(), projectRef, plugin, getTarget(), getIndex(), isManaged() ); + return new PluginDependencyRelationship( getSources(), getPomLocation(), projectRef, plugin, getTarget(), + getIndex(), isManaged() ); } @Override @@ -107,8 +110,8 @@ else if ( !plugin.equals( other.plugin ) ) @Override public String toString() { - return String.format( "PluginDependencyRelationship [%s -> (%s) => %s (managed=%s, index=%s)]", getDeclaring(), plugin, getTarget(), - isManaged(), getIndex() ); + return String.format( "PluginDependencyRelationship [%s -> (%s) => %s (managed=%s, index=%s)]", getDeclaring(), + plugin, getTarget(), isManaged(), getIndex() ); } @Override @@ -129,7 +132,8 @@ public ProjectRelationship selectDeclaring( final SingleVersion ver final ProjectVersionRef d = getDeclaring().selectVersion( version, force ); final ArtifactRef t = getTarget(); - return new PluginDependencyRelationship( getSources(), getPomLocation(), d, getPlugin(), t, getIndex(), isManaged() ); + return new PluginDependencyRelationship( getSources(), getPomLocation(), d, getPlugin(), t, getIndex(), + isManaged() ); } @Override @@ -145,7 +149,8 @@ public ProjectRelationship selectTarget( final SingleVersion versio ArtifactRef t = getTarget(); t = new ArtifactRef( t.selectVersion( version, force ), t.getType(), t.getClassifier(), t.isOptional() ); - return new PluginDependencyRelationship( getSources(), getPomLocation(), d, getPlugin(), t, getIndex(), isManaged() ); + return new PluginDependencyRelationship( getSources(), getPomLocation(), d, getPlugin(), t, getIndex(), + isManaged() ); } @Override @@ -153,7 +158,8 @@ public ProjectRelationship selectDeclaring( final ProjectVersionRef { final ArtifactRef t = getTarget(); - return new PluginDependencyRelationship( getSources(), getPomLocation(), ref, getPlugin(), t, getIndex(), isManaged() ); + return new PluginDependencyRelationship( getSources(), getPomLocation(), ref, getPlugin(), t, getIndex(), + isManaged() ); } @Override @@ -161,9 +167,12 @@ public ProjectRelationship selectTarget( final ProjectVersionRef re { final ProjectVersionRef d = getDeclaring(); ArtifactRef t = getTarget(); - t = (ArtifactRef) ( ( ref instanceof ArtifactRef ) ? ref : new ArtifactRef( ref, t.getType(), t.getClassifier(), t.isOptional() ) ); + t = + (ArtifactRef) ( ( ref instanceof ArtifactRef ) ? ref : new ArtifactRef( ref, t.getType(), + t.getClassifier(), t.isOptional() ) ); - return new PluginDependencyRelationship( getSources(), getPomLocation(), d, getPlugin(), t, getIndex(), isManaged() ); + return new PluginDependencyRelationship( getSources(), getPomLocation(), d, getPlugin(), t, getIndex(), + isManaged() ); } } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java index 9a86a7dd..0161b029 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java @@ -27,34 +27,36 @@ public final class PluginRelationship private final boolean reporting; - public PluginRelationship( final URI source, final ProjectVersionRef declaring, final ProjectVersionRef target, final int index, - final boolean managed ) + public PluginRelationship( final URI source, final ProjectVersionRef declaring, final ProjectVersionRef target, + final int index, final boolean managed ) { this( source, declaring, target, index, managed, false ); } - public PluginRelationship( final URI source, final ProjectVersionRef declaring, final ProjectVersionRef target, final int index, - final boolean managed, final boolean reporting ) + public PluginRelationship( final URI source, final ProjectVersionRef declaring, final ProjectVersionRef target, + final int index, final boolean managed, final boolean reporting ) { super( source, RelationshipType.PLUGIN, declaring, target, index, managed ); this.reporting = reporting; } - public PluginRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, final ProjectVersionRef target, - final int index, final boolean managed ) + public PluginRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, + final ProjectVersionRef target, final int index, final boolean managed ) { this( source, pomLocation, declaring, target, index, managed, false ); } - public PluginRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, final ProjectVersionRef target, - final int index, final boolean managed, final boolean reporting ) + public PluginRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, + final ProjectVersionRef target, final int index, final boolean managed, + final boolean reporting ) { super( source, pomLocation, RelationshipType.PLUGIN, declaring, target, index, managed ); this.reporting = reporting; } public PluginRelationship( final Collection sources, final URI pomLocation, final ProjectVersionRef declaring, - final ProjectVersionRef target, final int index, final boolean managed, final boolean reporting ) + final ProjectVersionRef target, final int index, final boolean managed, + final boolean reporting ) { super( sources, pomLocation, RelationshipType.PLUGIN, declaring, target, index, managed ); this.reporting = reporting; @@ -68,7 +70,8 @@ public final boolean isReporting() @Override public synchronized ProjectRelationship cloneFor( final ProjectVersionRef projectRef ) { - return new PluginRelationship( getSources(), getPomLocation(), projectRef, getTarget(), getIndex(), isManaged(), reporting ); + return new PluginRelationship( getSources(), getPomLocation(), projectRef, getTarget(), getIndex(), + isManaged(), reporting ); } @Override @@ -106,7 +109,8 @@ public boolean equals( final Object obj ) @Override public String toString() { - return String.format( "PluginRelationship [%s => %s (managed=%s, index=%s)]", getDeclaring(), getTarget(), isManaged(), getIndex() ); + return String.format( "PluginRelationship [%s => %s (managed=%s, index=%s)]", getDeclaring(), getTarget(), + isManaged(), getIndex() ); } @Override diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipType.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipType.java index e4761d17..a4cdc1c4 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipType.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipType.java @@ -18,8 +18,9 @@ public enum RelationshipType { - PARENT( "parent" ), BOM( "bom" ), DEPENDENCY( "dependency", "dep" ), PLUGIN( "plugin" ), PLUGIN_DEP( "plugin-dependency", "plugin-dep", - "plugin-level-dependency", "plugin-level-dep" ), EXTENSION( "extension", "ext" ); + PARENT( "parent" ), BOM( "bom" ), DEPENDENCY( "dependency", "dep" ), PLUGIN( "plugin" ), PLUGIN_DEP( + "plugin-dependency", "plugin-dep", "plugin-level-dependency", "plugin-level-dep" ), EXTENSION( "extension", + "ext" ); private final Set names; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/GraphDatabaseDriver.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/GraphDatabaseDriver.java index d2324a55..ede3be03 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/GraphDatabaseDriver.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/GraphDatabaseDriver.java @@ -120,21 +120,23 @@ void traverse( GraphView view, ProjectNetTraversal traversal, EProjectNet net, P * @deprecated Use {@link #getDirectRelationshipsFrom(GraphView,ProjectVersionRef,boolean,boolean,RelationshipType...)} instead */ @Deprecated - Set> getDirectRelationshipsFrom( GraphView eProjectNetView, ProjectVersionRef from, boolean includeManagedInfo, - RelationshipType... types ); + Set> getDirectRelationshipsFrom( GraphView eProjectNetView, ProjectVersionRef from, + boolean includeManagedInfo, RelationshipType... types ); /** * @deprecated Use {@link #getDirectRelationshipsTo(GraphView,ProjectVersionRef,boolean,boolean,RelationshipType...)} instead */ @Deprecated - Set> getDirectRelationshipsTo( GraphView eProjectNetView, ProjectVersionRef to, boolean includeManagedInfo, - RelationshipType... types ); + Set> getDirectRelationshipsTo( GraphView eProjectNetView, ProjectVersionRef to, + boolean includeManagedInfo, RelationshipType... types ); - Set> getDirectRelationshipsFrom( GraphView eProjectNetView, ProjectVersionRef from, boolean includeManagedInfo, - boolean includeConcreteInfo, RelationshipType... types ); + Set> getDirectRelationshipsFrom( GraphView eProjectNetView, ProjectVersionRef from, + boolean includeManagedInfo, boolean includeConcreteInfo, + RelationshipType... types ); - Set> getDirectRelationshipsTo( GraphView eProjectNetView, ProjectVersionRef to, boolean includeManagedInfo, - boolean includeConcreteInfo, RelationshipType... types ); + Set> getDirectRelationshipsTo( GraphView eProjectNetView, ProjectVersionRef to, + boolean includeManagedInfo, boolean includeConcreteInfo, + RelationshipType... types ); Set getProjectsMatching( GraphView eProjectNetView, ProjectRef projectRef ); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractFilteringTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractFilteringTraversal.java index 7f94d2ff..8842b7ea 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractFilteringTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractFilteringTraversal.java @@ -39,15 +39,18 @@ protected AbstractFilteringTraversal( final ProjectRelationshipFilter filter, fi rootFilter = filter; } - protected AbstractFilteringTraversal( final ProjectRelationshipFilter filter, final int passes, final TraversalType... types ) + protected AbstractFilteringTraversal( final ProjectRelationshipFilter filter, final int passes, + final TraversalType... types ) { super( passes, types ); rootFilter = filter; } - protected abstract boolean shouldTraverseEdge( ProjectRelationship relationship, List> path, int pass ); + protected abstract boolean shouldTraverseEdge( ProjectRelationship relationship, + List> path, int pass ); - protected void edgeTraversalFinished( final ProjectRelationship relationship, final List> path, final int pass ) + protected void edgeTraversalFinished( final ProjectRelationship relationship, + final List> path, final int pass ) { } @@ -57,13 +60,15 @@ public final ProjectRelationshipFilter getRootFilter() } @Override - public final void edgeTraversed( final ProjectRelationship relationship, final List> path, final int pass ) + public final void edgeTraversed( final ProjectRelationship relationship, + final List> path, final int pass ) { edgeTraversalFinished( relationship, path, pass ); } @Override - public final boolean traverseEdge( final ProjectRelationship relationship, final List> path, final int pass ) + public final boolean traverseEdge( final ProjectRelationship relationship, + final List> path, final int pass ) { if ( !preCheck( relationship, path, pass ) ) { @@ -78,7 +83,8 @@ public final boolean traverseEdge( final ProjectRelationship relationship, fi } @Override - public boolean preCheck( final ProjectRelationship relationship, final List> path, final int pass ) + public boolean preCheck( final ProjectRelationship relationship, final List> path, + final int pass ) { boolean result = true; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java index 448818e8..7301d5bd 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java @@ -51,7 +51,8 @@ public BuildOrder getBuildOrder() } @Override - protected boolean shouldTraverseEdge( final ProjectRelationship relationship, final List> path, final int pass ) + protected boolean shouldTraverseEdge( final ProjectRelationship relationship, + final List> path, final int pass ) { final ProjectVersionRef decl = relationship.getDeclaring(); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java index 27fecd3f..1fb139bf 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java @@ -35,7 +35,8 @@ public class TransitiveDependencyTraversal private final Logger logger = LoggerFactory.getLogger( getClass() ); - private final Map artifacts = new HashMap(); + private final Map artifacts = + new HashMap(); private final Map seenArtifacts = new HashMap(); @@ -66,7 +67,8 @@ public List getArtifacts() } @Override - public boolean shouldTraverseEdge( final ProjectRelationship relationship, final List> path, final int pass ) + public boolean shouldTraverseEdge( final ProjectRelationship relationship, + final List> path, final int pass ) { boolean result = false; if ( relationship instanceof DependencyRelationship ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java index 64c1e4cd..2795047b 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java @@ -87,7 +87,8 @@ public void printStructure( final ProjectVersionRef from, } } - private void printLinks( final ProjectVersionRef from, final Set lines, final Map>> links, + private void printLinks( final ProjectVersionRef from, final Set lines, + final Map>> links, final Map> labels, final Set excluded, final Stack inPath ) { @@ -119,7 +120,6 @@ private void printLinks( final ProjectVersionRef from, final Set lines, // return; // } - relationshipPrinter.print( out, null, new PrintWriter( sw ), labels, 0, "" ); lines.add( sw.toString() ); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructurePrintingTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructurePrintingTraversal.java index bfd5a4f1..f23f6149 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructurePrintingTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructurePrintingTraversal.java @@ -41,7 +41,8 @@ public class StructurePrintingTraversal private final StructureRelationshipPrinter relationshipPrinter; - private final Map>> outboundLinks = new HashMap>>(); + private final Map>> outboundLinks = + new HashMap>>(); public StructurePrintingTraversal() { @@ -61,14 +62,16 @@ public StructurePrintingTraversal( final StructureRelationshipPrinter relationsh this.relationshipPrinter = relationshipPrinter; } - public StructurePrintingTraversal( final ProjectNetTraversal traversal, final StructureRelationshipPrinter relationshipPrinter ) + public StructurePrintingTraversal( final ProjectNetTraversal traversal, + final StructureRelationshipPrinter relationshipPrinter ) { this.traversal = traversal; this.relationshipPrinter = relationshipPrinter; } @Override - public boolean traverseEdge( final ProjectRelationship relationship, final List> path, final int pass ) + public boolean traverseEdge( final ProjectRelationship relationship, final List> path, + final int pass ) { if ( traversal == null || traversal.traverseEdge( relationship, path, pass ) ) { @@ -134,7 +137,7 @@ private void printLinks( final ProjectVersionRef from, final PrintWriter writer, for ( final ProjectRelationship out : outbound ) { final ProjectVersionRef outRef = out.getTarget() - .asProjectVersionRef(); + .asProjectVersionRef(); if ( inPath.contains( outRef ) ) { continue; @@ -184,7 +187,8 @@ private void printLinks( final ProjectVersionRef from, final PrintWriter writer, } @Override - public boolean preCheck( final ProjectRelationship relationship, final List> path, final int pass ) + public boolean preCheck( final ProjectRelationship relationship, final List> path, + final int pass ) { return traversal == null || traversal.preCheck( relationship, path, pass ); } @@ -210,7 +214,8 @@ public void endTraverse( final int pass, final EProjectNet network ) } @Override - public void edgeTraversed( final ProjectRelationship relationship, final List> path, final int pass ) + public void edgeTraversed( final ProjectRelationship relationship, final List> path, + final int pass ) { if ( traversal != null ) { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TargetRefPrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TargetRefPrinter.java index ae5ec198..eab73aaa 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TargetRefPrinter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TargetRefPrinter.java @@ -24,8 +24,8 @@ public final class TargetRefPrinter @Override public void print( final ProjectRelationship relationship, final ProjectVersionRef selectedTarget, - final PrintWriter writer, - final Map> labels, final int depth, final String indent ) + final PrintWriter writer, final Map> labels, final int depth, + final String indent ) { for ( int i = 0; i < depth; i++ ) { @@ -48,8 +48,8 @@ public void print( final ProjectRelationship relationship, final ProjectVersi @Override public void printProjectVersionRef( final ProjectVersionRef target, final PrintWriter writer, - final String targetSuffix, - final Map> labels, final Set localLabels ) + final String targetSuffix, final Map> labels, + final Set localLabels ) { writer.print( target ); if ( targetSuffix != null ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java index 7917165d..330f8065 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java @@ -58,23 +58,22 @@ public TreePrinter( final StructureRelationshipPrinter relationshipPrinter ) // } public void printStructure( final ProjectVersionRef from, - final Map>> links, + final Map>> links, final Map> labels, PrintWriter writer ) { printStructure( from, links, null, null, " ", labels, writer ); } public void printStructure( final ProjectVersionRef from, - final Map>> links, - final String indent, + final Map>> links, final String indent, final Map> labels, PrintWriter writer ) { printStructure( from, links, null, null, indent, labels, writer ); } public void printStructure( final ProjectVersionRef from, - final Map>> links, - final String header, final String footer, final String indent, + final Map>> links, final String header, + final String footer, final String indent, final Map> labels, PrintWriter writer ) { if ( header != null ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java index b9b99b58..a9d30e67 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java @@ -113,8 +113,10 @@ public static boolean isExcluded( final ProjectRef ref, final Collection>> mapByDeclaring( final Collection> relationships ) { final Logger logger = LoggerFactory.getLogger( RelationshipUtils.class ); - logger.debug( "Mapping {} relationships by declaring GAV:\n\n {}\n\n", relationships.size(), new JoinString( "\n ", relationships ) ); - final Map>> result = new HashMap>>(); + logger.debug( "Mapping {} relationships by declaring GAV:\n\n {}\n\n", relationships.size(), + new JoinString( "\n ", relationships ) ); + final Map>> result = + new HashMap>>(); for ( final ProjectRelationship rel : relationships ) { final ProjectVersionRef declaring = rel.getDeclaring(); @@ -267,208 +269,256 @@ public static Set gavs( final Collection getRelationshipTypes( final ProjectRelationshipFilter filter ) @@ -488,7 +538,8 @@ public static Set getRelationshipTypes( final ProjectRelations } else if ( filter instanceof AbstractAggregatingFilter ) { - final List filters = ( (AbstractAggregatingFilter) filter ).getFilters(); + final List filters = + ( (AbstractAggregatingFilter) filter ).getFilters(); for ( final ProjectRelationshipFilter f : filters ) { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/workspace/GraphWorkspaceConfiguration.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/workspace/GraphWorkspaceConfiguration.java index 8a6e3678..17b8c55d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/workspace/GraphWorkspaceConfiguration.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/workspace/GraphWorkspaceConfiguration.java @@ -183,7 +183,8 @@ public int getActiveSourceCount() @Override public String toString() { - return String.format( "GraphWorkspaceConfiguration [activePomLocations=%s, activeSources=%s]", activePomLocations, activeSources ); + return String.format( "GraphWorkspaceConfiguration [activePomLocations=%s, activeSources=%s]", + activePomLocations, activeSources ); } public void setLastAccess( final long lastAccess ) diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java index 275bf67f..3e03f8b2 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java @@ -53,14 +53,15 @@ protected abstract EGraphManager getManager() public void printStart() { start = System.currentTimeMillis(); - System.out.printf( "***START [%s#%s] (%s)\n\n", naming.getClass(), naming.getMethodName(), new Date().toString() ); + System.out.printf( "***START [%s#%s] (%s)\n\n", naming.getClass(), naming.getMethodName(), + new Date().toString() ); } @After public void printEnd() { - System.out.printf( "\n\n***END [%s#%s] - %sms (%s)\n", naming.getClass(), naming.getMethodName(), ( System.currentTimeMillis() - start ), - new Date().toString() ); + System.out.printf( "\n\n***END [%s#%s] - %sms (%s)\n", naming.getClass(), naming.getMethodName(), + ( System.currentTimeMillis() - start ), new Date().toString() ); } } diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/SubGraphSelectionTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/SubGraphSelectionTCK.java index 436b9ec3..ea0d63d9 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/SubGraphSelectionTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/SubGraphSelectionTCK.java @@ -55,17 +55,21 @@ public void selectVersionForVariableSubgraph() /* @formatter:on */ Set variables = graph.getVariableSubgraphs(); - System.out.println( "Before selection in view: " + view.getShortId() + ", here are the variable nodes: " + variables ); + System.out.println( "Before selection in view: " + view.getShortId() + ", here are the variable nodes: " + + variables ); assertThat( variables.contains( varDep ), equalTo( true ) ); - view = new GraphView( ws, AnyFilter.INSTANCE, view.getMutator(), Collections.singletonMap( varDep.asProjectRef(), selected ), project ); + view = + new GraphView( ws, AnyFilter.INSTANCE, view.getMutator(), Collections.singletonMap( varDep.asProjectRef(), + selected ), project ); graph = getManager().getGraph( view ); // final ProjectVersionRef selDep = view.selectVersion( varDep.asProjectRef(), selected ); // assertThat( selDep.asProjectRef(), equalTo( varDep.asProjectRef() ) ); variables = graph.getVariableSubgraphs(); - System.out.println( "After selection in view: " + view.getShortId() + ", here are the variable nodes: " + variables ); + System.out.println( "After selection in view: " + view.getShortId() + ", here are the variable nodes: " + + variables ); assertThat( variables.isEmpty(), equalTo( true ) ); final Set incomplete = graph.getIncompleteSubgraphs(); @@ -98,7 +102,9 @@ public void selectThenClearVersionForVariableSubgraph() System.out.println( "Variable before selecting:\n " + variables ); assertThat( variables.contains( varDep ), equalTo( true ) ); - view = new GraphView( ws, AnyFilter.INSTANCE, view.getMutator(), Collections.singletonMap( varDep.asProjectRef(), selected ), project ); + view = + new GraphView( ws, AnyFilter.INSTANCE, view.getMutator(), Collections.singletonMap( varDep.asProjectRef(), + selected ), project ); graph = getManager().getGraph( view ); // final ProjectVersionRef selDep = view.selectVersion( varDep.asProjectRef(), selected ); @@ -159,7 +165,9 @@ public void selectVersionForVariableSubgraph_SelectionsContextualToView() // Select a concrete version for the session associated with the FIRST graph. // Second graph session should remain unchanged. - view = new GraphView( session, AnyFilter.INSTANCE, view.getMutator(), Collections.singletonMap( varDep.asProjectRef(), selected ), project ); + view = + new GraphView( session, AnyFilter.INSTANCE, view.getMutator(), + Collections.singletonMap( varDep.asProjectRef(), selected ), project ); graph = getManager().getGraph( view ); assertThat( view.getSelection( varDep ), equalTo( selected ) ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java index b1740528..160aa76d 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java @@ -50,7 +50,8 @@ public void simpleDependencyBuildOrder() final ProjectVersionRef b = new ProjectVersionRef( "group.id", "b", "2" ); final ProjectVersionRef a = new ProjectVersionRef( "group.id", "a", "1" ); - final Map relativeOrder = new HashMap(); + final Map relativeOrder = + new HashMap(); relativeOrder.put( c, b ); relativeOrder.put( b, a ); @@ -89,7 +90,8 @@ public void simpleDependencyBuildOrder_includeDepParent() final ProjectVersionRef a = new ProjectVersionRef( "group.id", "a", "1" ); final ProjectVersionRef p = new ProjectVersionRef( "group.id", "b-parent", "1001" ); - final Map relativeOrder = new HashMap(); + final Map relativeOrder = + new HashMap(); relativeOrder.put( c, b ); relativeOrder.put( b, a ); relativeOrder.put( b, p ); @@ -139,7 +141,8 @@ public void simpleDependencyBuildOrder_IgnorePluginPath() final ProjectVersionRef pa = new ProjectVersionRef( "plugin.id", "p-a", "1" ); final ProjectVersionRef pb = new ProjectVersionRef( "plugin.id", "p-b", "2" ); - final Map relativeOrder = new HashMap(); + final Map relativeOrder = + new HashMap(); relativeOrder.put( c, b ); relativeOrder.put( b, a ); @@ -186,7 +189,8 @@ public void simpleDependencyBuildOrder_runtimeDepsOnly() final ProjectVersionRef pa = new ProjectVersionRef( "plugin.id", "p-a", "1" ); final ProjectVersionRef pb = new ProjectVersionRef( "plugin.id", "p-b", "2" ); - final Map relativeOrder = new HashMap(); + final Map relativeOrder = + new HashMap(); relativeOrder.put( c, b ); relativeOrder.put( b, a ); @@ -235,7 +239,8 @@ public void simpleDependencyBuildOrder_ignoreExcluded() final ProjectVersionRef b = new ProjectVersionRef( "group.id", "b", "2" ); final ProjectVersionRef a = new ProjectVersionRef( "group.id", "a", "1" ); - final Map relativeOrder = new HashMap(); + final Map relativeOrder = + new HashMap(); relativeOrder.put( c, b ); relativeOrder.put( b, a ); @@ -283,7 +288,8 @@ public void simpleEverythingBuildOrder() final ProjectVersionRef pa = new ProjectVersionRef( "plugin.dep.id", "p-a", "1" ); final ProjectVersionRef pb = new ProjectVersionRef( "plugin.id", "p-b", "2" ); - final Map relativeOrder = new HashMap(); + final Map relativeOrder = + new HashMap(); relativeOrder.put( c, b ); relativeOrder.put( b, a ); relativeOrder.put( c, pb ); @@ -322,7 +328,8 @@ public void simpleEverythingBuildOrder() assertRelativeOrder( relativeOrder, buildOrder ); } - private void assertRelativeOrder( final Map relativeOrder, final List buildOrder ) + private void assertRelativeOrder( final Map relativeOrder, + final List buildOrder ) { for ( final Map.Entry entry : relativeOrder.entrySet() ) { @@ -346,7 +353,8 @@ private void assertRelativeOrder( final Map= kidx ) { - fail( "prerequisite project: " + v + " of: " + k + " appears AFTER it in the build order: " + buildOrder ); + fail( "prerequisite project: " + v + " of: " + k + " appears AFTER it in the build order: " + + buildOrder ); } } } diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/TransitiveDependencyTraversalTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/TransitiveDependencyTraversalTCK.java index 404e60c5..2bf277d7 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/TransitiveDependencyTraversalTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/TransitiveDependencyTraversalTCK.java @@ -101,7 +101,9 @@ public void collectDependencyOfDependencyWithExternalDepManagement() )); /* @formatter:on */ - view = new GraphView( view.getWorkspace(), AnyFilter.INSTANCE, view.getMutator(), Collections.singletonMap( d2.asProjectRef(), d3 ), root ); + view = + new GraphView( view.getWorkspace(), AnyFilter.INSTANCE, view.getMutator(), + Collections.singletonMap( d2.asProjectRef(), d3 ), root ); graph = getManager().getGraph( view ); // graph.getView() From bada97970f659c0db8c6de8d00eba24fff078a85 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 27 May 2014 11:44:07 -0500 Subject: [PATCH 005/240] [maven-release-plugin] prepare release atlas-parent-0.12.0 --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 8 ++++---- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index b50fd5c7..b2e79093 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.12.0-SNAPSHOT + 0.12.0 atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 92740f59..b945b1d5 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.12.0-SNAPSHOT + 0.12.0 atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 2e20dfb8..aa5a8cfc 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.12.0-SNAPSHOT + 0.12.0 atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index 78a38b8b..08bbfa25 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.12.0-SNAPSHOT + 0.12.0 atlas-identities diff --git a/pom.xml b/pom.xml index e1c0df3f..0541c163 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.12.0-SNAPSHOT + 0.12.0 pom Atlas :: Maven Project-Graph :: Parent @@ -36,17 +36,17 @@ org.commonjava.maven.atlas atlas-identities - 0.12.0-SNAPSHOT + 0.12.0 org.commonjava.maven.atlas atlas-relationships-api - 0.12.0-SNAPSHOT + 0.12.0 org.commonjava.maven.atlas atlas-drivers-tck - 0.12.0-SNAPSHOT + 0.12.0 test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 926eac6b..b91db6d3 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.12.0-SNAPSHOT + 0.12.0 atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 0d194acf..65bb63b5 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.12.0-SNAPSHOT + 0.12.0 atlas-drivers-tck From 0da8134454899085d665ed914ea970d1a216cdf9 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 27 May 2014 11:44:12 -0500 Subject: [PATCH 006/240] [maven-release-plugin] prepare for next development iteration --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 8 ++++---- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index b2e79093..faa227ec 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.12.0 + 0.13.0-SNAPSHOT atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index b945b1d5..e69a849e 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.12.0 + 0.13.0-SNAPSHOT atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index aa5a8cfc..7eb69b85 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.12.0 + 0.13.0-SNAPSHOT atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index 08bbfa25..e9693ced 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.12.0 + 0.13.0-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index 0541c163..14cda69e 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.12.0 + 0.13.0-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -36,17 +36,17 @@ org.commonjava.maven.atlas atlas-identities - 0.12.0 + 0.13.0-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.12.0 + 0.13.0-SNAPSHOT org.commonjava.maven.atlas atlas-drivers-tck - 0.12.0 + 0.13.0-SNAPSHOT test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index b91db6d3..62e9171d 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.12.0 + 0.13.0-SNAPSHOT atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 65bb63b5..cbd284aa 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.12.0 + 0.13.0-SNAPSHOT atlas-drivers-tck From 701d1b554f29cd8fe9172239d1b2347daba29c2d Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 27 May 2014 17:22:07 -0500 Subject: [PATCH 007/240] Working on logic to count open connections / graph users, and use a timer to close the connection after the last graph closes, in order to reuse existing instances as much as possible over a narrow timeframe. --- .../spi/neo4j/FileNeo4JGraphConnection.java | 61 +++++-- .../spi/neo4j/FileNeo4jConnectionFactory.java | 16 +- .../maven/atlas/graph/RelationshipGraph.java | 4 +- .../atlas/graph/RelationshipGraphFactory.java | 168 +++++++++++++++--- 4 files changed, 209 insertions(+), 40 deletions(-) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java index c9e794be..ad956da9 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java @@ -10,6 +10,7 @@ ******************************************************************************/ package org.commonjava.maven.atlas.graph.spi.neo4j; +import static org.apache.commons.lang.StringUtils.join; import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.CONFIG_ID; import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.GA; import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.GAV; @@ -147,6 +148,8 @@ public class FileNeo4JGraphConnection /* @formatter:on */ + private boolean closed = false; + private GraphDatabaseService graph; private final boolean useShutdownHook; @@ -161,10 +164,13 @@ public class FileNeo4JGraphConnection private final FileNeo4jConnectionFactory factory; + private final File dbDir; + FileNeo4JGraphConnection( final String workspaceId, final File dbDir, final boolean useShutdownHook, final FileNeo4jConnectionFactory factory ) { this.workspaceId = workspaceId; + this.dbDir = dbDir; this.factory = factory; this.adminAccess = new GraphAdminImpl( this ); @@ -226,15 +232,24 @@ protected boolean isUseShutdownHook() @Override public void printStats() { - logger.info( "Graph contains {} nodes.", graph.index() - .forNodes( BY_GAV_IDX ) - .query( GAV, "*" ) - .size() ); + final StringBuilder stats = new StringBuilder(); + stats.append( "Graph in: " ) + .append( dbDir ); + stats.append( "\ncontains " ) + .append( graph.index() + .forNodes( BY_GAV_IDX ) + .query( GAV, "*" ) + .size() ) + .append( " nodes." ); - logger.info( "Graph contains {} relationships.", graph.index() - .forRelationships( ALL_RELATIONSHIPS ) - .query( RELATIONSHIP_ID, "*" ) - .size() ); + stats.append( "\ncontains " ) + .append( graph.index() + .forRelationships( ALL_RELATIONSHIPS ) + .query( RELATIONSHIP_ID, "*" ) + .size() ) + .append( " relationships." ); + + logger.info( stats.toString() ); } @Override @@ -263,9 +278,9 @@ public Collection> getRelationshipsDeclaredBy( return null; } - private void checkClosed() + private synchronized void checkClosed() { - if ( graph == null ) + if ( closed || graph == null ) { throw new IllegalStateException( "Graph database has been closed!" ); } @@ -1032,18 +1047,35 @@ Relationship getRelationship( final String relId ) return hits.hasNext() ? hits.next() : null; } + private static final int SHUTDOWN_WAIT = 5; + @Override public synchronized void close() throws RelationshipGraphConnectionException { + closed = true; + + factory.connectionClosing( workspaceId ); + if ( graph != null ) { try { + logger.info( "Shutting down graph via:\n {}\n\n", join( Thread.currentThread() + .getStackTrace(), "\n " ) ); + printStats(); + graph.shutdown(); - factory.connectionClosed( workspaceId ); + + logger.info( "Waiting for shutdown..." ); + if ( graph.isAvailable( 1000 * SHUTDOWN_WAIT ) ) + { + throw new RelationshipGraphConnectionException( "Failed to shutdown graph: %s.", dbDir ); + } graph = null; + + logger.info( "...graph shutdown complete." ); } catch ( final Exception e ) { @@ -2062,6 +2094,8 @@ public GraphPath createPath( final GraphPath parent, final ProjectRelation @Override public boolean registerView( final ViewParams params ) { + checkClosed(); + if ( params == null ) { return false; @@ -2435,4 +2469,9 @@ public Set> getDirectRelationshipsTo( final ViewParams pa return getDirectRelationshipsFrom( params, to, includeManagedInfo, true, types ); } + public synchronized boolean isOpen() + { + return !closed; + } + } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java index c86beaf4..dd99ee78 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java @@ -64,7 +64,7 @@ else if ( !db.mkdirs() ) } FileNeo4JGraphConnection conn = openConnections.get( workspaceId ); - if ( conn == null ) + if ( conn == null || !conn.isOpen() ) { conn = new FileNeo4JGraphConnection( workspaceId, db, useShutdownHook, this ); openConnections.put( workspaceId, conn ); @@ -111,7 +111,7 @@ public boolean delete( final String workspaceId ) } @Override - public void close() + public synchronized void close() throws RelationshipGraphConnectionException { final Logger logger = LoggerFactory.getLogger( getClass() ); @@ -130,17 +130,14 @@ public void close() } } + openConnections.clear(); + if ( !failedClose.isEmpty() ) { throw new RelationshipGraphConnectionException( "Failed to close: {}", new JoinString( ", ", failedClose ) ); } } - public synchronized void connectionClosed( final String workspaceId ) - { - openConnections.remove( workspaceId ); - } - @Override public boolean exists( final String workspaceId ) { @@ -148,4 +145,9 @@ public boolean exists( final String workspaceId ) return db.exists() && db.isDirectory(); } + public synchronized void connectionClosing( final String workspaceId ) + { + openConnections.remove( workspaceId ); + } + } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java index 9081bdf1..d169eacf 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java @@ -45,6 +45,8 @@ public final class RelationshipGraph { this.params = params; this.connection = driver; + + connection.registerView( params ); } public ViewParams getParams() @@ -511,7 +513,7 @@ public final ProjectVersionRef getSelection( final ProjectRef ref ) // +++ IMPORTED FROM EGraphManager public boolean containsGraph( final ProjectVersionRef ref ) { - return connection.containsProject( params, ref ) && !connection.isMissing( params, ref ); + return connection.containsProject( params, ref ); } public Set> findDirectRelationshipsTo( final ProjectVersionRef to, diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java index 32f83c91..14c7adc1 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java @@ -1,18 +1,27 @@ package org.commonjava.maven.atlas.graph; +import static org.apache.commons.lang.StringUtils.join; + import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; +import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public final class RelationshipGraphFactory { + private final Logger logger = LoggerFactory.getLogger( getClass() ); + private final RelationshipGraphConnectionFactory connectionManager; private final Map connectionCaches = new HashMap(); @@ -22,6 +31,8 @@ public final class RelationshipGraphFactory private boolean closed; + private final Timer timer = new Timer( true ); + public RelationshipGraphFactory( final RelationshipGraphConnectionFactory connectionFactory, final RelationshipGraphListenerFactory... listenerFactories ) { @@ -32,14 +43,14 @@ public RelationshipGraphFactory( final RelationshipGraphConnectionFactory connec } } - public RelationshipGraph open( final ViewParams params, final boolean create ) + public synchronized RelationshipGraph open( final ViewParams params, final boolean create ) throws RelationshipGraphException { checkClosed(); final String wsid = params.getWorkspaceId(); ConnectionCache cache = connectionCaches.get( wsid ); - if ( cache == null ) + if ( cache == null || !cache.isOpen() ) { if ( !create ) { @@ -49,8 +60,14 @@ public RelationshipGraph open( final ViewParams params, final boolean create ) final RelationshipGraphConnection connection = connectionManager.openConnection( params.getWorkspaceId(), create ); - cache = new ConnectionCache( connection ); + cache = new ConnectionCache( timer, connectionCaches, connection ); connectionCaches.put( wsid, cache ); + + logger.info( "Created new connection to graph db: {}", params.getWorkspaceId() ); + } + else + { + logger.info( "Reusing connection to graph db: {}", params.getWorkspaceId() ); } RelationshipGraph graph = cache.getGraph( params ); @@ -61,6 +78,10 @@ public RelationshipGraph open( final ViewParams params, final boolean create ) graph.addListener( cache ); cache.registerGraph( params, graph ); } + else + { + cache.addGraphOwner( params ); + } return graph; } @@ -93,14 +114,15 @@ private void checkClosed() } } - public void close() + public synchronized void close() throws RelationshipGraphException { closed = true; + timer.cancel(); for ( final ConnectionCache cache : connectionCaches.values() ) { - cache.close(); + cache.closeNow(); } connectionCaches.clear(); @@ -117,25 +139,115 @@ private static final class ConnectionCache extends AbstractRelationshipGraphListener implements Iterable { - private final RelationshipGraphConnection connection; + private static final long CLOSE_WAIT_TIMEOUT = 5000; + + private final Logger logger = LoggerFactory.getLogger( getClass() ); + + private RelationshipGraphConnection connection; private final Map graphs = new HashMap(); - ConnectionCache( final RelationshipGraphConnection connection ) + private final Map graphCounter = new HashMap(); + + private final Timer timer; + + private TimerTask closeTimer; + + private final Map mapOfCaches; + + ConnectionCache( final Timer timer, final Map mapOfCaches, + final RelationshipGraphConnection connection ) { + this.timer = timer; + this.mapOfCaches = mapOfCaches; this.connection = connection; } - public void close() - throws RelationshipGraphException + public synchronized void closeNow() + throws RelationshipGraphConnectionException { + mapOfCaches.remove( this ); + graphs.clear(); - connection.close(); + + final RelationshipGraphConnection conn = connection; + connection = null; + + conn.close(); + } + + public synchronized void startCloseTimer() + { + closeTimer = new TimerTask() + { + @Override + public void run() + { + if ( isEmpty() ) + { + try + { + closeNow(); + } + catch ( final RelationshipGraphConnectionException e ) + { + logger.error( "Failed to close graph connection cache: " + connection, e ); + } + } + } + }; + + logger.info( "Starting close-cache countdown for: {} ({}ms)", connection.getWorkspaceId(), + CLOSE_WAIT_TIMEOUT ); + + timer.schedule( closeTimer, CLOSE_WAIT_TIMEOUT ); + } + + public synchronized boolean isOpen() + { + return connection != null; + } + + synchronized void addGraphOwner( final ViewParams params ) + { + Integer i = graphCounter.remove( params ); + if ( i == null ) + { + i = Integer.valueOf( 1 ); + } + else + { + i = Integer.valueOf( i.intValue() + 1 ); + } + + graphCounter.put( params, i ); } RelationshipGraph getGraph( final ViewParams params ) { - return graphs.get( params ); + final RelationshipGraph graph = graphs.get( params ); + + logger.info( "Returning existing graph for: {}", params.getWorkspaceId() ); + + if ( graph != null ) + { + cancelCloseTimer(); + } + + return graph; + } + + private synchronized void cancelCloseTimer() + { + if ( closeTimer != null ) + { + logger.info( "Canceling close-cache countdown for: {} (was scheduled to run in: {}ms)", + connection.getWorkspaceId(), + ( closeTimer.scheduledExecutionTime() - System.currentTimeMillis() ) ); + + closeTimer.cancel(); + closeTimer = null; + } } RelationshipGraphConnection getConnection() @@ -143,14 +255,30 @@ RelationshipGraphConnection getConnection() return connection; } - void registerGraph( final ViewParams params, final RelationshipGraph graph ) + synchronized void registerGraph( final ViewParams params, final RelationshipGraph graph ) { + addGraphOwner( params ); + logger.info( "Registering new connection to: {}", params.getWorkspaceId() ); graphs.put( params, graph ); + cancelCloseTimer(); } - void deregisterGraph( final ViewParams params ) + synchronized void deregisterGraph( final ViewParams params ) { - graphs.remove( params ); + Integer i = graphCounter.remove( params ); + if ( i == null || i.intValue() < 2 ) + { + graphs.remove( params ); + if ( isEmpty() ) + { + startCloseTimer(); + } + } + else + { + i = Integer.valueOf( i.intValue() - 1 ); + graphCounter.put( params, i ); + } } boolean isEmpty() @@ -159,10 +287,9 @@ boolean isEmpty() } @Override - public Iterator iterator() + public synchronized Iterator iterator() { - return graphs.values() - .iterator(); + return new HashSet( graphs.values() ).iterator(); } @Override @@ -173,11 +300,10 @@ public void closed( final RelationshipGraph graph ) // same workspace... // factory.flush( cache.getConnection() ); + + logger.info( "Closing graph via:\n {}", join( Thread.currentThread() + .getStackTrace(), "\n " ) ); deregisterGraph( graph.getParams() ); - if ( isEmpty() ) - { - close(); - } } @Override From 3570bdfcfd4664d2a82a1ba1a4295c18ca9dcf43 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 27 May 2014 17:27:00 -0500 Subject: [PATCH 008/240] removing two of the more expensive debug log outputs. --- .../maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java | 4 +--- .../maven/atlas/graph/RelationshipGraphFactory.java | 4 ---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java index ad956da9..c6e29fb7 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java @@ -10,7 +10,6 @@ ******************************************************************************/ package org.commonjava.maven.atlas.graph.spi.neo4j; -import static org.apache.commons.lang.StringUtils.join; import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.CONFIG_ID; import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.GA; import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.GAV; @@ -1061,8 +1060,7 @@ public synchronized void close() { try { - logger.info( "Shutting down graph via:\n {}\n\n", join( Thread.currentThread() - .getStackTrace(), "\n " ) ); + logger.info( "Shutting down graph..." ); printStats(); graph.shutdown(); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java index 14c7adc1..b728a164 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java @@ -1,7 +1,5 @@ package org.commonjava.maven.atlas.graph; -import static org.apache.commons.lang.StringUtils.join; - import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; @@ -301,8 +299,6 @@ public void closed( final RelationshipGraph graph ) // factory.flush( cache.getConnection() ); - logger.info( "Closing graph via:\n {}", join( Thread.currentThread() - .getStackTrace(), "\n " ) ); deregisterGraph( graph.getParams() ); } From c4234cd189c123422c9eac70c92a45273b11fc0f Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 27 May 2014 23:01:02 -0500 Subject: [PATCH 009/240] Move per-graph user count out of connection cache and into RelationshipGraph proper, since the graph's own close logic happens whether the connection cache deregisters it or not...which left stale (disconnected) graph instances in the cache. --- .../maven/atlas/graph/RelationshipGraph.java | 168 ++++++++++-------- .../atlas/graph/RelationshipGraphFactory.java | 35 +--- 2 files changed, 101 insertions(+), 102 deletions(-) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java index d169eacf..1754d9ab 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java @@ -25,10 +25,14 @@ import org.commonjava.maven.atlas.graph.traverse.TraversalType; import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public final class RelationshipGraph { + private final Logger logger = LoggerFactory.getLogger( getClass() ); + private static final String GROUP_ID = "groupId"; private static final String ARTIFACT_ID = "artifactId"; @@ -41,12 +45,15 @@ public final class RelationshipGraph private RelationshipGraphConnection connection; + // if we didn't have a user, we wouldn't have constructed this thing! + private int userCounter = 1; + RelationshipGraph( final ViewParams params, final RelationshipGraphConnection driver ) { this.params = params; this.connection = driver; - connection.registerView( params ); + getConnectionInternal().registerView( params ); } public ViewParams getParams() @@ -57,7 +64,7 @@ public ViewParams getParams() public void storeProjectError( final ProjectVersionRef ref, final Throwable error ) throws RelationshipGraphException { - connection.addProjectError( ref, error ); + getConnectionInternal().addProjectError( ref, error ); for ( final RelationshipGraphListener listener : listeners ) { @@ -67,18 +74,18 @@ public void storeProjectError( final ProjectVersionRef ref, final Throwable erro public Throwable getProjectError( final ProjectVersionRef ref ) { - return connection.getProjectError( ref ); + return getConnectionInternal().getProjectError( ref ); } public boolean hasProjectError( final ProjectVersionRef ref ) { - return connection.hasProjectError( ref ); + return getConnectionInternal().hasProjectError( ref ); } public void clearProjectError( final ProjectVersionRef ref ) throws RelationshipGraphException { - connection.clearProjectError( ref ); + getConnectionInternal().clearProjectError( ref ); } public Set> storeRelationships( final ProjectRelationship... relationships ) @@ -91,7 +98,7 @@ public Set> storeRelationships( final ProjectRelationship listener.storing( this, rels ); } - final Set> rejected = connection.addRelationships( relationships ); + final Set> rejected = getConnectionInternal().addRelationships( relationships ); for ( final RelationshipGraphListener listener : listeners ) { @@ -110,7 +117,7 @@ public Set> storeRelationships( final Collection> rejected = - connection.addRelationships( relationships.toArray( new ProjectRelationship[relationships.size()] ) ); + getConnectionInternal().addRelationships( relationships.toArray( new ProjectRelationship[relationships.size()] ) ); for ( final RelationshipGraphListener listener : listeners ) { @@ -138,7 +145,12 @@ public void removeListener( final RelationshipGraphListener listener ) } } - public void close() + synchronized void incrementGraphOwnership() + { + userCounter++; + } + + public synchronized void forceClose() throws RelationshipGraphException { if ( listeners != null ) @@ -158,48 +170,47 @@ public void close() listener.closed( this ); } } + } - // try - // { - // connection.close(); - // } - // finally - // { - // if ( listeners != null ) - // { - // for ( final RelationshipGraphListener listener : listeners ) - // { - // listener.closed( this ); - // } - // } - // } + public synchronized void close() + throws RelationshipGraphException + { + userCounter--; + + if ( userCounter < 1 ) + { + forceClose(); + } + + logger.info( "NOT closing; there are other users registered!" ); + return; } // +++ IMPORTED FROM EProjectWeb... public Set> getAllRelationships() { - return new HashSet>( connection.getAllRelationships( params ) ); + return new HashSet>( getConnectionInternal().getAllRelationships( params ) ); } public boolean isComplete() { - return !connection.hasMissingProjects( params ); + return !getConnectionInternal().hasMissingProjects( params ); } public boolean isConcrete() { - return !connection.hasVariableProjects( params ); + return !getConnectionInternal().hasVariableProjects( params ); } public Set getIncompleteSubgraphs() { - return Collections.unmodifiableSet( connection.getMissingProjects( params ) ); + return Collections.unmodifiableSet( getConnectionInternal().getMissingProjects( params ) ); } public Set getVariableSubgraphs() { - return Collections.unmodifiableSet( connection.getVariableProjects( params ) ); + return Collections.unmodifiableSet( getConnectionInternal().getVariableProjects( params ) ); } public Set> add( final EProjectDirectRelationships rels ) @@ -216,8 +227,8 @@ public boolean add( final ProjectRelationship rel ) return false; } - return connection.addRelationships( rel ) - .isEmpty(); + return getConnectionInternal().addRelationships( rel ) + .isEmpty(); } public > Set addAll( final Collection rels ) @@ -231,12 +242,12 @@ public > Set addAll( final Collection rel final Set result = new HashSet( rels ); final Set> rejected = - connection.addRelationships( rels.toArray( new ProjectRelationship[] {} ) ); + getConnectionInternal().addRelationships( rels.toArray( new ProjectRelationship[] {} ) ); result.removeAll( rejected ); if ( !result.isEmpty() ) { - connection.recomputeIncompleteSubgraphs(); + getConnectionInternal().recomputeIncompleteSubgraphs(); } return result; @@ -259,7 +270,7 @@ public > Set addAll( final T... rels ) } } - connection.recomputeIncompleteSubgraphs(); + getConnectionInternal().recomputeIncompleteSubgraphs(); return result; } @@ -268,7 +279,7 @@ public void traverse( final ProjectVersionRef start, final RelationshipGraphTrav final TraversalType type ) throws RelationshipGraphException { - connection.traverse( traversal, start, this, type ); + getConnectionInternal().traverse( traversal, start, this, type ); } public void traverse( final ProjectVersionRef start, final RelationshipGraphTraversal traversal ) @@ -282,7 +293,7 @@ public void traverse( final RelationshipGraphTraversal traversal, final Traversa { for ( final ProjectVersionRef root : params.getRoots() ) { - connection.traverse( traversal, root, this, type ); + getConnectionInternal().traverse( traversal, root, this, type ); } } @@ -294,22 +305,22 @@ public void traverse( final RelationshipGraphTraversal traversal ) public Set> getUserRelationships( final ProjectVersionRef ref ) { - if ( !connection.containsProject( params, ref ) ) + if ( !getConnectionInternal().containsProject( params, ref ) ) { return Collections.emptySet(); } - return new HashSet>( connection.getRelationshipsTargeting( params, ref ) ); + return new HashSet>( getConnectionInternal().getRelationshipsTargeting( params, ref ) ); } public Set> getDirectRelationships( final ProjectVersionRef ref ) { - if ( !connection.containsProject( params, ref ) ) + if ( !getConnectionInternal().containsProject( params, ref ) ) { return Collections.emptySet(); } - return new HashSet>( connection.getRelationshipsDeclaredBy( params, ref ) ); + return new HashSet>( getConnectionInternal().getRelationshipsDeclaredBy( params, ref ) ); } public Set getRoots() @@ -324,29 +335,29 @@ public Set> getExactAllRelationships() public boolean isCycleParticipant( final ProjectVersionRef ref ) { - return connection.isCycleParticipant( params, ref ); + return getConnectionInternal().isCycleParticipant( params, ref ); } public boolean isCycleParticipant( final ProjectRelationship rel ) { - return connection.isCycleParticipant( params, rel ); + return getConnectionInternal().isCycleParticipant( params, rel ); } public void addCycle( final EProjectCycle cycle ) throws RelationshipGraphException { - connection.addCycle( cycle ); + getConnectionInternal().addCycle( cycle ); } public Set getCycles() { - return connection.getCycles( params ); + return getConnectionInternal().getCycles( params ); } public Set> getRelationshipsTargeting( final ProjectVersionRef ref ) { final Collection> rels = - connection.getRelationshipsTargeting( params, ref.asProjectVersionRef() ); + getConnectionInternal().getRelationshipsTargeting( params, ref.asProjectVersionRef() ); if ( rels == null ) { return Collections.emptySet(); @@ -362,57 +373,57 @@ public RelationshipGraphConnection getDatabase() public Set getAllProjects() { - return connection.getAllProjects( params ); + return getConnectionInternal().getAllProjects( params ); } public void addMetadata( final ProjectVersionRef ref, final String name, final String value ) throws RelationshipGraphException { - connection.addMetadata( ref, name, value ); + getConnectionInternal().addMetadata( ref, name, value ); } public void addMetadata( final ProjectVersionRef ref, final Map metadata ) throws RelationshipGraphException { - connection.setMetadata( ref, metadata ); + getConnectionInternal().setMetadata( ref, metadata ); } public Set getProjectsWithMetadata( final String key ) { - return connection.getProjectsWithMetadata( params, key ); + return getConnectionInternal().getProjectsWithMetadata( params, key ); } public void reindex() throws RelationshipGraphException { - connection.reindex(); + getConnectionInternal().reindex(); } public void reindex( final ProjectVersionRef ref ) throws RelationshipGraphConnectionException { - connection.reindex( ref ); + getConnectionInternal().reindex( ref ); } public Set>> getPathsTo( final ProjectVersionRef... projectVersionRefs ) { - return connection.getAllPathsTo( params, projectVersionRefs ); + return getConnectionInternal().getAllPathsTo( params, projectVersionRefs ); } public boolean introducesCycle( final ProjectRelationship rel ) { - return connection.introducesCycle( params, rel ); + return getConnectionInternal().introducesCycle( params, rel ); } public void addDisconnectedProject( final ProjectVersionRef ref ) throws RelationshipGraphException { - connection.addDisconnectedProject( ref ); + getConnectionInternal().addDisconnectedProject( ref ); } public boolean isMissing( final ProjectVersionRef ref ) { - return connection.isMissing( params, ref ); + return getConnectionInternal().isMissing( params, ref ); } public Set getSources() @@ -513,37 +524,37 @@ public final ProjectVersionRef getSelection( final ProjectRef ref ) // +++ IMPORTED FROM EGraphManager public boolean containsGraph( final ProjectVersionRef ref ) { - return connection.containsProject( params, ref ); + return getConnectionInternal().containsProject( params, ref ); } public Set> findDirectRelationshipsTo( final ProjectVersionRef to, final boolean includeManagedInfo, final RelationshipType... types ) { - return connection.getDirectRelationshipsTo( params, to, includeManagedInfo, true, types ); + return getConnectionInternal().getDirectRelationshipsTo( params, to, includeManagedInfo, true, types ); } public Set> findDirectRelationshipsFrom( final ProjectVersionRef source, final boolean managed, final RelationshipType... types ) { - return connection.getDirectRelationshipsFrom( params, source, managed, true, types ); + return getConnectionInternal().getDirectRelationshipsFrom( params, source, managed, true, types ); } public Set getAllIncompleteSubgraphs() { - return connection.getMissingProjects( params ); + return getConnectionInternal().getMissingProjects( params ); } public Set getAllVariableSubgraphs() { - return connection.getVariableProjects( params ); + return getConnectionInternal().getVariableProjects( params ); } public Map getMetadata( final ProjectVersionRef ref ) { final Map result = new HashMap(); - final Map metadata = connection.getMetadata( ref ); + final Map metadata = getConnectionInternal().getMetadata( ref ); if ( metadata != null ) { result.putAll( metadata ); @@ -559,7 +570,7 @@ public Map getMetadata( final ProjectVersionRef ref ) public Map getMetadata( final ProjectVersionRef ref, final Set keys ) { final Map result = new HashMap(); - final Map metadata = connection.getMetadata( ref, keys ); + final Map metadata = getConnectionInternal().getMetadata( ref, keys ); if ( metadata != null ) { result.putAll( metadata ); @@ -607,43 +618,43 @@ public Map, Set> collateByMetadata( final public void setMetadata( final ProjectVersionRef project, final Map metadata ) throws RelationshipGraphException { - connection.setMetadata( project, metadata ); + getConnectionInternal().setMetadata( project, metadata ); } public void deleteRelationshipsDeclaredBy( final ProjectVersionRef ref ) throws RelationshipGraphException { - connection.deleteRelationshipsDeclaredBy( ref ); + getConnectionInternal().deleteRelationshipsDeclaredBy( ref ); } public Set getProjectsMatching( final ProjectRef projectRef ) { - return connection.getProjectsMatching( params, projectRef ); + return getConnectionInternal().getProjectsMatching( params, projectRef ); } public Map, GraphPathInfo> getPathMapTargeting( final Set refs ) { - return connection.getPathMapTargeting( params, refs ); + return getConnectionInternal().getPathMapTargeting( params, refs ); } public ProjectVersionRef getPathTargetRef( final GraphPath path ) { - return connection.getPathTargetRef( path ); + return getConnectionInternal().getPathTargetRef( path ); } public GraphPath createPath( final GraphPath parentPath, final ProjectRelationship relationship ) { - return connection.createPath( parentPath, relationship ); + return getConnectionInternal().createPath( parentPath, relationship ); } public GraphPath createPath( final ProjectRelationship... relationships ) { - return connection.createPath( relationships ); + return getConnectionInternal().createPath( relationships ); } public List getPathRefs( final GraphPath path ) { - return connection.getPathRefs( params, path ); + return getConnectionInternal().getPathRefs( params, path ); } RelationshipGraphConnection getConnection() @@ -661,16 +672,16 @@ public String toString() public void printStats() { - connection.printStats(); + getConnectionInternal().printStats(); } public Map getAllProjectErrors() { final Map errors = new HashMap(); - final Set projects = connection.getAllProjects( params ); + final Set projects = getConnectionInternal().getAllProjects( params ); for ( final ProjectVersionRef ref : projects ) { - final Throwable error = connection.getProjectError( ref ); + final Throwable error = getConnectionInternal().getProjectError( ref ); if ( error != null ) { errors.put( ref, error ); @@ -680,4 +691,19 @@ public Map getAllProjectErrors() return errors; } + public synchronized boolean isOpen() + { + return connection != null; + } + + private synchronized RelationshipGraphConnection getConnectionInternal() + { + if ( connection == null ) + { + throw new IllegalStateException( "Relationship graph has been closed!" ); + } + + return connection; + } + } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java index b728a164..9a79ec1e 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java @@ -78,7 +78,7 @@ public synchronized RelationshipGraph open( final ViewParams params, final boole } else { - cache.addGraphOwner( params ); + graph.incrementGraphOwnership(); } return graph; @@ -145,8 +145,6 @@ private static final class ConnectionCache private final Map graphs = new HashMap(); - private final Map graphCounter = new HashMap(); - private final Timer timer; private TimerTask closeTimer; @@ -206,21 +204,6 @@ public synchronized boolean isOpen() return connection != null; } - synchronized void addGraphOwner( final ViewParams params ) - { - Integer i = graphCounter.remove( params ); - if ( i == null ) - { - i = Integer.valueOf( 1 ); - } - else - { - i = Integer.valueOf( i.intValue() + 1 ); - } - - graphCounter.put( params, i ); - } - RelationshipGraph getGraph( final ViewParams params ) { final RelationshipGraph graph = graphs.get( params ); @@ -255,7 +238,6 @@ RelationshipGraphConnection getConnection() synchronized void registerGraph( final ViewParams params, final RelationshipGraph graph ) { - addGraphOwner( params ); logger.info( "Registering new connection to: {}", params.getWorkspaceId() ); graphs.put( params, graph ); cancelCloseTimer(); @@ -263,19 +245,10 @@ synchronized void registerGraph( final ViewParams params, final RelationshipGrap synchronized void deregisterGraph( final ViewParams params ) { - Integer i = graphCounter.remove( params ); - if ( i == null || i.intValue() < 2 ) - { - graphs.remove( params ); - if ( isEmpty() ) - { - startCloseTimer(); - } - } - else + graphs.remove( params ); + if ( isEmpty() ) { - i = Integer.valueOf( i.intValue() - 1 ); - graphCounter.put( params, i ); + startCloseTimer(); } } From 8334cc6ec4ea4c5cc02488cd639a252d28b4677d Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 4 Jun 2014 12:53:47 -0500 Subject: [PATCH 010/240] Fixing sorting bug in SnapshotPart, adding methods to detect/parse SnapshotPart instances from a string literal (SnapshotSupport), and using these when constructing a SnapshotPart with only the string literal, if the literal represents a remote snapshot --- .../ident/version/part/SnapshotPart.java | 20 +++++++-- .../version/transform/SnapshotSupport.java | 42 ++++++++++++++++++- .../ident/version/part/SnapshotPartTest.java | 23 ++++++++++ .../maven/atlas/graph/RelationshipGraph.java | 12 ++++-- .../atlas/graph/RelationshipGraphFactory.java | 10 ++++- 5 files changed, 97 insertions(+), 10 deletions(-) create mode 100644 identities/src/test/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPartTest.java diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPart.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPart.java index f64371ce..105ea1dd 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPart.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPart.java @@ -13,6 +13,8 @@ import java.io.Serializable; import java.util.Date; +import org.commonjava.maven.atlas.ident.version.transform.SnapshotSupport; + public class SnapshotPart extends VersionPart implements Serializable @@ -26,7 +28,6 @@ public class SnapshotPart private final String literal; - // TODO: Parse into date and buildnumber for comparison public SnapshotPart( final Date timestamp, final int buildNumber, final String literal ) { this.timestamp = timestamp; @@ -36,8 +37,18 @@ public SnapshotPart( final Date timestamp, final int buildNumber, final String l public SnapshotPart( final String literal ) { - timestamp = null; - buildNumber = null; + if ( SnapshotSupport.isRemoteSnapshotVersionPart( literal ) ) + { + final SnapshotPart sp = SnapshotSupport.parseRemoteSnapshotVersionPart( literal ); + timestamp = sp.timestamp; + buildNumber = sp.buildNumber; + } + else + { + timestamp = null; + buildNumber = null; + } + this.literal = literal; } @@ -78,6 +89,7 @@ public String getValue() return renderStandard(); } + @Override public int compareTo( final VersionPart o ) { if ( o instanceof SnapshotPart ) @@ -90,6 +102,8 @@ public int compareTo( final VersionPart o ) { return getBuildNumber() - oSnap.getBuildNumber(); } + + return comp; } else if ( isLocalSnapshot() && !oSnap.isLocalSnapshot() ) { diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/transform/SnapshotSupport.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/transform/SnapshotSupport.java index 908781a5..06da51e0 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/transform/SnapshotSupport.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/transform/SnapshotSupport.java @@ -15,13 +15,17 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.commonjava.maven.atlas.ident.version.part.SnapshotPart; public class SnapshotSupport { public static final String SNAPSHOT_TSTAMP_FORMAT = "yyyyMMdd.hhmmss"; - public static final String SNAPSHOT_PATTERN = "^((.+)-)?([0-9]{8}.[0-9]{6})-([0-9]+)$"; + public static final String REMOTE_SNAPSHOT_PART_PATTERN = "^((.+)-)?([0-9]{8}.[0-9]{6})-([0-9]+)$"; public static String generateSnapshotSuffix( final Date d, final int buildNumber ) { @@ -33,6 +37,42 @@ public static String generateSnapshotTimestamp( final Date d ) return getFormat().format( d ); } + public static boolean isRemoteSnapshotVersionPart( final String literal ) + { + return literal.matches( REMOTE_SNAPSHOT_PART_PATTERN ); + } + + public static SnapshotPart parseRemoteSnapshotVersionPart( final String literal ) + { + final Pattern pattern = Pattern.compile( REMOTE_SNAPSHOT_PART_PATTERN ); + final Matcher matcher = pattern.matcher( literal ); + if ( matcher.matches() ) + { + final String tstamp = matcher.group( 3 ); + final String bn = matcher.group( 4 ); + if ( tstamp != null || bn != null ) + { + Date d; + try + { + d = parseSnapshotTimestamp( tstamp ); + } + catch ( final ParseException e ) + { + throw new IllegalArgumentException( "'" + literal + + "' is not a remote snapshot version-part (of the format: " + SNAPSHOT_TSTAMP_FORMAT + + "-NN (invalid timestamp)", e ); + } + final int build = Integer.parseInt( bn ); + + return new SnapshotPart( d, build, literal ); + } + } + + throw new IllegalArgumentException( "'" + literal + "' is not a remote snapshot version-part (of the format: " + + SNAPSHOT_TSTAMP_FORMAT + "-NN" ); + } + public static Date parseSnapshotTimestamp( final String tstamp ) throws ParseException { diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPartTest.java b/identities/src/test/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPartTest.java new file mode 100644 index 00000000..4bbe3906 --- /dev/null +++ b/identities/src/test/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPartTest.java @@ -0,0 +1,23 @@ +package org.commonjava.maven.atlas.ident.version.part; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +import org.junit.Test; + +public class SnapshotPartTest +{ + + @Test + public void compareTwoRemoteSnapshotsWithDifferentTimestamps_ParsedFromLiterals() + throws Exception + { + final SnapshotPart first = new SnapshotPart( "20140604.124355-1" ); + final SnapshotPart second = new SnapshotPart( "20140604.124350-1" ); + + final int result = first.compareTo( second ); + + assertThat( result, equalTo( 1 ) ); + } + +} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java index 1754d9ab..812d06fb 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java @@ -46,7 +46,7 @@ public final class RelationshipGraph private RelationshipGraphConnection connection; // if we didn't have a user, we wouldn't have constructed this thing! - private int userCounter = 1; + private int userCount = 1; RelationshipGraph( final ViewParams params, final RelationshipGraphConnection driver ) { @@ -147,12 +147,15 @@ public void removeListener( final RelationshipGraphListener listener ) synchronized void incrementGraphOwnership() { - userCounter++; + userCount++; + logger.info( "User count incremented to: {} for: {}", userCount, params ); } public synchronized void forceClose() throws RelationshipGraphException { + logger.info( "Closing: {}", params ); + if ( listeners != null ) { for ( final RelationshipGraphListener listener : listeners ) @@ -175,9 +178,10 @@ public synchronized void forceClose() public synchronized void close() throws RelationshipGraphException { - userCounter--; + userCount--; + logger.info( "User count decremented to: {} for: {}", userCount, params ); - if ( userCounter < 1 ) + if ( userCount < 1 ) { forceClose(); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java index 9a79ec1e..93dd9ceb 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java @@ -1,5 +1,7 @@ package org.commonjava.maven.atlas.graph; +import static org.apache.commons.lang.StringUtils.join; + import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; @@ -61,11 +63,15 @@ public synchronized RelationshipGraph open( final ViewParams params, final boole cache = new ConnectionCache( timer, connectionCaches, connection ); connectionCaches.put( wsid, cache ); - logger.info( "Created new connection to graph db: {}", params.getWorkspaceId() ); + logger.info( "Created new connection to graph db: {}\nVia:\n {}", params.getWorkspaceId(), + join( Thread.currentThread() + .getStackTrace(), "\n " ) ); } else { - logger.info( "Reusing connection to graph db: {}", params.getWorkspaceId() ); + logger.info( "Reusing connection to graph db: {}\nVia:\n {}", params.getWorkspaceId(), + join( Thread.currentThread() + .getStackTrace(), "\n " ) ); } RelationshipGraph graph = cache.getGraph( params ); From aae701b40eba3c405bf4c74d741a57e461c30a41 Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 4 Jun 2014 13:39:16 -0500 Subject: [PATCH 011/240] moving a couple util classes into the ident.util package, and moving ArtifactPathInfo out of aprox and galley, and into atlas-identities (since the functionality belongs here) --- .../atlas/ident/ref/ProjectVersionRef.java | 2 +- .../atlas/ident/util/ArtifactPathInfo.java | 234 ++++++++++++++++++ .../SnapshotUtils.java} | 35 ++- .../ident/{version => util}/VersionUtils.java | 6 +- .../ident/version/part/SnapshotPart.java | 11 +- identities/src/main/javacc/version.jj | 4 +- .../ident/util/ArtifactPathInfoTest.java | 46 ++++ .../version/SingleVersionComparisonsTest.java | 2 +- .../atlas/ident/version/VersionRangeTest.java | 2 +- .../atlas/ident/version/VersionUtilsTest.java | 2 +- .../graph/rel/ParentRelationshipTest.java | 2 +- 11 files changed, 332 insertions(+), 14 deletions(-) create mode 100644 identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java rename identities/src/main/java/org/commonjava/maven/atlas/ident/{version/transform/SnapshotSupport.java => util/SnapshotUtils.java} (73%) rename identities/src/main/java/org/commonjava/maven/atlas/ident/{version => util}/VersionUtils.java (91%) create mode 100644 identities/src/test/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfoTest.java diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java index 77795479..850e57a4 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java @@ -14,10 +14,10 @@ import java.io.Serializable; +import org.commonjava.maven.atlas.ident.util.VersionUtils; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; import org.commonjava.maven.atlas.ident.version.SingleVersion; import org.commonjava.maven.atlas.ident.version.VersionSpec; -import org.commonjava.maven.atlas.ident.version.VersionUtils; /** * Reference to a particular release of a project (or module, in terms of Maven builds). A release may contain many artifacts (see {@link ArtifactRef}). diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java new file mode 100644 index 00000000..328ad5de --- /dev/null +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java @@ -0,0 +1,234 @@ +/******************************************************************************* + * Copyright (c) 2014 Red Hat, Inc.. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Public License v3.0 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/gpl.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package org.commonjava.maven.atlas.ident.util; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.version.part.SnapshotPart; + +public class ArtifactPathInfo +{ + + // regex developed at: http://fiddle.re/tvk5 + private static final String ARTIFACT_PATH_REGEX = + "\\/?(([^\\/]+\\/)*[^\\/]+)\\/([^\\/]+)\\/(([^\\/]+)(-SNAPSHOT)?)\\/(\\3-((\\4)|(\\5-" + + SnapshotUtils.RAW_REMOTE_SNAPSHOT_PART_PATTERN + "))(-([^.]+))?(\\.(.+)))"; + + private static final int GROUP_ID_GROUP = 1; + + private static final int ARTIFACT_ID_GROUP = 3; + + private static final int FILE_GROUP = 5; + + private static final int VERSION_GROUP = 8; + + private static final int CLASSIFIER_GROUP = 12; + + private static final int TYPE_GROUP = 14; + + public static ArtifactPathInfo parse( final String path ) + { + if ( path == null ) + { + return null; + } + + final Matcher matcher = Pattern.compile( ARTIFACT_PATH_REGEX ) + .matcher( path.replace( '\\', '/' ) ); + if ( !matcher.matches() ) + { + return null; + } + + final String g = matcher.group( GROUP_ID_GROUP ) + .replace( '/', '.' ); + final String a = matcher.group( ARTIFACT_ID_GROUP ); + final String v = matcher.group( VERSION_GROUP ); + final String c = matcher.group( CLASSIFIER_GROUP ); + final String t = matcher.group( TYPE_GROUP ); + final String f = matcher.group( FILE_GROUP ); + + return new ArtifactPathInfo( g, a, v, c, t, f, path ); + } + + private final String groupId; + + private final String artifactId; + + private final String version; + + private final String classifier; + + private final String type; + + private final String file; + + private final String fullPath; + + private final boolean isSnapshot; + + public ArtifactPathInfo( final String groupId, final String artifactId, final String version, final String file, + final String fullPath ) + { + this( groupId, artifactId, version, null, "jar", file, fullPath ); + } + + public ArtifactPathInfo( final String groupId, final String artifactId, final String version, + final String classifier, final String type, final String file, final String fullPath ) + { + this.groupId = groupId; + this.artifactId = artifactId; + this.version = version; + this.classifier = classifier; + this.type = type; + this.file = file; + this.fullPath = fullPath; + isSnapshot = SnapshotUtils.isSnapshotVersion( version ); + } + + public boolean isSnapshot() + { + return isSnapshot; + } + + private SnapshotPart snapshotInfo; + + public synchronized SnapshotPart getSnapshotInfo() + { + snapshotInfo = SnapshotUtils.extractSnapshotVersionPart( version ); + return snapshotInfo; + } + + public String getGroupId() + { + return groupId; + } + + public String getArtifactId() + { + return artifactId; + } + + public String getVersion() + { + return version; + } + + public String getClassifier() + { + return classifier; + } + + public String getType() + { + return type; + } + + public String getFile() + { + return file; + } + + public String getFullPath() + { + return fullPath; + } + + @Override + public String toString() + { + return String.format( "ArtifactPathInfo [groupId=%s, artifactId=%s, version=%s, file=%s]", groupId, artifactId, + version, file ); + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ( ( artifactId == null ) ? 0 : artifactId.hashCode() ); + result = prime * result + ( ( file == null ) ? 0 : file.hashCode() ); + result = prime * result + ( ( groupId == null ) ? 0 : groupId.hashCode() ); + result = prime * result + ( ( version == null ) ? 0 : version.hashCode() ); + return result; + } + + @Override + public boolean equals( final Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( obj == null ) + { + return false; + } + if ( getClass() != obj.getClass() ) + { + return false; + } + final ArtifactPathInfo other = (ArtifactPathInfo) obj; + if ( artifactId == null ) + { + if ( other.artifactId != null ) + { + return false; + } + } + else if ( !artifactId.equals( other.artifactId ) ) + { + return false; + } + if ( file == null ) + { + if ( other.file != null ) + { + return false; + } + } + else if ( !file.equals( other.file ) ) + { + return false; + } + if ( groupId == null ) + { + if ( other.groupId != null ) + { + return false; + } + } + else if ( !groupId.equals( other.groupId ) ) + { + return false; + } + if ( version == null ) + { + if ( other.version != null ) + { + return false; + } + } + else if ( !version.equals( other.version ) ) + { + return false; + } + return true; + } + + public ProjectVersionRef getProjectId() + { + return new ProjectVersionRef( getGroupId(), getArtifactId(), getVersion() ); + } + +} diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/transform/SnapshotSupport.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/SnapshotUtils.java similarity index 73% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/version/transform/SnapshotSupport.java rename to identities/src/main/java/org/commonjava/maven/atlas/ident/util/SnapshotUtils.java index 06da51e0..601d8c82 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/transform/SnapshotSupport.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/SnapshotUtils.java @@ -8,7 +8,7 @@ * Contributors: * Red Hat, Inc. - initial API and implementation ******************************************************************************/ -package org.commonjava.maven.atlas.ident.version.transform; +package org.commonjava.maven.atlas.ident.util; import java.text.DateFormat; import java.text.ParseException; @@ -20,12 +20,16 @@ import org.commonjava.maven.atlas.ident.version.part.SnapshotPart; -public class SnapshotSupport +public class SnapshotUtils { public static final String SNAPSHOT_TSTAMP_FORMAT = "yyyyMMdd.hhmmss"; - public static final String REMOTE_SNAPSHOT_PART_PATTERN = "^((.+)-)?([0-9]{8}.[0-9]{6})-([0-9]+)$"; + public static final String RAW_REMOTE_SNAPSHOT_PART_PATTERN = "([0-9]{8}.[0-9]{6})-([0-9]+)"; + + public static final String REMOTE_SNAPSHOT_PART_PATTERN = "^((.+)-)?" + RAW_REMOTE_SNAPSHOT_PART_PATTERN + "$"; + + public static final String LOCAL_SNAPSHOT_VERSION_PART = "-SNAPSHOT"; public static String generateSnapshotSuffix( final Date d, final int buildNumber ) { @@ -37,6 +41,16 @@ public static String generateSnapshotTimestamp( final Date d ) return getFormat().format( d ); } + public static boolean isSnapshotVersion( final String literal ) + { + return literal.endsWith( LOCAL_SNAPSHOT_VERSION_PART ) || isRemoteSnapshotVersion( literal ); + } + + public static boolean isRemoteSnapshotVersion( final String literal ) + { + return literal.matches( REMOTE_SNAPSHOT_PART_PATTERN ); + } + public static boolean isRemoteSnapshotVersionPart( final String literal ) { return literal.matches( REMOTE_SNAPSHOT_PART_PATTERN ); @@ -87,4 +101,19 @@ private static DateFormat getFormat() return fmt; } + public static SnapshotPart extractSnapshotVersionPart( final String version ) + { + SnapshotPart part = null; + if ( SnapshotUtils.isRemoteSnapshotVersion( version ) ) + { + part = SnapshotUtils.parseRemoteSnapshotVersionPart( version ); + } + else if ( version.endsWith( LOCAL_SNAPSHOT_VERSION_PART ) ) + { + part = new SnapshotPart( LOCAL_SNAPSHOT_VERSION_PART ); + } + + return part; + } + } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/VersionUtils.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionUtils.java similarity index 91% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/version/VersionUtils.java rename to identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionUtils.java index 7c54e431..f14d5308 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/VersionUtils.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionUtils.java @@ -8,8 +8,12 @@ * Contributors: * Red Hat, Inc. - initial API and implementation ******************************************************************************/ -package org.commonjava.maven.atlas.ident.version; +package org.commonjava.maven.atlas.ident.util; +import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; +import org.commonjava.maven.atlas.ident.version.RangeVersionSpec; +import org.commonjava.maven.atlas.ident.version.SingleVersion; +import org.commonjava.maven.atlas.ident.version.VersionSpec; import org.commonjava.maven.atlas.ident.version.parse.ParseException; import org.commonjava.maven.atlas.ident.version.parse.TokenMgrError; import org.commonjava.maven.atlas.ident.version.parse.VersionParser; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPart.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPart.java index 105ea1dd..0b81736b 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPart.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPart.java @@ -13,7 +13,7 @@ import java.io.Serializable; import java.util.Date; -import org.commonjava.maven.atlas.ident.version.transform.SnapshotSupport; +import org.commonjava.maven.atlas.ident.util.SnapshotUtils; public class SnapshotPart extends VersionPart @@ -37,9 +37,9 @@ public SnapshotPart( final Date timestamp, final int buildNumber, final String l public SnapshotPart( final String literal ) { - if ( SnapshotSupport.isRemoteSnapshotVersionPart( literal ) ) + if ( SnapshotUtils.isRemoteSnapshotVersionPart( literal ) ) { - final SnapshotPart sp = SnapshotSupport.parseRemoteSnapshotVersionPart( literal ); + final SnapshotPart sp = SnapshotUtils.parseRemoteSnapshotVersionPart( literal ); timestamp = sp.timestamp; buildNumber = sp.buildNumber; } @@ -72,6 +72,11 @@ public boolean isLocalSnapshot() return timestamp == null; } + public boolean isRemoteSnapshot() + { + return timestamp != null; + } + @Override public String toString() { diff --git a/identities/src/main/javacc/version.jj b/identities/src/main/javacc/version.jj index 373f80c2..ea4c6fa9 100644 --- a/identities/src/main/javacc/version.jj +++ b/identities/src/main/javacc/version.jj @@ -10,9 +10,9 @@ options { PARSER_BEGIN(VersionParser) package org.commonjava.maven.atlas.ident.version.parse; +import org.commonjava.maven.atlas.ident.util.*; import org.commonjava.maven.atlas.ident.version.*; import org.commonjava.maven.atlas.ident.version.part.*; -import org.commonjava.maven.atlas.ident.version.transform.*; import java.util.*; import java.text.*; import java.io.*; @@ -63,7 +63,7 @@ public class VersionParser { try { - return new SnapshotPart( SnapshotSupport.parseSnapshotTimestamp( date ), Integer.parseInt( buildnum ), date + "-" + buildnum ); + return new SnapshotPart( SnapshotUtils.parseSnapshotTimestamp( date ), Integer.parseInt( buildnum ), date + "-" + buildnum ); } catch ( java.text.ParseException e ) { diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfoTest.java b/identities/src/test/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfoTest.java new file mode 100644 index 00000000..77c6546c --- /dev/null +++ b/identities/src/test/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfoTest.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2014 Red Hat, Inc.. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Public License v3.0 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/gpl.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package org.commonjava.maven.atlas.ident.util; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +import org.junit.Test; + +public class ArtifactPathInfoTest +{ + + @Test + public void matchSnapshotUIDVersion() + { + final String path = + "/path/to/unsigner-maven-plugin/0.2-SNAPSHOT/unsigner-maven-plugin-0.2-20120307.200227-1.jar"; + assertThat( ArtifactPathInfo.parse( path ) + .isSnapshot(), equalTo( true ) ); + } + + @Test + public void matchSnapshotNonUIDVersion() + { + final String path = "/path/to/unsigner-maven-plugin/0.2-SNAPSHOT/unsigner-maven-plugin-0.2-SNAPSHOT.jar"; + assertThat( ArtifactPathInfo.parse( path ) + .isSnapshot(), equalTo( true ) ); + } + + @Test + public void dontMatchNonSnapshotVersion() + { + final String path = "/path/to/unsigner-maven-plugin/0.2/unsigner-maven-plugin-0.2.jar"; + assertThat( ArtifactPathInfo.parse( path ) + .isSnapshot(), equalTo( false ) ); + } + +} diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/SingleVersionComparisonsTest.java b/identities/src/test/java/org/commonjava/maven/atlas/ident/version/SingleVersionComparisonsTest.java index b3034434..b7a7900e 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/SingleVersionComparisonsTest.java +++ b/identities/src/test/java/org/commonjava/maven/atlas/ident/version/SingleVersionComparisonsTest.java @@ -37,9 +37,9 @@ import java.util.List; import java.util.Locale; +import org.commonjava.maven.atlas.ident.util.VersionUtils; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; import org.commonjava.maven.atlas.ident.version.SingleVersion; -import org.commonjava.maven.atlas.ident.version.VersionUtils; import org.junit.After; import org.junit.Rule; import org.junit.Test; diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionRangeTest.java b/identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionRangeTest.java index e6d10b11..15cf11f8 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionRangeTest.java +++ b/identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionRangeTest.java @@ -13,9 +13,9 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; +import org.commonjava.maven.atlas.ident.util.VersionUtils; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; import org.commonjava.maven.atlas.ident.version.RangeVersionSpec; -import org.commonjava.maven.atlas.ident.version.VersionUtils; import org.junit.Test; public class VersionRangeTest diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionUtilsTest.java b/identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionUtilsTest.java index fb612fe4..43c8e017 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionUtilsTest.java +++ b/identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionUtilsTest.java @@ -10,8 +10,8 @@ ******************************************************************************/ package org.commonjava.maven.atlas.ident.version; +import org.commonjava.maven.atlas.ident.util.VersionUtils; import org.commonjava.maven.atlas.ident.version.SingleVersion; -import org.commonjava.maven.atlas.ident.version.VersionUtils; import org.junit.Test; public class VersionUtilsTest diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/ParentRelationshipTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/ParentRelationshipTest.java index 1a11f52f..533c2197 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/ParentRelationshipTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/ParentRelationshipTest.java @@ -17,8 +17,8 @@ import java.net.URISyntaxException; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.util.VersionUtils; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; -import org.commonjava.maven.atlas.ident.version.VersionUtils; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestName; From 80014e832fcf275d98c3238e62f8fa6a0c5e9483 Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 5 Jun 2014 16:17:19 -0500 Subject: [PATCH 012/240] upgrade parent version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 14cda69e..10e01953 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ org.commonjava commonjava - 3 + 4 org.commonjava.maven.atlas From 6ed3894f981a730c8ebdf575044582f40ccd912e Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 5 Jun 2014 16:18:15 -0500 Subject: [PATCH 013/240] [maven-release-plugin] prepare release atlas-parent-0.13.0 --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 9 +++++---- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index faa227ec..aab970f2 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.0-SNAPSHOT + 0.13.0 atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index e69a849e..dbc5f250 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.0-SNAPSHOT + 0.13.0 atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 7eb69b85..5899193d 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.0-SNAPSHOT + 0.13.0 atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index e9693ced..8589b8fa 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.0-SNAPSHOT + 0.13.0 atlas-identities diff --git a/pom.xml b/pom.xml index 10e01953..2d786d1a 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.0-SNAPSHOT + 0.13.0 pom Atlas :: Maven Project-Graph :: Parent @@ -29,6 +29,7 @@ scm:git:http://jdcasey@github.com/jdcasey/atlas.git scm:git:git@github.com:jdcasey/atlas.git http://github.com/jdcasey/atlas + atlas-parent-0.13.0 @@ -36,17 +37,17 @@ org.commonjava.maven.atlas atlas-identities - 0.13.0-SNAPSHOT + 0.13.0 org.commonjava.maven.atlas atlas-relationships-api - 0.13.0-SNAPSHOT + 0.13.0 org.commonjava.maven.atlas atlas-drivers-tck - 0.13.0-SNAPSHOT + 0.13.0 test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 62e9171d..511a363d 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.0-SNAPSHOT + 0.13.0 atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index cbd284aa..28eae693 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.0-SNAPSHOT + 0.13.0 atlas-drivers-tck From 6957f2720bdd53d23a2531aab74342e3672c707a Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 5 Jun 2014 16:18:19 -0500 Subject: [PATCH 014/240] [maven-release-plugin] prepare for next development iteration --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index aab970f2..cf04af74 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.0 + 0.13.1-SNAPSHOT atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index dbc5f250..15c44bd9 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.0 + 0.13.1-SNAPSHOT atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 5899193d..b5dec598 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.0 + 0.13.1-SNAPSHOT atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index 8589b8fa..ed8dc521 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.0 + 0.13.1-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index 2d786d1a..2ba0b956 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.0 + 0.13.1-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -29,7 +29,7 @@ scm:git:http://jdcasey@github.com/jdcasey/atlas.git scm:git:git@github.com:jdcasey/atlas.git http://github.com/jdcasey/atlas - atlas-parent-0.13.0 + HEAD @@ -37,17 +37,17 @@ org.commonjava.maven.atlas atlas-identities - 0.13.0 + 0.13.1-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.13.0 + 0.13.1-SNAPSHOT org.commonjava.maven.atlas atlas-drivers-tck - 0.13.0 + 0.13.1-SNAPSHOT test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 511a363d..7c2f21c3 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.0 + 0.13.1-SNAPSHOT atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 28eae693..b6847e20 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.0 + 0.13.1-SNAPSHOT atlas-drivers-tck From 075de39178e246e00fad9673e40b7b5df2c6c730 Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 9 Jun 2014 14:15:54 -0500 Subject: [PATCH 015/240] Add parse methods to ArtifactRef and VersionlessArtifactRef...the latter is a little less flexible because of ambiguity from optional classifier field, but still reasonable. --- .../maven/atlas/ident/ref/ArtifactRef.java | 52 ++++++++++++++++--- .../ident/ref/VersionlessArtifactRef.java | 43 +++++++++++++++ 2 files changed, 88 insertions(+), 7 deletions(-) diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java index c12bb6e1..d99637d1 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java @@ -10,6 +10,8 @@ ******************************************************************************/ package org.commonjava.maven.atlas.ident.ref; +import static org.apache.commons.lang.StringUtils.isEmpty; + import java.io.Serializable; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; @@ -69,6 +71,49 @@ public ArtifactRef( final String groupId, final String artifactId, final String this.optional = optional; } + @Override + public String toString() + { + return String.format( "%s:%s:%s:%s%s", getGroupId(), getArtifactId(), getType(), getVersionString(), + ( getClassifier() == null ? "" : ":" + getClassifier() ) ); + } + + public static ArtifactRef parse( final String spec ) + { + final String[] parts = spec.split( ":" ); + + if ( parts.length < 3 || isEmpty( parts[0] ) || isEmpty( parts[1] ) || isEmpty( parts[2] ) ) + { + throw new InvalidRefException( + "ArtifactRef must contain AT LEAST non-empty groupId, artifactId, AND version. (Given: '" + + spec + "')" ); + } + + final String g = parts[0]; + final String a = parts[1]; + + // assume we're actually parsing a GAV into a POM artifact... + String v = parts[2]; + String t = "pom"; + String c = null; + + if ( parts.length > 3 ) + { + // oops, it's a type, not a version...see toString() for the specification. + t = v; + v = parts[3]; + + if ( parts.length > 4 ) + { + c = parts[4]; + } + } + + // assume non-optional, because it might not matter if you're parsing a string like this...you'd be more careful if you were reading something + // that had an optional field, because it's not in the normal GATV[C] spec. + return new ArtifactRef( g, a, v, t, c, false ); + } + @Override protected ProjectVersionRef newRef( final String groupId, final String artifactId, final SingleVersion version ) { @@ -152,13 +197,6 @@ else if ( !tc.equals( other.tc ) ) return true; } - @Override - public String toString() - { - return String.format( "%s:%s:%s:%s%s", getGroupId(), getArtifactId(), getType(), getVersionString(), - ( getClassifier() == null ? "" : ":" + getClassifier() ) ); - } - @Override public boolean versionlessEquals( final ProjectVersionRef other ) { diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java index 0f43f054..cab4952e 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java @@ -10,6 +10,8 @@ ******************************************************************************/ package org.commonjava.maven.atlas.ident.ref; +import static org.apache.commons.lang.StringUtils.isEmpty; + import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; /** @@ -65,6 +67,47 @@ public String toString() return String.format( "%s:%s:%s", getGroupId(), getArtifactId(), getTypeAndClassifier() ); } + public static VersionlessArtifactRef parse( final String spec ) + { + final String[] parts = spec.split( ":" ); + + if ( parts.length < 2 || isEmpty( parts[0] ) || isEmpty( parts[1] ) ) + { + throw new InvalidRefException( + "VersionlessArtifactRef must contain AT LEAST non-empty groupId and artifactId. (Given: '" + + spec + "')" ); + } + + final String g = parts[0]; + final String a = parts[1]; + + String t = "pom"; + String c = null; + + if ( parts.length > 2 ) + { + // we probably have a type in there. + t = parts[2]; + + if ( parts.length > 3 ) + { + // we have a classifier? What if it's GATV?? + // assume it's just a classifier... + c = parts[3]; + + if ( parts.length > 4 ) + { + // okay, wtf? It's a GATVC, and we need to shift to eliminate the V... + c = parts[4]; + } + } + } + + // assume non-optional, because it might not matter if you're parsing a string like this...you'd be more careful if you were reading something + // that had an optional field, because it's not in the normal GATV[C] spec. + return new VersionlessArtifactRef( g, a, t, c, false ); + } + public String getType() { return tc.getType(); From 0579db13b80ea3e8d843aa69d5d03c4fefadbb58 Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 9 Jun 2014 14:27:58 -0500 Subject: [PATCH 016/240] Adding tests for parse() methods on ArtifactRef and VersionlessArtifactRef --- .../atlas/ident/ref/ArtifactRefTest.java | 69 +++++++++++++ .../ident/ref/VersionlessArtifactRefTest.java | 96 ++++++++++++++++++- 2 files changed, 162 insertions(+), 3 deletions(-) create mode 100644 identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ArtifactRefTest.java diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ArtifactRefTest.java b/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ArtifactRefTest.java new file mode 100644 index 00000000..a67633f0 --- /dev/null +++ b/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ArtifactRefTest.java @@ -0,0 +1,69 @@ +package org.commonjava.maven.atlas.ident.ref; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertThat; + +import org.junit.Test; + +public class ArtifactRefTest +{ + + @Test( expected = InvalidRefException.class ) + public void failParsingGA() + { + ArtifactRef.parse( "org.foo:bar" ); + } + + @Test + public void parseGAVIntoPOM() + { + final String g = "org.foo"; + final String a = "bar"; + final String v = "1.0"; + + final ArtifactRef ar = ArtifactRef.parse( String.format( "%s:%s:%s", g, a, v ) ); + + assertThat( ar.getGroupId(), equalTo( g ) ); + assertThat( ar.getArtifactId(), equalTo( a ) ); + assertThat( ar.getVersionString(), equalTo( v ) ); + assertThat( ar.getType(), equalTo( "pom" ) ); + assertThat( ar.getClassifier(), nullValue() ); + } + + @Test + public void parseGATV() + { + final String g = "org.foo"; + final String a = "bar"; + final String v = "1.0"; + final String t = "zip"; + + final ArtifactRef ar = ArtifactRef.parse( String.format( "%s:%s:%s:%s", g, a, t, v ) ); + + assertThat( ar.getGroupId(), equalTo( g ) ); + assertThat( ar.getArtifactId(), equalTo( a ) ); + assertThat( ar.getVersionString(), equalTo( v ) ); + assertThat( ar.getType(), equalTo( t ) ); + assertThat( ar.getClassifier(), nullValue() ); + } + + @Test + public void parseGATVC() + { + final String g = "org.foo"; + final String a = "bar"; + final String v = "1.0"; + final String t = "zip"; + final String c = "sources"; + + final ArtifactRef ar = ArtifactRef.parse( String.format( "%s:%s:%s:%s:%s", g, a, t, v, c ) ); + + assertThat( ar.getGroupId(), equalTo( g ) ); + assertThat( ar.getArtifactId(), equalTo( a ) ); + assertThat( ar.getVersionString(), equalTo( v ) ); + assertThat( ar.getType(), equalTo( t ) ); + assertThat( ar.getClassifier(), equalTo( c ) ); + } + +} diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRefTest.java b/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRefTest.java index 6f6a9839..1c25cbe8 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRefTest.java +++ b/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRefTest.java @@ -11,15 +11,105 @@ package org.commonjava.maven.atlas.ident.ref; import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.nullValue; import static org.junit.Assert.assertThat; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.VersionlessArtifactRef; import org.junit.Test; public class VersionlessArtifactRefTest { + + @Test + public void parseGA() + { + final String g = "org.foo"; + final String a = "bar"; + final VersionlessArtifactRef var = VersionlessArtifactRef.parse( String.format( "%s:%s", g, a ) ); + + assertThat( var.getGroupId(), equalTo( g ) ); + assertThat( var.getArtifactId(), equalTo( a ) ); + assertThat( var.getType(), equalTo( "pom" ) ); + assertThat( var.getClassifier(), nullValue() ); + } + + @Test + public void parseGAT() + { + final String g = "org.foo"; + final String a = "bar"; + final String t = "zip"; + + final VersionlessArtifactRef var = VersionlessArtifactRef.parse( String.format( "%s:%s:%s", g, a, t ) ); + + assertThat( var.getGroupId(), equalTo( g ) ); + assertThat( var.getArtifactId(), equalTo( a ) ); + assertThat( var.getType(), equalTo( t ) ); + assertThat( var.getClassifier(), nullValue() ); + } + + @Test + public void parseGATC() + { + final String g = "org.foo"; + final String a = "bar"; + final String t = "zip"; + final String c = "sources"; + + final VersionlessArtifactRef var = VersionlessArtifactRef.parse( String.format( "%s:%s:%s:%s", g, a, t, c ) ); + + assertThat( var.getGroupId(), equalTo( g ) ); + assertThat( var.getArtifactId(), equalTo( a ) ); + assertThat( var.getType(), equalTo( t ) ); + assertThat( var.getClassifier(), equalTo( c ) ); + } + + @Test + public void parseGATVC_VersionDiscarded() + { + final String g = "org.foo"; + final String a = "bar"; + final String t = "zip"; + final String v = "1.0"; + final String c = "sources"; + + final VersionlessArtifactRef var = + VersionlessArtifactRef.parse( String.format( "%s:%s:%s:%s:%s", g, a, t, v, c ) ); + + assertThat( var.getGroupId(), equalTo( g ) ); + assertThat( var.getArtifactId(), equalTo( a ) ); + assertThat( var.getType(), equalTo( t ) ); + assertThat( var.getClassifier(), equalTo( c ) ); + } + + @Test + public void parseGATV_MistakeForGATC() + { + final String g = "org.foo"; + final String a = "bar"; + final String t = "zip"; + final String v = "1.0"; + + final VersionlessArtifactRef var = VersionlessArtifactRef.parse( String.format( "%s:%s:%s:%s", g, a, t, v ) ); + + assertThat( var.getGroupId(), equalTo( g ) ); + assertThat( var.getArtifactId(), equalTo( a ) ); + assertThat( var.getType(), equalTo( t ) ); + assertThat( var.getClassifier(), equalTo( v ) ); + } + + @Test + public void parseGATVC() + { + final String g = "org.foo"; + final String a = "bar"; + final VersionlessArtifactRef var = VersionlessArtifactRef.parse( String.format( "%s:%s", g, a ) ); + + assertThat( var.getGroupId(), equalTo( g ) ); + assertThat( var.getArtifactId(), equalTo( a ) ); + assertThat( var.getType(), equalTo( "pom" ) ); + assertThat( var.getClassifier(), nullValue() ); + } + @Test public void identicalVersionlessArtifactsAreNotEqualWhenOptionalFlagsDiffer() { From e33f54a6186a59831ded2d281cf3831ef2087419 Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 9 Jun 2014 14:28:37 -0500 Subject: [PATCH 017/240] [maven-release-plugin] prepare release atlas-parent-0.13.1 --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index cf04af74..cf085315 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.1-SNAPSHOT + 0.13.1 atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 15c44bd9..a80e1dfe 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.1-SNAPSHOT + 0.13.1 atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index b5dec598..74f1dd80 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.1-SNAPSHOT + 0.13.1 atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index ed8dc521..77ecc288 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.1-SNAPSHOT + 0.13.1 atlas-identities diff --git a/pom.xml b/pom.xml index 2ba0b956..a71f5a4b 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.1-SNAPSHOT + 0.13.1 pom Atlas :: Maven Project-Graph :: Parent @@ -29,7 +29,7 @@ scm:git:http://jdcasey@github.com/jdcasey/atlas.git scm:git:git@github.com:jdcasey/atlas.git http://github.com/jdcasey/atlas - HEAD + atlas-parent-0.13.1 @@ -37,17 +37,17 @@ org.commonjava.maven.atlas atlas-identities - 0.13.1-SNAPSHOT + 0.13.1 org.commonjava.maven.atlas atlas-relationships-api - 0.13.1-SNAPSHOT + 0.13.1 org.commonjava.maven.atlas atlas-drivers-tck - 0.13.1-SNAPSHOT + 0.13.1 test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 7c2f21c3..37946782 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.1-SNAPSHOT + 0.13.1 atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index b6847e20..e76fcef1 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.1-SNAPSHOT + 0.13.1 atlas-drivers-tck From 579aef3fe52f74297038e1fb7eec2d1974c6a3bb Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 9 Jun 2014 14:28:40 -0500 Subject: [PATCH 018/240] [maven-release-plugin] prepare for next development iteration --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index cf085315..d7c2e6eb 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.1 + 0.13.2-SNAPSHOT atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index a80e1dfe..ae3035cb 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.1 + 0.13.2-SNAPSHOT atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 74f1dd80..1f9dab96 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.1 + 0.13.2-SNAPSHOT atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index 77ecc288..a6ef6496 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.1 + 0.13.2-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index a71f5a4b..f65df10d 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.1 + 0.13.2-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -29,7 +29,7 @@ scm:git:http://jdcasey@github.com/jdcasey/atlas.git scm:git:git@github.com:jdcasey/atlas.git http://github.com/jdcasey/atlas - atlas-parent-0.13.1 + HEAD @@ -37,17 +37,17 @@ org.commonjava.maven.atlas atlas-identities - 0.13.1 + 0.13.2-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.13.1 + 0.13.2-SNAPSHOT org.commonjava.maven.atlas atlas-drivers-tck - 0.13.1 + 0.13.2-SNAPSHOT test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 37946782..c1b09158 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.1 + 0.13.2-SNAPSHOT atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index e76fcef1..8ead63e1 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.1 + 0.13.2-SNAPSHOT atlas-drivers-tck From 79572338c58fb30016fc3b3550486169dc258c6b Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 25 Jun 2014 10:17:58 -0500 Subject: [PATCH 019/240] Fixing #15. Store project errors as strings that look much like what error.printStackTrace() would look. Also, take a stab at synchroinzing access to index results for looking up relationships... The second comment in jdcasey/galley#13 seems like it might be a race condition related to the indexes. --- .../graph/spi/jung/JungGraphConnection.java | 6 +-- .../spi/neo4j/FileNeo4JGraphConnection.java | 38 +++++++--------- .../atlas/graph/spi/neo4j/io/Conversions.java | 44 ++----------------- .../maven/atlas/graph/RelationshipGraph.java | 14 +++--- .../spi/RelationshipGraphConnection.java | 4 +- 5 files changed, 35 insertions(+), 71 deletions(-) diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java index b36c5f28..b2f42210 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java @@ -75,7 +75,7 @@ public class JungGraphConnection private final Set cycles = new HashSet(); - private final Map errors = new HashMap(); + private final Map errors = new HashMap(); private final String workspaceId; @@ -1173,14 +1173,14 @@ public String getWorkspaceId() } @Override - public void addProjectError( final ProjectVersionRef ref, final Throwable error ) + public void addProjectError( final ProjectVersionRef ref, final String error ) throws RelationshipGraphConnectionException { errors.put( ref, error ); } @Override - public Throwable getProjectError( final ProjectVersionRef ref ) + public String getProjectError( final ProjectVersionRef ref ) { return errors.get( ref ); } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java index c6e29fb7..f91496d5 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java @@ -424,7 +424,10 @@ public Collection> getAllRelationships( final ViewParams final IndexHits hits = graph.index() .forRelationships( ALL_RELATIONSHIPS ) .query( RELATIONSHIP_ID, "*" ); - return convertToRelationships( hits, cache ); + synchronized ( hits ) + { + return convertToRelationships( hits, cache ); + } } @Override @@ -593,10 +596,8 @@ private Map> addRelationshipsInternal( final Projec .forRelationships( ALL_RELATIONSHIPS ); final String relId = id( rel ); - final IndexHits relHits = relIdx.get( RELATIONSHIP_ID, relId ); - - Relationship relationship; - if ( relHits.size() < 1 ) + Relationship relationship = getRelationship( relId ); + if ( relationship == null ) { final Node from = nodes[0]; @@ -660,7 +661,6 @@ private Map> addRelationshipsInternal( final Projec } else { - relationship = relHits.next(); logger.debug( "== {} ({})", relationship, toProjectRelationship( relationship, cache ) ); addToURISetProperty( rel.getSources(), SOURCE_URI, relationship ); @@ -777,15 +777,12 @@ private Relationship select( final Relationship old, final ViewParams params, fi if ( selected != oldRel ) { - final RelationshipIndex relIdx = graph.index() - .forRelationships( ALL_RELATIONSHIPS ); - // logger.info( "Checking for existing DB relationship for: {}", selected ); final String selId = id( selected ); - IndexHits hits = relIdx.get( RELATIONSHIP_ID, selId ); - if ( hits.hasNext() ) + Relationship result = getRelationship( selId ); + if ( result != null ) { - return hits.next(); + return result; } logger.info( "Creating ad-hoc db relationship for selection: {} (replacing: {})", selected, oldRel ); @@ -796,12 +793,9 @@ private Relationship select( final Relationship old, final ViewParams params, fi final Transaction tx = graph.beginTx(); try { - Relationship result = null; - hits = relIdx.get( RELATIONSHIP_ID, selId ); - if ( hits.hasNext() ) + result = getRelationship( selId ); + if ( result != null ) { - result = hits.next(); - logger.debug( "Adding relationship {} to selections index", result ); Conversions.setSelection( old.getId(), result.getId(), paramsNode ); @@ -1042,8 +1036,10 @@ Relationship getRelationship( final String relId ) .forRelationships( ALL_RELATIONSHIPS ); final IndexHits hits = idx.get( RELATIONSHIP_ID, relId ); - - return hits.hasNext() ? hits.next() : null; + synchronized ( hits ) + { + return hits.hasNext() ? hits.next() : null; + } } private static final int SHUTDOWN_WAIT = 5; @@ -2410,7 +2406,7 @@ public String getWorkspaceId() } @Override - public void addProjectError( final ProjectVersionRef ref, final Throwable error ) + public void addProjectError( final ProjectVersionRef ref, final String error ) throws RelationshipGraphConnectionException { Node node = getNode( ref ); @@ -2423,7 +2419,7 @@ public void addProjectError( final ProjectVersionRef ref, final Throwable error } @Override - public Throwable getProjectError( final ProjectVersionRef ref ) + public String getProjectError( final ProjectVersionRef ref ) { final Node node = getNode( ref ); if ( node == null ) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java index 9b072440..04c60343 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java @@ -1133,55 +1133,19 @@ public static void removeSelectionByOrigin( final long originRid, final Node vie } } - public static void storeError( final Node node, final Throwable error ) + public static void storeError( final Node node, final String error ) { - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = null; - try - { - oos = new ObjectOutputStream( baos ); - oos.writeObject( error ); - - node.setProperty( PROJECT_ERROR, baos.toByteArray() ); - } - catch ( final IOException e ) - { - throw new IllegalStateException( "Cannot construct ObjectOutputStream to wrap ByteArrayOutputStream!", e ); - } - finally - { - IOUtils.closeQuietly( oos ); - } + node.setProperty( PROJECT_ERROR, error ); } - public static Throwable getError( final Node node ) + public static String getError( final Node node ) { if ( !node.hasProperty( PROJECT_ERROR ) ) { return null; } - final byte[] data = (byte[]) node.getProperty( PROJECT_ERROR ); - ObjectInputStream ois = null; - try - { - ois = new ObjectInputStream( new ByteArrayInputStream( data ) ); - return (Throwable) ois.readObject(); - } - catch ( final IOException e ) - { - throw new IllegalStateException( - "Cannot construct ObjectInputStream to wrap ByteArrayInputStream containing " - + data.length + " bytes!", e ); - } - catch ( final ClassNotFoundException e ) - { - throw new IllegalStateException( "Cannot read Throwable. A class was missing: " + e.getMessage(), e ); - } - finally - { - IOUtils.closeQuietly( ois ); - } + return (String) node.getProperty( PROJECT_ERROR ); } } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java index 812d06fb..e6c0107d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java @@ -1,5 +1,7 @@ package org.commonjava.maven.atlas.graph; +import static org.apache.commons.lang.StringUtils.join; + import java.net.URI; import java.util.ArrayList; import java.util.Arrays; @@ -64,7 +66,9 @@ public ViewParams getParams() public void storeProjectError( final ProjectVersionRef ref, final Throwable error ) throws RelationshipGraphException { - getConnectionInternal().addProjectError( ref, error ); + getConnectionInternal().addProjectError( ref, + String.format( "%s\n%s", error.getMessage(), + join( error.getStackTrace(), "\n " ) ) ); for ( final RelationshipGraphListener listener : listeners ) { @@ -72,7 +76,7 @@ public void storeProjectError( final ProjectVersionRef ref, final Throwable erro } } - public Throwable getProjectError( final ProjectVersionRef ref ) + public String getProjectError( final ProjectVersionRef ref ) { return getConnectionInternal().getProjectError( ref ); } @@ -679,13 +683,13 @@ public void printStats() getConnectionInternal().printStats(); } - public Map getAllProjectErrors() + public Map getAllProjectErrors() { - final Map errors = new HashMap(); + final Map errors = new HashMap(); final Set projects = getConnectionInternal().getAllProjects( params ); for ( final ProjectVersionRef ref : projects ) { - final Throwable error = getConnectionInternal().getProjectError( ref ); + final String error = getConnectionInternal().getProjectError( ref ); if ( error != null ) { errors.put( ref, error ); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java index a037fdc5..8a43ab30 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java @@ -59,7 +59,7 @@ void deleteRelationshipsDeclaredBy( ProjectVersionRef root ) Set> addRelationships( ProjectRelationship... rel ) throws RelationshipGraphConnectionException; - void addProjectError( ProjectVersionRef ref, Throwable error ) + void addProjectError( ProjectVersionRef ref, String error ) throws RelationshipGraphConnectionException; void clearProjectError( ProjectVersionRef ref ) @@ -82,7 +82,7 @@ void reindex( final ProjectVersionRef ref ) * ################################################ */ - Throwable getProjectError( ProjectVersionRef ref ); + String getProjectError( ProjectVersionRef ref ); Collection> getRelationshipsDeclaredBy( ViewParams params, ProjectVersionRef root ); From 6dbe3042e0b37b97bfde4b2b05390841b94195e6 Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 25 Jun 2014 10:38:55 -0500 Subject: [PATCH 020/240] [maven-release-plugin] prepare release atlas-parent-0.13.2 --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index d7c2e6eb..470cfd4f 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.2-SNAPSHOT + 0.13.2 atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index ae3035cb..0ddc28f8 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.2-SNAPSHOT + 0.13.2 atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 1f9dab96..fffaa99b 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.2-SNAPSHOT + 0.13.2 atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index a6ef6496..05c1e0d5 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.2-SNAPSHOT + 0.13.2 atlas-identities diff --git a/pom.xml b/pom.xml index f65df10d..cbb701de 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.2-SNAPSHOT + 0.13.2 pom Atlas :: Maven Project-Graph :: Parent @@ -29,7 +29,7 @@ scm:git:http://jdcasey@github.com/jdcasey/atlas.git scm:git:git@github.com:jdcasey/atlas.git http://github.com/jdcasey/atlas - HEAD + atlas-parent-0.13.2 @@ -37,17 +37,17 @@ org.commonjava.maven.atlas atlas-identities - 0.13.2-SNAPSHOT + 0.13.2 org.commonjava.maven.atlas atlas-relationships-api - 0.13.2-SNAPSHOT + 0.13.2 org.commonjava.maven.atlas atlas-drivers-tck - 0.13.2-SNAPSHOT + 0.13.2 test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index c1b09158..d7aaa9da 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.2-SNAPSHOT + 0.13.2 atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 8ead63e1..4d06395e 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.2-SNAPSHOT + 0.13.2 atlas-drivers-tck From dddb4e20dbd941a5bcfffb2ea8c4b197df59f9ae Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 25 Jun 2014 10:38:58 -0500 Subject: [PATCH 021/240] [maven-release-plugin] prepare for next development iteration --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index 470cfd4f..4ad2ea43 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.2 + 0.13.3-SNAPSHOT atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 0ddc28f8..1817d746 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.2 + 0.13.3-SNAPSHOT atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index fffaa99b..3567900d 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.2 + 0.13.3-SNAPSHOT atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index 05c1e0d5..9e3599bf 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.2 + 0.13.3-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index cbb701de..69d7f8f4 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.2 + 0.13.3-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -29,7 +29,7 @@ scm:git:http://jdcasey@github.com/jdcasey/atlas.git scm:git:git@github.com:jdcasey/atlas.git http://github.com/jdcasey/atlas - atlas-parent-0.13.2 + HEAD @@ -37,17 +37,17 @@ org.commonjava.maven.atlas atlas-identities - 0.13.2 + 0.13.3-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.13.2 + 0.13.3-SNAPSHOT org.commonjava.maven.atlas atlas-drivers-tck - 0.13.2 + 0.13.3-SNAPSHOT test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index d7aaa9da..edd73aea 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.2 + 0.13.3-SNAPSHOT atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 4d06395e..de02f7a2 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.2 + 0.13.3-SNAPSHOT atlas-drivers-tck From 5fafec7ba866f41a322e1157692d0a376eb7a5fa Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Thu, 17 Jul 2014 01:14:30 +0200 Subject: [PATCH 022/240] Make addProjectError transactional Without that it threw org.neo4j.graphdb.NotInTransactionException when trying to store a project error. --- .../spi/neo4j/FileNeo4JGraphConnection.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java index f91496d5..77e8d0cf 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java @@ -2409,13 +2409,23 @@ public String getWorkspaceId() public void addProjectError( final ProjectVersionRef ref, final String error ) throws RelationshipGraphConnectionException { - Node node = getNode( ref ); - if ( node == null ) + final Transaction tx = graph.beginTx(); + try + { + Node node = getNode( ref ); + if ( node == null ) + { + node = newProjectNode( ref ); + } + + Conversions.storeError( node, error ); + + tx.success(); + } + finally { - node = newProjectNode( ref ); + tx.finish(); } - - Conversions.storeError( node, error ); } @Override From 3a834f72aac253b395757a7b7e4adaf87fa2030c Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Fri, 11 Jul 2014 16:56:47 +0200 Subject: [PATCH 023/240] Allow passing of null into ViewParams.Builder.withSelections() --- .../maven/atlas/graph/ViewParams.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java index a6bb0c19..84fd630c 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java @@ -142,7 +142,7 @@ public ViewParams( final String workspaceId, final Map activePomLocations, final Set activeSources, final Map selections, final Map properties, - final Set roots ) + final Collection roots ) { this.workspaceId = workspaceId; this.filter = filter; @@ -499,10 +499,25 @@ public Builder withMutator( final GraphMutator mutator ) return this; } + /** + * Adds selected versions into selections map. To work properly keys + * must be instances of {@link ProjectRef} or of the same class as the + * one used in {@link ViewParams#getSelection(ProjectRef)} and + * {@link ViewParams#hasSelection(ProjectRef)}. + * + * @param selections + * map of {@link ProjectRef} to {@link ProjectVersionRef}, + * can be {@code null} indicating that no selections were + * done + * @return this instance for method chaining + */ public Builder withSelections( final Map selections ) { this.selections.clear(); - this.selections.putAll( selections ); + if ( selections != null ) + { + this.selections.putAll( selections ); + } return this; } From 400e31330f4d2e3f3e8ffa1e3ee1e5c41da09726 Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 21 Jul 2014 16:55:36 -0500 Subject: [PATCH 024/240] [maven-release-plugin] prepare release atlas-parent-0.13.3 --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index 4ad2ea43..cdb3fca3 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.3-SNAPSHOT + 0.13.3 atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 1817d746..e5afafc0 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.3-SNAPSHOT + 0.13.3 atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 3567900d..35cf546b 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.3-SNAPSHOT + 0.13.3 atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index 9e3599bf..e804040c 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.3-SNAPSHOT + 0.13.3 atlas-identities diff --git a/pom.xml b/pom.xml index 69d7f8f4..28cdd35a 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.3-SNAPSHOT + 0.13.3 pom Atlas :: Maven Project-Graph :: Parent @@ -29,7 +29,7 @@ scm:git:http://jdcasey@github.com/jdcasey/atlas.git scm:git:git@github.com:jdcasey/atlas.git http://github.com/jdcasey/atlas - HEAD + atlas-parent-0.13.3 @@ -37,17 +37,17 @@ org.commonjava.maven.atlas atlas-identities - 0.13.3-SNAPSHOT + 0.13.3 org.commonjava.maven.atlas atlas-relationships-api - 0.13.3-SNAPSHOT + 0.13.3 org.commonjava.maven.atlas atlas-drivers-tck - 0.13.3-SNAPSHOT + 0.13.3 test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index edd73aea..9597d4f6 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.3-SNAPSHOT + 0.13.3 atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index de02f7a2..8ec7abf1 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.3-SNAPSHOT + 0.13.3 atlas-drivers-tck From df1d0113edabcdfdcd73e72555b31c7efcef1823 Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 21 Jul 2014 16:55:39 -0500 Subject: [PATCH 025/240] [maven-release-plugin] prepare for next development iteration --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index cdb3fca3..3ac1bf4b 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.3 + 0.13.4-SNAPSHOT atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index e5afafc0..e211fbf1 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.3 + 0.13.4-SNAPSHOT atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 35cf546b..26c492eb 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.3 + 0.13.4-SNAPSHOT atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index e804040c..6ad3e052 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.3 + 0.13.4-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index 28cdd35a..6e10da59 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.3 + 0.13.4-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -29,7 +29,7 @@ scm:git:http://jdcasey@github.com/jdcasey/atlas.git scm:git:git@github.com:jdcasey/atlas.git http://github.com/jdcasey/atlas - atlas-parent-0.13.3 + HEAD @@ -37,17 +37,17 @@ org.commonjava.maven.atlas atlas-identities - 0.13.3 + 0.13.4-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.13.3 + 0.13.4-SNAPSHOT org.commonjava.maven.atlas atlas-drivers-tck - 0.13.3 + 0.13.4-SNAPSHOT test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 9597d4f6..4a494379 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.3 + 0.13.4-SNAPSHOT atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 8ec7abf1..e897a08d 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.3 + 0.13.4-SNAPSHOT atlas-drivers-tck From 942345531d21901b636c8eb4d945373e281982fb Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Tue, 8 Jul 2014 10:07:45 +0200 Subject: [PATCH 026/240] Fix return value - invert check if DB exists after deletion --- .../maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java index dd99ee78..c3c7f562 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java @@ -100,7 +100,7 @@ public boolean delete( final String workspaceId ) try { FileUtils.forceDelete( db ); - result = db.exists(); + result = !db.exists(); } catch ( final IOException e ) { From 26ed321fa09d03d293275c97773b678925b824f9 Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Thu, 24 Jul 2014 18:44:52 +0200 Subject: [PATCH 027/240] Fix workspace deletion - remove a connection to a workspace from openconnections and close it - close conncetionCache from connectionCaches - remove from mapOfCaches properly --- .../spi/neo4j/FileNeo4jConnectionFactory.java | 8 ++++++++ .../atlas/graph/RelationshipGraphFactory.java | 20 +++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java index c3c7f562..05f14118 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java @@ -101,6 +101,14 @@ public boolean delete( final String workspaceId ) { FileUtils.forceDelete( db ); result = !db.exists(); + if ( result ) + { + FileNeo4JGraphConnection connection = openConnections.remove( workspaceId ); + if ( connection != null ) + { + connection.close(); + } + } } catch ( final IOException e ) { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java index 93dd9ceb..a8deaeed 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java @@ -60,7 +60,7 @@ public synchronized RelationshipGraph open( final ViewParams params, final boole final RelationshipGraphConnection connection = connectionManager.openConnection( params.getWorkspaceId(), create ); - cache = new ConnectionCache( timer, connectionCaches, connection ); + cache = new ConnectionCache( timer, connectionCaches, connection, wsid ); connectionCaches.put( wsid, cache ); logger.info( "Created new connection to graph db: {}\nVia:\n {}", params.getWorkspaceId(), @@ -106,7 +106,16 @@ public boolean deleteWorkspace( final String workspaceId ) throws RelationshipGraphException { checkClosed(); - return connectionManager.delete( workspaceId ); + boolean result = connectionManager.delete( workspaceId ); + if ( result ) + { + final ConnectionCache connectionCache = connectionCaches.get( workspaceId ); + if ( connectionCache != null ) + { + connectionCache.closeNow(); + } + } + return result; } private void checkClosed() @@ -149,6 +158,8 @@ private static final class ConnectionCache private RelationshipGraphConnection connection; + private final String wsid; + private final Map graphs = new HashMap(); private final Timer timer; @@ -158,17 +169,18 @@ private static final class ConnectionCache private final Map mapOfCaches; ConnectionCache( final Timer timer, final Map mapOfCaches, - final RelationshipGraphConnection connection ) + final RelationshipGraphConnection connection, final String wsid ) { this.timer = timer; this.mapOfCaches = mapOfCaches; this.connection = connection; + this.wsid = wsid; } public synchronized void closeNow() throws RelationshipGraphConnectionException { - mapOfCaches.remove( this ); + mapOfCaches.remove( wsid ); graphs.clear(); From 75200226556da42e029cb1488fcd0a80dcf2f966 Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 24 Jul 2014 15:31:42 -0500 Subject: [PATCH 028/240] Fixes #19 : Creating TCK/unit test in neo4j to check that open-populate-close-delete-open doesn't cause an error, and fixing connection-closing logic in FileNeo4jConnectionFactory to fix this problem (was throwing a lucene RuntimeException). --- .../spi/neo4j/FileNeo4jConnectionFactory.java | 15 +- .../neo4j/RelationshipGraphFactoryTest.java | 20 +++ .../atlas/tck/graph/AbstractSPI_TCK.java | 11 ++ .../graph/RelationshipGraphFactoryTCK.java | 129 ++++++++++++++++++ .../atlas/tck/graph/RelationshipGraphTCK.java | 11 -- 5 files changed, 166 insertions(+), 20 deletions(-) create mode 100644 drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphFactoryTest.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphFactoryTCK.java diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java index 05f14118..d3212b0b 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java @@ -19,7 +19,6 @@ public class FileNeo4jConnectionFactory implements RelationshipGraphConnectionFactory { - private final Map openConnections = new HashMap(); @@ -96,19 +95,17 @@ public boolean delete( final String workspaceId ) return false; } + final FileNeo4JGraphConnection connection = openConnections.remove( workspaceId ); + if ( connection != null ) + { + connection.close(); + } + boolean result = false; try { FileUtils.forceDelete( db ); result = !db.exists(); - if ( result ) - { - FileNeo4JGraphConnection connection = openConnections.remove( workspaceId ); - if ( connection != null ) - { - connection.close(); - } - } } catch ( final IOException e ) { diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphFactoryTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphFactoryTest.java new file mode 100644 index 00000000..02657739 --- /dev/null +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphFactoryTest.java @@ -0,0 +1,20 @@ +package org.commonjava.maven.atlas.graph.spi.neo4j; + +import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; +import org.commonjava.maven.atlas.graph.spi.neo4j.fixture.FileConnectionFixture; +import org.commonjava.maven.atlas.tck.graph.RelationshipGraphFactoryTCK; +import org.junit.Rule; + +public class RelationshipGraphFactoryTest + extends RelationshipGraphFactoryTCK +{ + @Rule + public FileConnectionFixture fixture = new FileConnectionFixture(); + + @Override + protected synchronized RelationshipGraphConnectionFactory connectionFactory() + throws Exception + { + return fixture.connectionFactory(); + } +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java index eca812d0..e7affce2 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java @@ -12,12 +12,14 @@ import java.net.URI; import java.net.URISyntaxException; +import java.util.Collections; import java.util.Date; import org.commonjava.maven.atlas.graph.RelationshipGraph; import org.commonjava.maven.atlas.graph.RelationshipGraphFactory; import org.commonjava.maven.atlas.graph.ViewParams; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; +import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; import org.junit.After; import org.junit.Before; @@ -70,6 +72,15 @@ protected final RelationshipGraphFactory graphFactory() return graphFactory; } + protected final RelationshipGraph openGraph( final ViewParams params, final boolean create ) + throws Exception + { + final RelationshipGraph graph = + graphFactory().open( new ViewParams.Builder( params ).withActiveSources( Collections.singleton( RelationshipUtils.ANY_SOURCE_URI ) ) + .build(), create ); + return graph; + } + private long start; @Before diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphFactoryTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphFactoryTCK.java new file mode 100644 index 00000000..cfc82069 --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphFactoryTCK.java @@ -0,0 +1,129 @@ +package org.commonjava.maven.atlas.tck.graph; + +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertThat; + +import java.net.URI; +import java.util.List; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.RelationshipGraphException; +import org.commonjava.maven.atlas.graph.ViewParams; +import org.commonjava.maven.atlas.graph.rel.ParentRelationship; +import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; +import org.commonjava.maven.atlas.graph.traverse.RelationshipGraphTraversal; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.junit.Test; + +public abstract class RelationshipGraphFactoryTCK + extends AbstractSPI_TCK +{ + + @Test + public void openStoreDeleteAndReopen() + throws Exception + { + final ProjectVersionRef r = new ProjectVersionRef( "org.test", "root", "1" ); + final ProjectVersionRef p = new ProjectVersionRef( "org.test", "parent", "1.0" ); + final ProjectVersionRef c = new ProjectVersionRef( "org.test", "child", "1.0" ); + + final URI source = sourceURI(); + + final String wsid = newWorkspaceId(); + + final RelationshipGraph child = openGraph( new ViewParams( wsid, c ), true ); + + child.storeRelationships( new ParentRelationship( source, c, p ) ); + + openGraph( new ViewParams( wsid, p ), true ).storeRelationships( new ParentRelationship( source, p, r ) ); + + RelationshipGraph graph = openGraph( new ViewParams( wsid, r ), true ); + graph.storeRelationships( new ParentRelationship( source, r ) ); + + // final Thread t = new Thread( new DelayTraverseRunnable( graph ) ); + // t.setDaemon( true ); + // t.start(); + + try + { + graphFactory().deleteWorkspace( wsid ); + + graph = openGraph( new ViewParams( wsid, c ), true ); + assertThat( graph, notNullValue() ); + + graph.storeRelationships( new ParentRelationship( source, c, p ) ); + } + finally + { + // t.interrupt(); + } + } + + public static final class DelayTraverseRunnable + implements Runnable + { + private final RelationshipGraph graph; + + DelayTraverseRunnable( final RelationshipGraph graph ) + { + this.graph = graph; + } + + @Override + public void run() + { + try + { + graph.traverse( new RelationshipGraphTraversal() + { + @Override + public boolean traverseEdge( final ProjectRelationship relationship, + final List> path ) + { + try + { + Thread.sleep( 2000 ); + } + catch ( final InterruptedException e ) + { + return false; + } + return true; + } + + @Override + public void startTraverse( final RelationshipGraph graph ) + throws RelationshipGraphConnectionException + { + } + + @Override + public boolean preCheck( final ProjectRelationship relationship, + final List> path ) + { + return true; + } + + @Override + public void endTraverse( final RelationshipGraph graph ) + throws RelationshipGraphConnectionException + { + } + + @Override + public void edgeTraversed( final ProjectRelationship relationship, + final List> path ) + { + } + } ); + } + catch ( final RelationshipGraphException e ) + { + e.printStackTrace(); + } + } + + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphTCK.java index 4f637c90..e03424e5 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphTCK.java @@ -16,7 +16,6 @@ import static org.junit.Assert.assertThat; import java.net.URI; -import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -30,7 +29,6 @@ import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.graph.traverse.AncestryTraversal; import org.commonjava.maven.atlas.graph.traverse.TraversalType; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.DependencyScope; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; import org.junit.Test; @@ -161,13 +159,4 @@ public void connectThreeGraphsWithParentInterrelationships_WrongOrder() assertThat( iterator.next(), equalTo( r ) ); } - private RelationshipGraph openGraph( final ViewParams params, final boolean create ) - throws Exception - { - final RelationshipGraph graph = - graphFactory().open( new ViewParams.Builder( params ).withActiveSources( Collections.singleton( RelationshipUtils.ANY_SOURCE_URI ) ) - .build(), create ); - return graph; - } - } From ba70709a2d0a459ecddd6a44510bd7df7decb201 Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Mon, 28 Jul 2014 17:11:47 +0200 Subject: [PATCH 029/240] Remove the connection cache even though the workspace deletion failed Also make the connection close conditional only when it is not closed already. --- .../graph/spi/jung/JungGraphConnection.java | 11 +++++++- .../spi/neo4j/FileNeo4JGraphConnection.java | 6 +++++ .../atlas/graph/RelationshipGraphFactory.java | 26 ++++++++++++++++--- .../spi/RelationshipGraphConnection.java | 2 ++ 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java index b2f42210..e6d47865 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java @@ -59,6 +59,8 @@ public class JungGraphConnection { private final Logger logger = LoggerFactory.getLogger( getClass() ); + private boolean closed = false; + private DirectedGraph> graph = new DirectedSparseMultigraph>(); @@ -548,7 +550,14 @@ public void restrictRelationshipMembership( final Collection> getDirectRelationshipsTo( ViewParams params, Project void close() throws RelationshipGraphConnectionException; + boolean isClosed(); + String getWorkspaceId(); } From f58366ec1e9b30c37c5ecd7dced6aec4971a26b7 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 29 Jul 2014 12:13:18 -0500 Subject: [PATCH 030/240] make TypeAndClassifier serializable --- .../commonjava/maven/atlas/ident/ref/TypeAndClassifier.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/TypeAndClassifier.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/TypeAndClassifier.java index b6df3afc..47a49b22 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/TypeAndClassifier.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/TypeAndClassifier.java @@ -12,8 +12,13 @@ import static org.apache.commons.lang.StringUtils.isEmpty; +import java.io.Serializable; + public class TypeAndClassifier + implements Serializable { + private static final long serialVersionUID = 1L; + private final String type; private final String classifier; From e05b7e15778f1be2298c28f8c4d412208c15e2c1 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 29 Jul 2014 15:37:37 -0500 Subject: [PATCH 031/240] Adding new filter to exclude specific GAVs and their subgraphs. --- .../atlas/graph/filter/ExcludingFilter.java | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java new file mode 100644 index 00000000..e466b45b --- /dev/null +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java @@ -0,0 +1,87 @@ +package org.commonjava.maven.atlas.graph.filter; + +import static org.apache.commons.lang.StringUtils.join; + +import java.util.List; +import java.util.Set; + +import org.apache.commons.codec.digest.DigestUtils; +import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; + +public class ExcludingFilter + implements ProjectRelationshipFilter +{ + + private static final long serialVersionUID = 1L; + + private final List excludedSubgraphs; + + private final ProjectRelationshipFilter filter; + + private transient String longId; + + private transient String shortId; + + public ExcludingFilter( final List excludedSubgraphs, final ProjectRelationshipFilter filter ) + { + this.excludedSubgraphs = excludedSubgraphs; + this.filter = filter; + } + + @Override + public boolean accept( final ProjectRelationship rel ) + { + final ProjectVersionRef target = rel.getTarget() + .asProjectVersionRef(); + return !excludedSubgraphs.contains( target ); + } + + @Override + public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) + { + return this; + } + + @Override + public String getLongId() + { + if ( longId == null ) + { + longId = + "Excluded-Subgraphs [" + join( excludedSubgraphs, "\n" ) + "], delegating to: " + filter.getLongId(); + } + return longId; + } + + @Override + public String getCondensedId() + { + if ( shortId == null ) + { + shortId = DigestUtils.shaHex( getLongId() ); + } + + return shortId; + } + + @Override + public boolean includeManagedRelationships() + { + return filter.includeManagedRelationships(); + } + + @Override + public boolean includeConcreteRelationships() + { + return filter.includeConcreteRelationships(); + } + + @Override + public Set getAllowedTypes() + { + return filter.getAllowedTypes(); + } + +} From 47d0625b59714a1001ac78a72d08849b28fa4a1c Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 7 Aug 2014 16:20:44 -0500 Subject: [PATCH 032/240] [maven-release-plugin] prepare release atlas-parent-0.13.4 --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index 3ac1bf4b..5e54e6ff 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.4-SNAPSHOT + 0.13.4 atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index e211fbf1..f4720dbb 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.4-SNAPSHOT + 0.13.4 atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 26c492eb..491050a9 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.4-SNAPSHOT + 0.13.4 atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index 6ad3e052..f98b3864 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.4-SNAPSHOT + 0.13.4 atlas-identities diff --git a/pom.xml b/pom.xml index 6e10da59..27a8eb00 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.4-SNAPSHOT + 0.13.4 pom Atlas :: Maven Project-Graph :: Parent @@ -29,7 +29,7 @@ scm:git:http://jdcasey@github.com/jdcasey/atlas.git scm:git:git@github.com:jdcasey/atlas.git http://github.com/jdcasey/atlas - HEAD + atlas-parent-0.13.4 @@ -37,17 +37,17 @@ org.commonjava.maven.atlas atlas-identities - 0.13.4-SNAPSHOT + 0.13.4 org.commonjava.maven.atlas atlas-relationships-api - 0.13.4-SNAPSHOT + 0.13.4 org.commonjava.maven.atlas atlas-drivers-tck - 0.13.4-SNAPSHOT + 0.13.4 test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 4a494379..97d9fb9d 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.4-SNAPSHOT + 0.13.4 atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index e897a08d..1ec63137 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.4-SNAPSHOT + 0.13.4 atlas-drivers-tck From e4e84f2f5f0b0227bdaf69fd802c95931c8a71ff Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 7 Aug 2014 16:20:46 -0500 Subject: [PATCH 033/240] [maven-release-plugin] prepare for next development iteration --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index 5e54e6ff..96d2da97 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.4 + 0.13.5-SNAPSHOT atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index f4720dbb..30ff198d 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.4 + 0.13.5-SNAPSHOT atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 491050a9..4ea67b4f 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.4 + 0.13.5-SNAPSHOT atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index f98b3864..abc14945 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.4 + 0.13.5-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index 27a8eb00..66230696 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.4 + 0.13.5-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -29,7 +29,7 @@ scm:git:http://jdcasey@github.com/jdcasey/atlas.git scm:git:git@github.com:jdcasey/atlas.git http://github.com/jdcasey/atlas - atlas-parent-0.13.4 + HEAD @@ -37,17 +37,17 @@ org.commonjava.maven.atlas atlas-identities - 0.13.4 + 0.13.5-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.13.4 + 0.13.5-SNAPSHOT org.commonjava.maven.atlas atlas-drivers-tck - 0.13.4 + 0.13.5-SNAPSHOT test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 97d9fb9d..acfe1787 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.4 + 0.13.5-SNAPSHOT atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 1ec63137..10aed41b 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.4 + 0.13.5-SNAPSHOT atlas-drivers-tck From f1d32d24c1da0124fdf1c79e4a54904747c1b6ad Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 14 Aug 2014 15:21:21 -0500 Subject: [PATCH 034/240] be a little more careful to catch common failure cases when parsing ArtifactPathInfo --- .../org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java index 328ad5de..1b529bb3 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java @@ -38,7 +38,7 @@ public class ArtifactPathInfo public static ArtifactPathInfo parse( final String path ) { - if ( path == null ) + if ( path == null || path.length() < 1 ) { return null; } From ef59a4db6b21dff44007e7ba9b3b53d87f19cd9a Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 21 Aug 2014 17:15:45 -0500 Subject: [PATCH 035/240] sort local snapshots to the end of the line, which is consistent with the most recent non-local snapshot sorting. --- .../atlas/ident/version/part/SnapshotPart.java | 4 ++-- .../atlas/ident/version/part/SnapshotPartTest.java | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPart.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPart.java index 0b81736b..f084b2cb 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPart.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPart.java @@ -112,11 +112,11 @@ public int compareTo( final VersionPart o ) } else if ( isLocalSnapshot() && !oSnap.isLocalSnapshot() ) { - return -1; + return 1; } else if ( !isLocalSnapshot() && oSnap.isLocalSnapshot() ) { - return 1; + return -1; } return 0; diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPartTest.java b/identities/src/test/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPartTest.java index 4bbe3906..2718673d 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPartTest.java +++ b/identities/src/test/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPartTest.java @@ -3,6 +3,7 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; +import org.commonjava.maven.atlas.ident.util.SnapshotUtils; import org.junit.Test; public class SnapshotPartTest @@ -20,4 +21,16 @@ public void compareTwoRemoteSnapshotsWithDifferentTimestamps_ParsedFromLiterals( assertThat( result, equalTo( 1 ) ); } + @Test + public void compareLocalVsRemoteSnapshot_LocalSortsLastAsMostRecent() + throws Exception + { + final SnapshotPart first = new SnapshotPart( SnapshotUtils.LOCAL_SNAPSHOT_VERSION_PART ); + final SnapshotPart second = new SnapshotPart( "20140604.124350-1" ); + + final int result = first.compareTo( second ); + + assertThat( result, equalTo( 1 ) ); + } + } From 9cfa9cd770b22fb38ccb5f46483cb6ba17b34e35 Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 22 Aug 2014 17:09:00 -0500 Subject: [PATCH 036/240] [maven-release-plugin] prepare release atlas-parent-0.13.5 --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index 96d2da97..2eaefc4a 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.5-SNAPSHOT + 0.13.5 atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 30ff198d..76a27538 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.5-SNAPSHOT + 0.13.5 atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 4ea67b4f..2706c999 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.5-SNAPSHOT + 0.13.5 atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index abc14945..dde006fe 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.5-SNAPSHOT + 0.13.5 atlas-identities diff --git a/pom.xml b/pom.xml index 66230696..c1233ef0 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.5-SNAPSHOT + 0.13.5 pom Atlas :: Maven Project-Graph :: Parent @@ -29,7 +29,7 @@ scm:git:http://jdcasey@github.com/jdcasey/atlas.git scm:git:git@github.com:jdcasey/atlas.git http://github.com/jdcasey/atlas - HEAD + atlas-parent-0.13.5 @@ -37,17 +37,17 @@ org.commonjava.maven.atlas atlas-identities - 0.13.5-SNAPSHOT + 0.13.5 org.commonjava.maven.atlas atlas-relationships-api - 0.13.5-SNAPSHOT + 0.13.5 org.commonjava.maven.atlas atlas-drivers-tck - 0.13.5-SNAPSHOT + 0.13.5 test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index acfe1787..859e0e56 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.5-SNAPSHOT + 0.13.5 atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 10aed41b..9426d0e3 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.5-SNAPSHOT + 0.13.5 atlas-drivers-tck From d38fe3c7f2e85ef8e95a431c54d7651a2a00b23e Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 22 Aug 2014 17:09:02 -0500 Subject: [PATCH 037/240] [maven-release-plugin] prepare for next development iteration --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index 2eaefc4a..e0cc4510 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.5 + 0.13.6-SNAPSHOT atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 76a27538..eb8ad613 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.5 + 0.13.6-SNAPSHOT atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 2706c999..f23ec14f 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.5 + 0.13.6-SNAPSHOT atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index dde006fe..56a504dd 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.5 + 0.13.6-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index c1233ef0..a2b2a3a5 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.5 + 0.13.6-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -29,7 +29,7 @@ scm:git:http://jdcasey@github.com/jdcasey/atlas.git scm:git:git@github.com:jdcasey/atlas.git http://github.com/jdcasey/atlas - atlas-parent-0.13.5 + HEAD @@ -37,17 +37,17 @@ org.commonjava.maven.atlas atlas-identities - 0.13.5 + 0.13.6-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.13.5 + 0.13.6-SNAPSHOT org.commonjava.maven.atlas atlas-drivers-tck - 0.13.5 + 0.13.6-SNAPSHOT test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 859e0e56..f341cf90 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.5 + 0.13.6-SNAPSHOT atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 9426d0e3..d3d40d8a 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.5 + 0.13.6-SNAPSHOT atlas-drivers-tck From 4b1d3a791c232bb292faed7ad622455662ed9f7e Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 29 Aug 2014 13:21:22 -0500 Subject: [PATCH 038/240] Fixing date-formatting and -parsing problems in SnasphotUtils, and adding methods to help users do the right thing WRT generating snapshot dates (using UTC)...along with formatting/parsing lastUpdated-style date strings for metadata files. Fixing parsing in ArtifactPathInfo when it's a remote snapshot (which introduces two new capture groups for the regex). Adding convenience method getSnapshotPart() to SingleVersion. Adding tests for SnapshotUtils. --- .../atlas/ident/util/ArtifactPathInfo.java | 30 +++++++-- .../maven/atlas/ident/util/SnapshotUtils.java | 25 +++++++- .../atlas/ident/version/SingleVersion.java | 5 ++ .../atlas/ident/util/SnapshotUtilsTest.java | 62 +++++++++++++++++++ 4 files changed, 115 insertions(+), 7 deletions(-) create mode 100644 identities/src/test/java/org/commonjava/maven/atlas/ident/util/SnapshotUtilsTest.java diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java index 1b529bb3..89eb4ddb 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java @@ -28,13 +28,19 @@ public class ArtifactPathInfo private static final int ARTIFACT_ID_GROUP = 3; - private static final int FILE_GROUP = 5; + private static final int FILE_GROUP = 7; private static final int VERSION_GROUP = 8; - private static final int CLASSIFIER_GROUP = 12; + private static final int NON_REMOTE_SNAP_CLASSIFIER_GROUP = 12; - private static final int TYPE_GROUP = 14; + private static final int REMOTE_SNAP_CLASSIFIER_GROUP = 14; + + private static final int NON_REMOTE_SNAP_TYPE_GROUP = 14; + + private static final int REMOTE_SNAP_TYPE_GROUP = 16; + + private static final int REMOTE_SNAPSHOT_GROUP_COUNT = 16; public static ArtifactPathInfo parse( final String path ) { @@ -50,12 +56,26 @@ public static ArtifactPathInfo parse( final String path ) return null; } + final int groupCount = matcher.groupCount(); + final String g = matcher.group( GROUP_ID_GROUP ) .replace( '/', '.' ); final String a = matcher.group( ARTIFACT_ID_GROUP ); final String v = matcher.group( VERSION_GROUP ); - final String c = matcher.group( CLASSIFIER_GROUP ); - final String t = matcher.group( TYPE_GROUP ); + + final String c; + final String t; + if ( groupCount == REMOTE_SNAPSHOT_GROUP_COUNT ) + { + c = matcher.group( REMOTE_SNAP_CLASSIFIER_GROUP ); + t = matcher.group( REMOTE_SNAP_TYPE_GROUP ); + } + else + { + c = matcher.group( NON_REMOTE_SNAP_CLASSIFIER_GROUP ); + t = matcher.group( NON_REMOTE_SNAP_TYPE_GROUP ); + } + final String f = matcher.group( FILE_GROUP ); return new ArtifactPathInfo( g, a, v, c, t, f, path ); diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/SnapshotUtils.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/SnapshotUtils.java index 601d8c82..89fbdac9 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/SnapshotUtils.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/SnapshotUtils.java @@ -13,6 +13,7 @@ import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.Calendar; import java.util.Date; import java.util.TimeZone; import java.util.regex.Matcher; @@ -23,7 +24,9 @@ public class SnapshotUtils { - public static final String SNAPSHOT_TSTAMP_FORMAT = "yyyyMMdd.hhmmss"; + private static final String LAST_UPDATED_FORMAT = "yyyyMMddHHmmss"; + + public static final String SNAPSHOT_TSTAMP_FORMAT = "yyyyMMdd.HHmmss"; public static final String RAW_REMOTE_SNAPSHOT_PART_PATTERN = "([0-9]{8}.[0-9]{6})-([0-9]+)"; @@ -41,6 +44,13 @@ public static String generateSnapshotTimestamp( final Date d ) return getFormat().format( d ); } + public static Date getCurrentTimestamp() + { + final Calendar cal = Calendar.getInstance( TimeZone.getTimeZone( "UTC" ) ); + cal.set( Calendar.MILLISECOND, 0 ); + return cal.getTime(); + } + public static boolean isSnapshotVersion( final String literal ) { return literal.endsWith( LOCAL_SNAPSHOT_VERSION_PART ) || isRemoteSnapshotVersion( literal ); @@ -96,7 +106,7 @@ public static Date parseSnapshotTimestamp( final String tstamp ) private static DateFormat getFormat() { final SimpleDateFormat fmt = new SimpleDateFormat( SNAPSHOT_TSTAMP_FORMAT ); - fmt.setTimeZone( TimeZone.getTimeZone( "UTC" ) ); + // fmt.setTimeZone( TimeZone.getTimeZone( "UTC" ) ); return fmt; } @@ -116,4 +126,15 @@ else if ( version.endsWith( LOCAL_SNAPSHOT_VERSION_PART ) ) return part; } + public static String generateUpdateTimestamp( final Date d ) + { + return new SimpleDateFormat( LAST_UPDATED_FORMAT ).format( d ); + } + + public static Date parseUpdateTimestamp( final String tstamp ) + throws ParseException + { + return new SimpleDateFormat( LAST_UPDATED_FORMAT ).parse( tstamp ); + } + } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/SingleVersion.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/SingleVersion.java index f5ac07ef..ef89ade5 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/SingleVersion.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/SingleVersion.java @@ -473,4 +473,9 @@ else if ( !mine.isSilent() && !theirs.isSilent() ) return true; } + public SnapshotPart getSnapshotPart() + { + return isSnapshot() ? (SnapshotPart) getLastPart() : null; + } + } diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/util/SnapshotUtilsTest.java b/identities/src/test/java/org/commonjava/maven/atlas/ident/util/SnapshotUtilsTest.java new file mode 100644 index 00000000..4f0e0df2 --- /dev/null +++ b/identities/src/test/java/org/commonjava/maven/atlas/ident/util/SnapshotUtilsTest.java @@ -0,0 +1,62 @@ +package org.commonjava.maven.atlas.ident.util; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.text.ParseException; +import java.util.Date; + +import org.junit.Test; + +public class SnapshotUtilsTest +{ + + @Test + public void roundTripSnapshotTimestamp_StartWithString() + throws ParseException + { + final String tstamp = "20140828.225831"; + + System.out.println( tstamp ); + + final Date d = SnapshotUtils.parseSnapshotTimestamp( tstamp ); + + final String result = SnapshotUtils.generateSnapshotTimestamp( d ); + System.out.println( result ); + + assertThat( result, equalTo( tstamp ) ); + } + + @Test + public void roundTripSnapshotTimestamp() + throws ParseException + { + final Date d = SnapshotUtils.getCurrentTimestamp(); + + System.out.println( d ); + final String tstamp = SnapshotUtils.generateSnapshotTimestamp( d ); + System.out.println( tstamp ); + + final Date result = SnapshotUtils.parseSnapshotTimestamp( tstamp ); + System.out.println( result ); + + assertThat( result, equalTo( d ) ); + } + + @Test + public void roundTripLastUpdatedTimestamp() + throws ParseException + { + final Date d = SnapshotUtils.getCurrentTimestamp(); + + System.out.println( d ); + final String tstamp = SnapshotUtils.generateUpdateTimestamp( d ); + System.out.println( tstamp ); + + final Date result = SnapshotUtils.parseUpdateTimestamp( tstamp ); + System.out.println( result ); + + assertThat( result, equalTo( d ) ); + } + +} From 338bb62f8b04c26a5cb04a2eb0ab7cf1d3b29356 Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 18 Sep 2014 17:03:38 -0500 Subject: [PATCH 039/240] Removing json-serialization and re-adding commons-io dependency, the converting to jdk impl of ByteArrayOutputStream --- drivers/neo4j-embedded/pom.xml | 8 ++++---- .../maven/atlas/graph/spi/neo4j/io/Conversions.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index eb8ad613..93774b78 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -31,10 +31,6 @@ commons-codec commons-codec - - org.commonjava.web - json-serialization - com.google.code.gson gson @@ -43,6 +39,10 @@ org.slf4j log4j-over-slf4j + + commons-io + commons-io + diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java index 04c60343..934a770d 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java @@ -15,6 +15,7 @@ import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.UNKNOWN_SOURCE_URI; import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -31,7 +32,6 @@ import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.IOUtils; -import org.apache.commons.io.output.ByteArrayOutputStream; import org.commonjava.maven.atlas.graph.ViewParams; import org.commonjava.maven.atlas.graph.rel.BomRelationship; import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; From 1d0d6912c9d2759c964a523517dc9ac3397977a1 Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 18 Sep 2014 17:04:13 -0500 Subject: [PATCH 040/240] [maven-release-plugin] prepare release atlas-parent-0.13.6 --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index e0cc4510..f6deda6a 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.6-SNAPSHOT + 0.13.6 atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 93774b78..d43e11f0 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.6-SNAPSHOT + 0.13.6 atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index f23ec14f..9f85af3f 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.6-SNAPSHOT + 0.13.6 atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index 56a504dd..a19f6c14 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.6-SNAPSHOT + 0.13.6 atlas-identities diff --git a/pom.xml b/pom.xml index a2b2a3a5..a0af9193 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.6-SNAPSHOT + 0.13.6 pom Atlas :: Maven Project-Graph :: Parent @@ -29,7 +29,7 @@ scm:git:http://jdcasey@github.com/jdcasey/atlas.git scm:git:git@github.com:jdcasey/atlas.git http://github.com/jdcasey/atlas - HEAD + atlas-parent-0.13.6 @@ -37,17 +37,17 @@ org.commonjava.maven.atlas atlas-identities - 0.13.6-SNAPSHOT + 0.13.6 org.commonjava.maven.atlas atlas-relationships-api - 0.13.6-SNAPSHOT + 0.13.6 org.commonjava.maven.atlas atlas-drivers-tck - 0.13.6-SNAPSHOT + 0.13.6 test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index f341cf90..f11fdf6b 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.6-SNAPSHOT + 0.13.6 atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index d3d40d8a..2b1986e0 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.6-SNAPSHOT + 0.13.6 atlas-drivers-tck From 3eac5bd3917da5148ea4517daabb3f58a23f8df2 Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 18 Sep 2014 17:04:16 -0500 Subject: [PATCH 041/240] [maven-release-plugin] prepare for next development iteration --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index f6deda6a..8ffd3973 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.6 + 0.13.7-SNAPSHOT atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index d43e11f0..debe5e96 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.6 + 0.13.7-SNAPSHOT atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 9f85af3f..e4732c06 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.6 + 0.13.7-SNAPSHOT atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index a19f6c14..6e659642 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.6 + 0.13.7-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index a0af9193..02eb8d4b 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.6 + 0.13.7-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -29,7 +29,7 @@ scm:git:http://jdcasey@github.com/jdcasey/atlas.git scm:git:git@github.com:jdcasey/atlas.git http://github.com/jdcasey/atlas - atlas-parent-0.13.6 + HEAD @@ -37,17 +37,17 @@ org.commonjava.maven.atlas atlas-identities - 0.13.6 + 0.13.7-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.13.6 + 0.13.7-SNAPSHOT org.commonjava.maven.atlas atlas-drivers-tck - 0.13.6 + 0.13.7-SNAPSHOT test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index f11fdf6b..01edbb66 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.6 + 0.13.7-SNAPSHOT atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 2b1986e0..caf4058f 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.6 + 0.13.7-SNAPSHOT atlas-drivers-tck From ba019c1894ba59b4ce1faa4f1ad044858cf4fdda Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 24 Sep 2014 18:02:51 -0500 Subject: [PATCH 042/240] make cycle more friendly to json serialization --- .../atlas/graph/model/EProjectCycle.java | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java index 832a9c51..bcd76471 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java @@ -32,7 +32,7 @@ public class EProjectCycle private static final long serialVersionUID = 1L; - private List> participants = new ArrayList>(); + private List> relationships = new ArrayList>(); public static final class Builder { @@ -102,17 +102,17 @@ public boolean contains( final ProjectRelationship rel ) public EProjectCycle( final List> cycle ) { - this.participants = new ArrayList>( cycle ); + this.relationships = new ArrayList>( cycle ); } public boolean contains( final ProjectRelationship rel ) { - return participants.contains( rel ); + return relationships.contains( rel ); } public boolean contains( final ProjectVersionRef ref ) { - for ( final ProjectRelationship rel : participants ) + for ( final ProjectRelationship rel : relationships ) { if ( rel.getDeclaring() .equals( ref ) ) @@ -126,15 +126,15 @@ public boolean contains( final ProjectVersionRef ref ) public int indexOf( final ProjectRelationship rel ) { - return participants.indexOf( rel ); + return relationships.indexOf( rel ); } public int indexOf( final ProjectVersionRef ref ) { int targetIdx = -1; - for ( int i = 0; i < participants.size(); i++ ) + for ( int i = 0; i < relationships.size(); i++ ) { - final ProjectRelationship rel = participants.get( i ); + final ProjectRelationship rel = relationships.get( i ); if ( rel.getDeclaring() .equals( ref ) ) { @@ -158,7 +158,7 @@ public int indexOf( final ProjectVersionRef ref ) @Override public Iterator> iterator() { - return participants.iterator(); + return relationships.iterator(); } @Override @@ -173,13 +173,13 @@ public Collection> getAllRelationships() @Override public Collection> getExactAllRelationships() { - return new ArrayList>( participants ); + return new ArrayList>( relationships ); } public Set getAllParticipatingProjects() { final Set refs = new HashSet(); - for ( final ProjectRelationship rel : participants ) + for ( final ProjectRelationship rel : relationships ) { refs.add( rel.getDeclaring() ); refs.add( rel.getTarget() @@ -189,10 +189,20 @@ public Set getAllParticipatingProjects() return refs; } + public List> getRelationships() + { + return relationships; + } + + public void setRelationships( final List> relationships ) + { + this.relationships = relationships; + } + @Override public String toString() { - return String.format( "Project cycle: [%s]", join( participants, " -> " ) ); + return String.format( "Project cycle: [%s]", join( relationships, " -> " ) ); } @Override @@ -201,7 +211,7 @@ public int hashCode() final int prime = 31; int result = 1; - final List> sorted = new ArrayList>( participants ); + final List> sorted = new ArrayList>( relationships ); Collections.sort( sorted, RelationshipComparator.INSTANCE ); result = prime * result + sorted.hashCode(); @@ -224,9 +234,9 @@ public boolean equals( final Object obj ) return false; } final EProjectCycle other = (EProjectCycle) obj; - if ( participants == null ) + if ( relationships == null ) { - if ( other.participants != null ) + if ( other.relationships != null ) { return false; } @@ -234,8 +244,8 @@ public boolean equals( final Object obj ) else { - final Set> cycle = new HashSet>( this.participants ); - final Set> otherCycle = new HashSet>( other.participants ); + final Set> cycle = new HashSet>( this.relationships ); + final Set> otherCycle = new HashSet>( other.relationships ); for ( final ProjectRelationship rel : cycle ) { From a51c4297ca95598760cc64d2bae139ff88882883 Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 25 Sep 2014 12:37:08 -0500 Subject: [PATCH 043/240] [maven-release-plugin] prepare release atlas-parent-0.13.7 --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index 8ffd3973..6829ed5a 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.7-SNAPSHOT + 0.13.7 atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index debe5e96..2488fc72 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.7-SNAPSHOT + 0.13.7 atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index e4732c06..d49d977f 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.7-SNAPSHOT + 0.13.7 atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index 6e659642..2aa73ecd 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.7-SNAPSHOT + 0.13.7 atlas-identities diff --git a/pom.xml b/pom.xml index 02eb8d4b..c3db8c0f 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.7-SNAPSHOT + 0.13.7 pom Atlas :: Maven Project-Graph :: Parent @@ -29,7 +29,7 @@ scm:git:http://jdcasey@github.com/jdcasey/atlas.git scm:git:git@github.com:jdcasey/atlas.git http://github.com/jdcasey/atlas - HEAD + atlas-parent-0.13.7 @@ -37,17 +37,17 @@ org.commonjava.maven.atlas atlas-identities - 0.13.7-SNAPSHOT + 0.13.7 org.commonjava.maven.atlas atlas-relationships-api - 0.13.7-SNAPSHOT + 0.13.7 org.commonjava.maven.atlas atlas-drivers-tck - 0.13.7-SNAPSHOT + 0.13.7 test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 01edbb66..356b58d5 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.7-SNAPSHOT + 0.13.7 atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index caf4058f..8e7c37c5 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.7-SNAPSHOT + 0.13.7 atlas-drivers-tck From 268960811e3d51e6748e47d09e61445e275cb05c Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 25 Sep 2014 12:37:11 -0500 Subject: [PATCH 044/240] [maven-release-plugin] prepare for next development iteration --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index 6829ed5a..f78e1b5a 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.7 + 0.13.8-SNAPSHOT atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 2488fc72..b398aef6 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.7 + 0.13.8-SNAPSHOT atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index d49d977f..df21c0c2 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.7 + 0.13.8-SNAPSHOT atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index 2aa73ecd..c3305662 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.7 + 0.13.8-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index c3db8c0f..31fc42d7 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.7 + 0.13.8-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -29,7 +29,7 @@ scm:git:http://jdcasey@github.com/jdcasey/atlas.git scm:git:git@github.com:jdcasey/atlas.git http://github.com/jdcasey/atlas - atlas-parent-0.13.7 + HEAD @@ -37,17 +37,17 @@ org.commonjava.maven.atlas atlas-identities - 0.13.7 + 0.13.8-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.13.7 + 0.13.8-SNAPSHOT org.commonjava.maven.atlas atlas-drivers-tck - 0.13.7 + 0.13.8-SNAPSHOT test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 356b58d5..afc5dc87 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.7 + 0.13.8-SNAPSHOT atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 8e7c37c5..9b887ff4 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.7 + 0.13.8-SNAPSHOT atlas-drivers-tck From 6b45232d8eb97af9b60a8e76718082fe8dbf7d0c Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Mon, 27 Oct 2014 15:09:39 +0100 Subject: [PATCH 045/240] Avoid having one filter instance multiple times in child filters collection Usage of ArrayList in an aggregating filter allows having the same instance of a child filter multiple times without any effect. Problem with that is that it can create very rich filter tree that slows down getting child filters. Changing this led to reduction of the time needed to traverse a graph from tens of minutes (and still waiting for a result) to less than a second. --- .../maven/atlas/graph/filter/AbstractAggregatingFilter.java | 4 ++-- .../org/commonjava/maven/atlas/graph/filter/AndFilter.java | 2 +- .../org/commonjava/maven/atlas/graph/filter/OrFilter.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java index 1a88dc26..d73fe9aa 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java @@ -54,7 +54,7 @@ public final List getFilters() @Override public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) { - final List childFilters = new ArrayList(); + final Set childFilters = new HashSet(); for ( final ProjectRelationshipFilter filter : getFilters() ) { // if ( filter.accept( parent ) ) @@ -72,7 +72,7 @@ public ProjectRelationshipFilter getChildFilter( final ProjectRelationship pa return newChildFilter( childFilters ); } - protected abstract AbstractAggregatingFilter newChildFilter( List childFilters ); + protected abstract AbstractAggregatingFilter newChildFilter( Collection childFilters ); @Override public Iterator iterator() diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java index 8ded9e4e..6e77007f 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java @@ -51,7 +51,7 @@ public boolean accept( final ProjectRelationship rel ) } @Override - protected AbstractAggregatingFilter newChildFilter( final List childFilters ) + protected AbstractAggregatingFilter newChildFilter( final Collection childFilters ) { if ( !filtersEqual( childFilters ) ) { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java index 5a8d096c..b9c2edf1 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java @@ -54,7 +54,7 @@ public boolean accept( final ProjectRelationship rel ) } @Override - protected AbstractAggregatingFilter newChildFilter( final List childFilters ) + protected AbstractAggregatingFilter newChildFilter( final Collection childFilters ) { if ( !filtersEqual( childFilters ) ) { From 0623f602500e66a8a486e6634609c8d1e370f28a Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 27 Oct 2014 14:10:26 -0500 Subject: [PATCH 046/240] use LinkedHashSet to preserve order of sub-filters, since first-match (or first-rejection) can be used to either optimize or prefer certain filters. --- .../maven/atlas/graph/filter/AbstractAggregatingFilter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java index d73fe9aa..49a7fb57 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java @@ -15,6 +15,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -54,7 +55,7 @@ public final List getFilters() @Override public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) { - final Set childFilters = new HashSet(); + final Set childFilters = new LinkedHashSet(); for ( final ProjectRelationshipFilter filter : getFilters() ) { // if ( filter.accept( parent ) ) From 3ea03fa67d83c090112a9aa3cb84eac4fb6816b9 Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 29 Oct 2014 12:47:20 -0500 Subject: [PATCH 047/240] Removing create check from RelationshipGraphFactory to prevent blocking attempts to re-open non-cached, existing workspaces. Adding formatting fix-up to RelationshipGraphException (and RelationshipGraphConnectionException) to convert {} to %s, and also converting exceptions constructed in FileNeo4jConnectionFactory to use the native %s format. --- .../atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java | 6 +++--- .../maven/atlas/graph/RelationshipGraphException.java | 2 +- .../maven/atlas/graph/RelationshipGraphFactory.java | 5 ----- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java index d3212b0b..b6b80eae 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java @@ -41,12 +41,12 @@ public synchronized RelationshipGraphConnection openConnection( final String wor { if ( !create ) { - throw new RelationshipGraphConnectionException( "Workspace does not exist: {}.", workspaceId ); + throw new RelationshipGraphConnectionException( "Workspace does not exist: %s.", workspaceId ); } else if ( !db.mkdirs() ) { throw new RelationshipGraphConnectionException( - "Failed to create workspace directory for: {}. (dir: {})", + "Failed to create workspace directory for: %s. (dir: %s)", workspaceId, db ); } // @@ -139,7 +139,7 @@ public synchronized void close() if ( !failedClose.isEmpty() ) { - throw new RelationshipGraphConnectionException( "Failed to close: {}", new JoinString( ", ", failedClose ) ); + throw new RelationshipGraphConnectionException( "Failed to close: %s", new JoinString( ", ", failedClose ) ); } } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphException.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphException.java index f4f4020e..e2f36f6d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphException.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphException.java @@ -46,7 +46,7 @@ public String getMessage() { try { - final String formatted = String.format( message, params ); + final String formatted = String.format( message.replaceAll( "\\{\\}", "%s" ), params ); message = formatted; } catch ( final IllegalFormatException e ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java index 37a864bd..4c30fe9e 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java @@ -52,11 +52,6 @@ public synchronized RelationshipGraph open( final ViewParams params, final boole ConnectionCache cache = connectionCaches.get( wsid ); if ( cache == null || !cache.isOpen() ) { - if ( !create ) - { - throw new RelationshipGraphException( "No such workspace: %s", wsid ); - } - final RelationshipGraphConnection connection = connectionManager.openConnection( params.getWorkspaceId(), create ); From 1d4240471542aa0e1251edb881df94896639f4c9 Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Fri, 16 Jan 2015 19:21:14 +0100 Subject: [PATCH 048/240] Fix check if it is safe to return the same instance of AbstractAggregatingFilter as child filter It was introduced by 6b45232d8eb97af9b60a8e76718082fe8dbf7d0c --- .../graph/filter/AbstractAggregatingFilter.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java index 49a7fb57..5fca7d48 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java @@ -64,7 +64,7 @@ public ProjectRelationshipFilter getChildFilter( final ProjectRelationship pa // } } - if ( getFilters().equals( childFilters ) ) + if ( filtersEqual( childFilters ) ) { return this; } @@ -123,7 +123,16 @@ else if ( otherFilters != null ) { // if ( orderMatters ) // { - return filters.equals( otherFilters ); + if ( otherFilters instanceof List ) + { + return filters.equals( otherFilters ); + } + else + { + List otherFiltersList = + new ArrayList( otherFilters ); + return filters.equals( otherFiltersList ); + } // } // else // { From 0c900d01ff9f12b5615d675b57dbe33dff5c683a Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Wed, 18 Feb 2015 13:10:03 +0100 Subject: [PATCH 049/240] Fix ExcludingFilter It did not use the embedded filter and accepted everything except tho artifacts listed in the excludedSubgraphs. Also getChildFilter returned the same instance all the time no matter if the childFilter of the embedded filter changed or not. --- .../maven/atlas/graph/filter/ExcludingFilter.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java index e466b45b..52c82a92 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java @@ -35,13 +35,21 @@ public boolean accept( final ProjectRelationship rel ) { final ProjectVersionRef target = rel.getTarget() .asProjectVersionRef(); - return !excludedSubgraphs.contains( target ); + return !excludedSubgraphs.contains( target ) && filter.accept( rel ); } @Override public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) { - return this; + ProjectRelationshipFilter childfilter = filter.getChildFilter( parent ); + if ( childfilter == filter ) + { + return this; + } + else + { + return new ExcludingFilter( excludedSubgraphs, childfilter ); + } } @Override From e478791689e61e74e6fd04535bb973b723d03d3d Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Fri, 16 Jan 2015 09:26:19 +0100 Subject: [PATCH 050/240] Add PathsTraversal that allows us to gather all relationship paths from root GAVs to target GAs --- .../atlas/graph/traverse/PathsTraversal.java | 132 ++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java new file mode 100644 index 00000000..f93af976 --- /dev/null +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java @@ -0,0 +1,132 @@ +/******************************************************************************* + * Copyright (c) 2014 Red Hat, Inc.. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Public License v3.0 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/gpl.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package org.commonjava.maven.atlas.graph.traverse; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.commonjava.maven.atlas.graph.filter.OrFilter; +import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; +import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; + +/** + * Dependency graph traversal ({@link ProjectNetTraversal}) implementation used + * to determine the paths between two GAVs or sets of GAVs in a graph. + * + * @author jdcasey + * @author pkocandr + */ +public class PathsTraversal +extends AbstractTraversal +{ + + private final ProjectRelationshipFilter rootFilter; + + private final Set to; + + private final Map cache = new HashMap(); + + private final Set>> paths = new HashSet>>(); + + public PathsTraversal( final ProjectRelationshipFilter filter, final Set toGas ) + { + this.rootFilter = filter; + this.to = toGas; + } + + @Override + public boolean preCheck( final ProjectRelationship relationship, final List> path ) + { + ProjectVersionRef declaring = relationship.getDeclaring().asProjectVersionRef(); + if ( path.isEmpty() || path.get( path.size() - 1 ).getTarget().asProjectVersionRef().equals( declaring ) ) + { + final ProjectRef dRef = declaring.asProjectRef(); + + ProjectRelationshipFilter filter = cache.get( dRef ); + if ( filter == null ) + { + filter = rootFilter; + } + + if ( filter.accept( relationship ) ) + { + final ProjectRef tRef = relationship.getTarget() + .asProjectRef(); + + final ProjectRelationshipFilter child = filter.getChildFilter( relationship ); + final OrFilter f = cache.get( tRef ); + if ( f == null ) + { + if ( child instanceof OrFilter ) + { + cache.put( tRef, (OrFilter) child ); + } + else + { + cache.put( tRef, new OrFilter( child ) ); + } + } + else + { + final Set filters = + new HashSet( f.getFilters() ); + if ( child instanceof OrFilter ) + { + List childFilters = + (List) ( (OrFilter) child ).getFilters(); + if ( !filters.containsAll( childFilters ) ) + { + filters.addAll( childFilters ); + cache.put( tRef, new OrFilter( filters ) ); + } + } + else + { + if ( !filters.contains( child ) ) + { + filters.add( child ); + cache.put( tRef, new OrFilter( filters ) ); + } + } + } + + if ( to.contains( tRef ) ) + { + final List> realPath = new ArrayList>( path ); + realPath.add( relationship ); + paths.add( realPath ); + } + + return true; + } + } + + return false; + } + + public Set>> getDiscoveredPaths() + { + return paths; + } + +// @Override +// public boolean traverseEdge( final ProjectRelationship relationship, final List> path ) +// { +// return false; +// } + +} From 3d51a246dcf0089fd9a1aeb0987fb77e66399d65 Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 25 Mar 2015 10:56:53 -0500 Subject: [PATCH 051/240] comment out log line that involves grabbing the stack trace. --- .../atlas/graph/RelationshipGraphFactory.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java index 4c30fe9e..e523c682 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java @@ -1,7 +1,5 @@ package org.commonjava.maven.atlas.graph; -import static org.apache.commons.lang.StringUtils.join; - import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; @@ -58,16 +56,16 @@ public synchronized RelationshipGraph open( final ViewParams params, final boole cache = new ConnectionCache( timer, connectionCaches, connection, wsid ); connectionCaches.put( wsid, cache ); - logger.info( "Created new connection to graph db: {}\nVia:\n {}", params.getWorkspaceId(), - join( Thread.currentThread() - .getStackTrace(), "\n " ) ); - } - else - { - logger.info( "Reusing connection to graph db: {}\nVia:\n {}", params.getWorkspaceId(), - join( Thread.currentThread() - .getStackTrace(), "\n " ) ); + // logger.info( "Created new connection to graph db: {}\nVia:\n {}", params.getWorkspaceId(), + // join( Thread.currentThread() + // .getStackTrace(), "\n " ) ); } + // else + // { + // logger.info( "Reusing connection to graph db: {}\nVia:\n {}", params.getWorkspaceId(), + // join( Thread.currentThread() + // .getStackTrace(), "\n " ) ); + // } RelationshipGraph graph = cache.getGraph( params ); From 09fac7bd9a79f80e4ef101670abe08f02b93bd74 Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 13 Apr 2015 16:50:52 -0500 Subject: [PATCH 052/240] adding test for zero-fill of versions. --- .../atlas/ident/version/SingleVersionComparisonsTest.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/SingleVersionComparisonsTest.java b/identities/src/test/java/org/commonjava/maven/atlas/ident/version/SingleVersionComparisonsTest.java index b7a7900e..8c692fe4 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/SingleVersionComparisonsTest.java +++ b/identities/src/test/java/org/commonjava/maven/atlas/ident/version/SingleVersionComparisonsTest.java @@ -38,8 +38,6 @@ import java.util.Locale; import org.commonjava.maven.atlas.ident.util.VersionUtils; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; -import org.commonjava.maven.atlas.ident.version.SingleVersion; import org.junit.After; import org.junit.Rule; import org.junit.Test; @@ -199,6 +197,12 @@ private void checkVersionsOrder( final String v1, final String v2 ) checkTrue( "expected > 0: " + v2 + " > " + v1 + " (got: " + comp + ")", comp > 0 ); } + @Test + public void testZeroFill() + { + checkVersionsEqual( "7", "7.0.0" ); + } + @Test public void testVersionsQualifier() throws InvalidVersionSpecificationException From 4c94ade474c0df8f64ae13d421dab765ac4cd714 Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 13 Apr 2015 16:54:50 -0500 Subject: [PATCH 053/240] [maven-release-plugin] prepare release atlas-parent-0.13.8 --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index f78e1b5a..e0ea5f4f 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.8-SNAPSHOT + 0.13.8 atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index b398aef6..101a12f1 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.8-SNAPSHOT + 0.13.8 atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index df21c0c2..30c65549 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.8-SNAPSHOT + 0.13.8 atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index c3305662..f7924da9 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.8-SNAPSHOT + 0.13.8 atlas-identities diff --git a/pom.xml b/pom.xml index 31fc42d7..ddd04e7b 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.8-SNAPSHOT + 0.13.8 pom Atlas :: Maven Project-Graph :: Parent @@ -29,7 +29,7 @@ scm:git:http://jdcasey@github.com/jdcasey/atlas.git scm:git:git@github.com:jdcasey/atlas.git http://github.com/jdcasey/atlas - HEAD + atlas-parent-0.13.8 @@ -37,17 +37,17 @@ org.commonjava.maven.atlas atlas-identities - 0.13.8-SNAPSHOT + 0.13.8 org.commonjava.maven.atlas atlas-relationships-api - 0.13.8-SNAPSHOT + 0.13.8 org.commonjava.maven.atlas atlas-drivers-tck - 0.13.8-SNAPSHOT + 0.13.8 test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index afc5dc87..0d543eed 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.8-SNAPSHOT + 0.13.8 atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 9b887ff4..014baf82 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.8-SNAPSHOT + 0.13.8 atlas-drivers-tck From acba27aa6c0e801c0c3f7d2ed2af15c5085c39b8 Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 13 Apr 2015 16:54:55 -0500 Subject: [PATCH 054/240] [maven-release-plugin] prepare for next development iteration --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index e0ea5f4f..f9b5a9fa 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.8 + 0.13.9-SNAPSHOT atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 101a12f1..76748f3b 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.8 + 0.13.9-SNAPSHOT atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 30c65549..72a9437e 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.8 + 0.13.9-SNAPSHOT atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index f7924da9..958858f6 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.8 + 0.13.9-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index ddd04e7b..ddc81739 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.8 + 0.13.9-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -29,7 +29,7 @@ scm:git:http://jdcasey@github.com/jdcasey/atlas.git scm:git:git@github.com:jdcasey/atlas.git http://github.com/jdcasey/atlas - atlas-parent-0.13.8 + HEAD @@ -37,17 +37,17 @@ org.commonjava.maven.atlas atlas-identities - 0.13.8 + 0.13.9-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.13.8 + 0.13.9-SNAPSHOT org.commonjava.maven.atlas atlas-drivers-tck - 0.13.8 + 0.13.9-SNAPSHOT test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 0d543eed..7c9cd4c7 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.8 + 0.13.9-SNAPSHOT atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 014baf82..dda1129c 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -15,7 +15,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.8 + 0.13.9-SNAPSHOT atlas-drivers-tck From 14f3d080093046f942c5e486b3e1f6da366e4e84 Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 17 Apr 2015 14:34:59 -0500 Subject: [PATCH 055/240] Changing license to ASL 2.0, and adding new version of parent so the license-maven-plugin (mycila) runs in the 'formatting' profile. --- LICENSE.txt | 16 ++++++++++ build-order-improvements.txt | 16 ++++++++++ codestyle.xml | 17 +++++++++++ drivers/jung/pom.xml | 23 ++++++++++----- .../spi/jung/CycleDetectionTraversal.java | 25 +++++++++------- .../graph/spi/jung/JungGraphConnection.java | 25 +++++++++------- .../spi/jung/JungGraphConnectionFactory.java | 15 ++++++++++ .../spi/jung/PathDetectionTraversal.java | 25 +++++++++------- .../graph/spi/jung/model/JungGraphPath.java | 25 +++++++++------- .../graph/spi/jung/CycleDetectionTest.java | 25 +++++++++------- .../jung/RelationshipGraphConnectionTest.java | 25 +++++++++------- .../graph/spi/jung/RelationshipGraphTest.java | 25 +++++++++------- .../graph/spi/jung/SubGraphSelectionTest.java | 25 +++++++++------- .../jung/traverse/AncestryTraversalTest.java | 25 +++++++++------- .../traverse/BuildOrderTraversalTest.java | 25 +++++++++------- .../TransitiveDependencyTraversalTest.java | 25 +++++++++------- drivers/neo4j-embedded/LICENSE.txt | 16 ++++++++++ drivers/neo4j-embedded/performance-todo.txt | 16 ++++++++++ drivers/neo4j-embedded/pom.xml | 23 ++++++++++----- .../spi/neo4j/FileNeo4JGraphConnection.java | 25 +++++++++------- .../spi/neo4j/FileNeo4jConnectionFactory.java | 15 ++++++++++ .../atlas/graph/spi/neo4j/GraphAdmin.java | 25 +++++++++------- .../atlas/graph/spi/neo4j/GraphRelType.java | 25 +++++++++------- .../graph/spi/neo4j/Neo4JGraphConnection.java | 25 +++++++++------- .../maven/atlas/graph/spi/neo4j/NodeType.java | 25 +++++++++------- .../atlas/graph/spi/neo4j/PathComparator.java | 25 +++++++++------- .../atlas/graph/spi/neo4j/ViewIndexes.java | 25 +++++++++------- .../graph/spi/neo4j/io/ConversionCache.java | 25 +++++++++------- .../atlas/graph/spi/neo4j/io/Conversions.java | 25 +++++++++------- .../graph/spi/neo4j/io/NodeIdProjector.java | 25 +++++++++------- .../atlas/graph/spi/neo4j/io/Projector.java | 25 +++++++++------- .../spi/neo4j/io/RelationshipIdProjector.java | 25 +++++++++------- .../graph/spi/neo4j/model/CyclePath.java | 25 +++++++++------- .../graph/spi/neo4j/model/Neo4jGraphPath.java | 25 +++++++++------- .../traverse/AbstractTraverseVisitor.java | 25 +++++++++------- .../spi/neo4j/traverse/AtlasCollector.java | 25 +++++++++------- .../traverse/AtlasRelIndexComparator.java | 15 ++++++++++ .../MembershipWrappedTraversalEvaluator.java | 25 +++++++++------- .../graph/spi/neo4j/traverse/NodePair.java | 25 +++++++++------- .../neo4j/traverse/PathCollectingVisitor.java | 25 +++++++++------- .../neo4j/traverse/PathExistenceVisitor.java | 25 +++++++++------- .../traverse/RootedRelationshipsVisitor.java | 25 +++++++++------- .../traverse/SubPathsCollectingVisitor.java | 25 +++++++++------- .../spi/neo4j/traverse/TraversalUtils.java | 25 +++++++++------- .../spi/neo4j/traverse/TraverseVisitor.java | 25 +++++++++------- .../traverse/track/LuceneSeenTracker.java | 25 +++++++++------- .../traverse/track/MemorySeenTracker.java | 25 +++++++++------- .../traverse/track/TraverseSeenTracker.java | 25 +++++++++------- .../spi/neo4j/update/CycleCacheUpdater.java | 25 +++++++++------- .../graph/spi/neo4j/update/ViewUpdater.java | 25 +++++++++------- .../graph/spi/neo4j/CypherQueriesTest.java | 25 +++++++++------- .../spi/neo4j/FileCycleDetectionTest.java | 25 +++++++++------- .../spi/neo4j/FileGraphWorkspaceTest.java | 25 +++++++++------- .../spi/neo4j/FileSubGraphSelectionTest.java | 25 +++++++++------- .../neo4j/RelationshipGraphFactoryTest.java | 15 ++++++++++ .../spi/neo4j/RelationshipGraphTest.java | 25 +++++++++------- .../neo4j/fixture/FileConnectionFixture.java | 25 +++++++++------- .../traverse/FileAncestryTraversalTest.java | 25 +++++++++------- .../traverse/FileBuildOrderTraversalTest.java | 25 +++++++++------- ...FileTransitiveDependencyTraversalTest.java | 25 +++++++++------- drivers/pom.xml | 23 ++++++++++----- identities/pom.xml | 23 ++++++++++----- .../maven/atlas/ident/DependencyScope.java | 25 +++++++++------- .../maven/atlas/ident/ScopeTransitivity.java | 25 +++++++++------- .../maven/atlas/ident/ref/ArtifactRef.java | 25 +++++++++------- .../atlas/ident/ref/InvalidRefException.java | 25 +++++++++------- .../maven/atlas/ident/ref/ProjectRef.java | 25 +++++++++------- .../atlas/ident/ref/ProjectVersionRef.java | 25 +++++++++------- .../atlas/ident/ref/TypeAndClassifier.java | 25 +++++++++------- .../maven/atlas/ident/ref/VersionedRef.java | 25 +++++++++------- .../ident/ref/VersionlessArtifactRef.java | 25 +++++++++------- .../atlas/ident/util/ArtifactPathInfo.java | 25 +++++++++------- .../ident/util/ArtifactRefComparator.java | 25 +++++++++------- .../maven/atlas/ident/util/IdentityUtils.java | 25 +++++++++------- .../maven/atlas/ident/util/JoinString.java | 25 +++++++++------- .../util/ProjectVersionRefComparator.java | 25 +++++++++------- .../maven/atlas/ident/util/SnapshotUtils.java | 25 +++++++++------- .../maven/atlas/ident/util/VersionUtils.java | 25 +++++++++------- .../VersionlessArtifactRefComparator.java | 25 +++++++++------- .../ident/version/CompoundVersionSpec.java | 25 +++++++++------- .../InvalidVersionSpecificationException.java | 25 +++++++++------- .../atlas/ident/version/MultiVersionSpec.java | 25 +++++++++------- .../atlas/ident/version/RangeVersionSpec.java | 25 +++++++++------- .../atlas/ident/version/SingleVersion.java | 25 +++++++++------- .../atlas/ident/version/VersionSpec.java | 25 +++++++++------- .../ident/version/VersionSpecComparisons.java | 25 +++++++++------- .../atlas/ident/version/part/NumericPart.java | 25 +++++++++------- .../ident/version/part/SeparatorPart.java | 25 +++++++++------- .../ident/version/part/SnapshotPart.java | 25 +++++++++------- .../atlas/ident/version/part/StringPart.java | 25 +++++++++------- .../atlas/ident/version/part/VersionPart.java | 25 +++++++++------- .../version/part/VersionPartSeparator.java | 25 +++++++++------- .../ident/version/part/VersionPhrase.java | 25 +++++++++------- identities/src/site/site.xml | 23 ++++++++++----- .../atlas/ident/ref/ArtifactRefTest.java | 15 ++++++++++ .../maven/atlas/ident/ref/ProjectRefTest.java | 25 +++++++++------- .../ident/ref/ProjectVersionRefTest.java | 25 +++++++++------- .../ident/ref/VersionlessArtifactRefTest.java | 25 +++++++++------- .../ident/util/ArtifactPathInfoTest.java | 25 +++++++++------- .../atlas/ident/util/SnapshotUtilsTest.java | 15 ++++++++++ .../version/SingleVersionComparisonsTest.java | 25 +++++++++------- .../ident/version/VersionParserTest.java | 25 +++++++++------- .../atlas/ident/version/VersionRangeTest.java | 25 +++++++++------- .../atlas/ident/version/VersionUtilsTest.java | 25 +++++++++------- .../ident/version/part/NumericPartTest.java | 25 +++++++++------- .../ident/version/part/SnapshotPartTest.java | 15 ++++++++++ pom.xml | 29 +++++++++++++------ relationships-api/pom.xml | 23 ++++++++++----- .../AbstractRelationshipGraphListener.java | 15 ++++++++++ .../maven/atlas/graph/RelationshipGraph.java | 15 ++++++++++ .../graph/RelationshipGraphException.java | 25 +++++++++------- .../atlas/graph/RelationshipGraphFactory.java | 15 ++++++++++ .../graph/RelationshipGraphListener.java | 15 ++++++++++ .../RelationshipGraphListenerFactory.java | 15 ++++++++++ .../maven/atlas/graph/ViewParams.java | 25 +++++++++------- .../filter/AbstractAggregatingFilter.java | 25 +++++++++------- .../graph/filter/AbstractTypedFilter.java | 25 +++++++++------- .../maven/atlas/graph/filter/AndFilter.java | 25 +++++++++------- .../maven/atlas/graph/filter/AnyFilter.java | 25 +++++++++------- .../maven/atlas/graph/filter/BomFilter.java | 25 +++++++++------- .../atlas/graph/filter/DependencyFilter.java | 25 +++++++++------- .../graph/filter/DependencyOnlyFilter.java | 25 +++++++++------- .../atlas/graph/filter/ExcludingFilter.java | 15 ++++++++++ .../atlas/graph/filter/ExtensionFilter.java | 25 +++++++++------- .../graph/filter/ExtensionOnlyFilter.java | 25 +++++++++------- .../maven/atlas/graph/filter/NoneFilter.java | 25 +++++++++------- .../maven/atlas/graph/filter/OrFilter.java | 25 +++++++++------- .../atlas/graph/filter/ParentFilter.java | 25 +++++++++------- .../graph/filter/PluginDependencyFilter.java | 25 +++++++++------- .../filter/PluginDependencyOnlyFilter.java | 25 +++++++++------- .../atlas/graph/filter/PluginOnlyFilter.java | 25 +++++++++------- .../graph/filter/PluginRuntimeFilter.java | 25 +++++++++------- .../filter/ProjectRelationshipFilter.java | 25 +++++++++------- .../filter/StructuralRelationshipsFilter.java | 15 ++++++++++ .../atlas/graph/model/EProjectCycle.java | 25 +++++++++------- .../model/EProjectDirectRelationships.java | 25 +++++++++------- .../model/EProjectRelationshipCollection.java | 25 +++++++++------- .../maven/atlas/graph/model/GraphPath.java | 25 +++++++++------- .../atlas/graph/model/GraphPathInfo.java | 25 +++++++++------- .../atlas/graph/mutate/GraphMutator.java | 25 +++++++++------- .../mutate/ManagedDependencyMutator.java | 25 +++++++++------- .../atlas/graph/mutate/NoOpGraphMutator.java | 25 +++++++++------- .../graph/mutate/VersionManagerMutator.java | 25 +++++++++------- .../rel/AbstractProjectRelationship.java | 25 +++++++++------- .../atlas/graph/rel/BomRelationship.java | 25 +++++++++------- .../graph/rel/DependencyRelationship.java | 25 +++++++++------- .../graph/rel/ExtensionRelationship.java | 25 +++++++++------- .../atlas/graph/rel/ParentRelationship.java | 25 +++++++++------- .../rel/PluginDependencyRelationship.java | 25 +++++++++------- .../atlas/graph/rel/PluginRelationship.java | 25 +++++++++------- .../atlas/graph/rel/ProjectRelationship.java | 25 +++++++++------- .../graph/rel/RelationshipComparator.java | 25 +++++++++------- .../graph/rel/RelationshipPathComparator.java | 25 +++++++++------- .../atlas/graph/rel/RelationshipType.java | 25 +++++++++------- .../spi/RelationshipGraphConnection.java | 25 +++++++++------- .../RelationshipGraphConnectionException.java | 25 +++++++++------- .../RelationshipGraphConnectionFactory.java | 15 ++++++++++ .../traverse/AbstractFilteringTraversal.java | 25 +++++++++------- .../graph/traverse/AbstractTraversal.java | 25 +++++++++------- .../graph/traverse/AncestryTraversal.java | 25 +++++++++------- .../graph/traverse/BuildOrderTraversal.java | 25 +++++++++------- .../graph/traverse/FilteringTraversal.java | 25 +++++++++------- .../atlas/graph/traverse/ImpactTraversal.java | 25 +++++++++------- .../atlas/graph/traverse/PathsTraversal.java | 23 +++++++++------ .../traverse/RelationshipGraphTraversal.java | 25 +++++++++------- .../TransitiveDependencyTraversal.java | 25 +++++++++------- .../atlas/graph/traverse/TraversalType.java | 25 +++++++++------- .../graph/traverse/model/BuildOrder.java | 25 +++++++++------- .../DependencyTreeRelationshipPrinter.java | 25 +++++++++------- .../graph/traverse/print/ListPrinter.java | 25 +++++++++------- .../print/StructurePrintingTraversal.java | 25 +++++++++------- .../print/StructureRelationshipPrinter.java | 25 +++++++++------- .../traverse/print/TargetRefPrinter.java | 25 +++++++++------- .../graph/traverse/print/TreePrinter.java | 25 +++++++++------- .../atlas/graph/util/RelationshipUtils.java | 25 +++++++++------- relationships-api/src/site/site.xml | 23 ++++++++++----- .../graph/EProjectRelationshipsTest.java | 25 +++++++++------- .../graph/filter/DependencyFilterTest.java | 25 +++++++++------- .../graph/rel/ParentRelationshipTest.java | 25 +++++++++------- .../rel/RelationshipPathComparatorTest.java | 25 +++++++++------- tck/pom.xml | 23 ++++++++++----- .../atlas/tck/graph/AbstractSPI_TCK.java | 25 +++++++++------- .../atlas/tck/graph/CycleDetectionTCK.java | 25 +++++++++------- .../RelationshipGraphConnection_TCK.java | 25 +++++++++------- .../graph/RelationshipGraphFactoryTCK.java | 15 ++++++++++ .../atlas/tck/graph/RelationshipGraphTCK.java | 25 +++++++++------- .../atlas/tck/graph/SubGraphSelectionTCK.java | 25 +++++++++------- .../graph/traverse/AncestryTraversalTCK.java | 25 +++++++++------- .../traverse/BuildOrderTraversalTCK.java | 25 +++++++++------- .../TransitiveDependencyTraversalTCK.java | 25 +++++++++------- 190 files changed, 2860 insertions(+), 1672 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 82ad83d5..8f49face 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,3 +1,19 @@ +==== + Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==== + #------------------------------------------------------------------------------- # Copyright (c) 2014 Red Hat, Inc.. # All rights reserved. This program and the accompanying materials diff --git a/build-order-improvements.txt b/build-order-improvements.txt index 4220f454..462fd452 100644 --- a/build-order-improvements.txt +++ b/build-order-improvements.txt @@ -1,3 +1,19 @@ +==== + Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==== + #------------------------------------------------------------------------------- # Copyright (c) 2014 Red Hat, Inc.. # All rights reserved. This program and the accompanying materials diff --git a/codestyle.xml b/codestyle.xml index 9e8c5134..04364a5f 100644 --- a/codestyle.xml +++ b/codestyle.xml @@ -1,4 +1,21 @@ + diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index f9b5a9fa..aee0a4c5 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -1,13 +1,20 @@ 4.0.0 diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTraversal.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTraversal.java index d4ecf671..eed018d6 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTraversal.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTraversal.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.jung; import static org.apache.commons.lang.StringUtils.join; diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java index e6d47865..a36cf75c 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.jung; import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.POM_ROOT_URI; diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnectionFactory.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnectionFactory.java index 885f08a2..df53247d 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnectionFactory.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnectionFactory.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.jung; import java.util.HashMap; diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java index fae9c23e..ff9ebc91 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.jung; import java.util.Arrays; diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/model/JungGraphPath.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/model/JungGraphPath.java index fd954139..aca20505 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/model/JungGraphPath.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/model/JungGraphPath.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.jung.model; import java.util.Arrays; diff --git a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTest.java b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTest.java index d5112bb2..4f43ed8e 100644 --- a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTest.java +++ b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTest.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.jung; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; diff --git a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/RelationshipGraphConnectionTest.java b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/RelationshipGraphConnectionTest.java index be1dab3f..2c4d28e6 100644 --- a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/RelationshipGraphConnectionTest.java +++ b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/RelationshipGraphConnectionTest.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.jung; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; diff --git a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/RelationshipGraphTest.java b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/RelationshipGraphTest.java index 712f196f..271aaa40 100644 --- a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/RelationshipGraphTest.java +++ b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/RelationshipGraphTest.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.jung; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; diff --git a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/SubGraphSelectionTest.java b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/SubGraphSelectionTest.java index a0b3a642..1114ea7f 100644 --- a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/SubGraphSelectionTest.java +++ b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/SubGraphSelectionTest.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.jung; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; diff --git a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/AncestryTraversalTest.java b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/AncestryTraversalTest.java index 37e87654..fb0c554f 100644 --- a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/AncestryTraversalTest.java +++ b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/AncestryTraversalTest.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.jung.traverse; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; diff --git a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/BuildOrderTraversalTest.java b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/BuildOrderTraversalTest.java index 872b5fb7..222b030f 100644 --- a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/BuildOrderTraversalTest.java +++ b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/BuildOrderTraversalTest.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.jung.traverse; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; diff --git a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/TransitiveDependencyTraversalTest.java b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/TransitiveDependencyTraversalTest.java index e3d1d6e3..b7cd9f66 100644 --- a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/TransitiveDependencyTraversalTest.java +++ b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/TransitiveDependencyTraversalTest.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.jung.traverse; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; diff --git a/drivers/neo4j-embedded/LICENSE.txt b/drivers/neo4j-embedded/LICENSE.txt index 82ad83d5..8f49face 100644 --- a/drivers/neo4j-embedded/LICENSE.txt +++ b/drivers/neo4j-embedded/LICENSE.txt @@ -1,3 +1,19 @@ +==== + Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==== + #------------------------------------------------------------------------------- # Copyright (c) 2014 Red Hat, Inc.. # All rights reserved. This program and the accompanying materials diff --git a/drivers/neo4j-embedded/performance-todo.txt b/drivers/neo4j-embedded/performance-todo.txt index 07c63ea2..e72c837d 100644 --- a/drivers/neo4j-embedded/performance-todo.txt +++ b/drivers/neo4j-embedded/performance-todo.txt @@ -1,3 +1,19 @@ +==== + Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==== + #------------------------------------------------------------------------------- # Copyright (c) 2014 Red Hat, Inc.. # All rights reserved. This program and the accompanying materials diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 76748f3b..0fa5a976 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -1,13 +1,20 @@ 4.0.0 diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java index 6da7b2d0..3d2cbf00 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j; import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.CONFIG_ID; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java index b6b80eae..ca8d7e21 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j; import java.io.File; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphAdmin.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphAdmin.java index d98deaeb..6ed9be3c 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphAdmin.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphAdmin.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j; import org.commonjava.maven.atlas.graph.ViewParams; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphRelType.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphRelType.java index 21914bd7..ef6b94b3 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphRelType.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphRelType.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j; import java.util.HashSet; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/Neo4JGraphConnection.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/Neo4JGraphConnection.java index 51cf5ede..78723d81 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/Neo4JGraphConnection.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/Neo4JGraphConnection.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j; import java.util.Map; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeType.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeType.java index 4b18ccdc..6b3a3800 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeType.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeType.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j; public enum NodeType diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java index 65d82e80..5ba60502 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j; import java.util.Comparator; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/ViewIndexes.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/ViewIndexes.java index 8f600c7b..99152e1c 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/ViewIndexes.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/ViewIndexes.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j; import org.commonjava.maven.atlas.graph.ViewParams; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/ConversionCache.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/ConversionCache.java index 5f95de02..71511866 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/ConversionCache.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/ConversionCache.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.io; import java.lang.ref.WeakReference; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java index 934a770d..04974a77 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.io; import static org.apache.commons.lang.StringUtils.join; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NodeIdProjector.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NodeIdProjector.java index 3078eeda..59cfdf51 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NodeIdProjector.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NodeIdProjector.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.io; import org.neo4j.graphdb.Node; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Projector.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Projector.java index 59bc2cb8..637be81c 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Projector.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Projector.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.io; public interface Projector diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/RelationshipIdProjector.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/RelationshipIdProjector.java index 004b393d..d425833f 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/RelationshipIdProjector.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/RelationshipIdProjector.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.io; import org.neo4j.graphdb.Relationship; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/CyclePath.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/CyclePath.java index a270a0c9..d43e0a69 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/CyclePath.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/CyclePath.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.model; import java.util.ArrayList; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java index a8b72ad6..f7deeb76 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.model; import java.util.ArrayList; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AbstractTraverseVisitor.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AbstractTraverseVisitor.java index fda7df49..fb6dadd9 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AbstractTraverseVisitor.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AbstractTraverseVisitor.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; import org.commonjava.maven.atlas.graph.model.GraphPathInfo; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java index 5be25953..0f0673e0 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.GAV; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasRelIndexComparator.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasRelIndexComparator.java index 1553f9e8..1b30be7c 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasRelIndexComparator.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasRelIndexComparator.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; import java.util.Comparator; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java index e8b8d513..cb49b22e 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.toProjectRelationship; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/NodePair.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/NodePair.java index 67a12e67..7c4dfd65 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/NodePair.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/NodePair.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; import org.neo4j.graphdb.Node; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathCollectingVisitor.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathCollectingVisitor.java index 8f23cebb..f098a200 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathCollectingVisitor.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathCollectingVisitor.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; import java.util.HashSet; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathExistenceVisitor.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathExistenceVisitor.java index 4f1042ee..66896f98 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathExistenceVisitor.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathExistenceVisitor.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; import org.commonjava.maven.atlas.graph.model.GraphPathInfo; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/RootedRelationshipsVisitor.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/RootedRelationshipsVisitor.java index f83daeef..b9f23a76 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/RootedRelationshipsVisitor.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/RootedRelationshipsVisitor.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; import java.util.HashSet; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/SubPathsCollectingVisitor.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/SubPathsCollectingVisitor.java index 8289d934..ae380146 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/SubPathsCollectingVisitor.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/SubPathsCollectingVisitor.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; import java.util.HashSet; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java index 0cab5eb6..56405878 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.POM_LOCATION_URI; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraverseVisitor.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraverseVisitor.java index fc94b078..ba241e12 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraverseVisitor.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraverseVisitor.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; import org.commonjava.maven.atlas.graph.model.GraphPathInfo; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/LuceneSeenTracker.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/LuceneSeenTracker.java index 398a319d..dac04a1f 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/LuceneSeenTracker.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/LuceneSeenTracker.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.traverse.track; import org.commonjava.maven.atlas.graph.ViewParams; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/MemorySeenTracker.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/MemorySeenTracker.java index f4d45133..8bad8fcc 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/MemorySeenTracker.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/MemorySeenTracker.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.traverse.track; import java.util.HashSet; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/TraverseSeenTracker.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/TraverseSeenTracker.java index 3bf4a995..17efe342 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/TraverseSeenTracker.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/TraverseSeenTracker.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.traverse.track; import org.commonjava.maven.atlas.graph.model.GraphPathInfo; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java index 5e9c5c53..ffef3f59 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.update; import java.util.ArrayList; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java index 45b5376e..f7166146 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.update; import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.NID; diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/CypherQueriesTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/CypherQueriesTest.java index dc087df5..7f5a22f9 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/CypherQueriesTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/CypherQueriesTest.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j; import java.net.URI; diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileCycleDetectionTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileCycleDetectionTest.java index 9cae0a36..dd4eb916 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileCycleDetectionTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileCycleDetectionTest.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileGraphWorkspaceTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileGraphWorkspaceTest.java index 550132ae..d1d254e2 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileGraphWorkspaceTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileGraphWorkspaceTest.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileSubGraphSelectionTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileSubGraphSelectionTest.java index 3723ffcb..9f9905df 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileSubGraphSelectionTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileSubGraphSelectionTest.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphFactoryTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphFactoryTest.java index 02657739..d741bad6 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphFactoryTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphFactoryTest.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphTest.java index efa5da56..a7a59515 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphTest.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/FileConnectionFixture.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/FileConnectionFixture.java index e9881202..9cd12818 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/FileConnectionFixture.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/FileConnectionFixture.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.fixture; import java.io.File; diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileAncestryTraversalTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileAncestryTraversalTest.java index 3a53f65f..7e221157 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileAncestryTraversalTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileAncestryTraversalTest.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileBuildOrderTraversalTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileBuildOrderTraversalTest.java index f922747f..e7117b6d 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileBuildOrderTraversalTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileBuildOrderTraversalTest.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileTransitiveDependencyTraversalTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileTransitiveDependencyTraversalTest.java index 23fb1283..a1d3e858 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileTransitiveDependencyTraversalTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileTransitiveDependencyTraversalTest.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; diff --git a/drivers/pom.xml b/drivers/pom.xml index 72a9437e..7f23f74f 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -1,13 +1,20 @@ 4.0.0 diff --git a/identities/pom.xml b/identities/pom.xml index 958858f6..40d922c8 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -1,13 +1,20 @@ 4.0.0 diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/DependencyScope.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/DependencyScope.java index f7addd00..66cca1db 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/DependencyScope.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/DependencyScope.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident; import java.util.ArrayList; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ScopeTransitivity.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ScopeTransitivity.java index 0da34cc1..f302fd9b 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ScopeTransitivity.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ScopeTransitivity.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident; import static org.commonjava.maven.atlas.ident.DependencyScope.embedded; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java index d99637d1..e927c834 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.ref; import static org.apache.commons.lang.StringUtils.isEmpty; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/InvalidRefException.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/InvalidRefException.java index 77f8818a..427350aa 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/InvalidRefException.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/InvalidRefException.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.ref; import java.util.IllegalFormatException; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java index c5168f9d..204300d2 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.ref; import static org.apache.commons.lang.StringUtils.isEmpty; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java index 850e57a4..03c2fa3d 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.ref; import static org.apache.commons.lang.StringUtils.isEmpty; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/TypeAndClassifier.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/TypeAndClassifier.java index 47a49b22..8957a994 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/TypeAndClassifier.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/TypeAndClassifier.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.ref; import static org.apache.commons.lang.StringUtils.isEmpty; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionedRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionedRef.java index 59271f27..d05819ad 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionedRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionedRef.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.ref; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java index cab4952e..5f8237b3 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.ref; import static org.apache.commons.lang.StringUtils.isEmpty; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java index 89eb4ddb..5d3b4a77 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.util; import java.util.regex.Matcher; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactRefComparator.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactRefComparator.java index 61ffa047..84f2935d 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactRefComparator.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactRefComparator.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.util; import java.util.Comparator; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/IdentityUtils.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/IdentityUtils.java index 210b077c..deec501d 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/IdentityUtils.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/IdentityUtils.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.util; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/JoinString.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/JoinString.java index e3f2d742..1315c2e9 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/JoinString.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/JoinString.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.util; import static org.apache.commons.lang.StringUtils.join; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ProjectVersionRefComparator.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ProjectVersionRefComparator.java index e6758606..9cb26103 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ProjectVersionRefComparator.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ProjectVersionRefComparator.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.util; import java.util.Comparator; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/SnapshotUtils.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/SnapshotUtils.java index 89fbdac9..e615fcc6 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/SnapshotUtils.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/SnapshotUtils.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.util; import java.text.DateFormat; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionUtils.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionUtils.java index f14d5308..7efee472 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionUtils.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionUtils.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.util; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionlessArtifactRefComparator.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionlessArtifactRefComparator.java index dd9112fc..52bfd3e4 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionlessArtifactRefComparator.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionlessArtifactRefComparator.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.util; import java.util.Comparator; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/CompoundVersionSpec.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/CompoundVersionSpec.java index 50d7f6ae..87eb7b67 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/CompoundVersionSpec.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/CompoundVersionSpec.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.version; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/InvalidVersionSpecificationException.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/InvalidVersionSpecificationException.java index 40f740be..7f1baf33 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/InvalidVersionSpecificationException.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/InvalidVersionSpecificationException.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.version; import java.util.IllegalFormatException; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/MultiVersionSpec.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/MultiVersionSpec.java index 80102e43..bcc8842e 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/MultiVersionSpec.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/MultiVersionSpec.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.version; public interface MultiVersionSpec diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/RangeVersionSpec.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/RangeVersionSpec.java index d90d50bc..349e2bca 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/RangeVersionSpec.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/RangeVersionSpec.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.version; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/SingleVersion.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/SingleVersion.java index ef89ade5..703c1ffa 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/SingleVersion.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/SingleVersion.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.version; import static org.apache.commons.lang.StringUtils.join; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/VersionSpec.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/VersionSpec.java index 52e1d7ea..9989acfd 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/VersionSpec.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/VersionSpec.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.version; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/VersionSpecComparisons.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/VersionSpecComparisons.java index 6d831d4d..91cc59f7 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/VersionSpecComparisons.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/VersionSpecComparisons.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.version; import java.util.ArrayList; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/NumericPart.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/NumericPart.java index 8144be0d..a3fc65e6 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/NumericPart.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/NumericPart.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.version.part; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SeparatorPart.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SeparatorPart.java index 5df5daef..2d0fd86e 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SeparatorPart.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SeparatorPart.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.version.part; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPart.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPart.java index f084b2cb..11f689da 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPart.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPart.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.version.part; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/StringPart.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/StringPart.java index cc91c175..35006581 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/StringPart.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/StringPart.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.version.part; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPart.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPart.java index b7e14d40..2951d75e 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPart.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPart.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.version.part; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPartSeparator.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPartSeparator.java index 4d1bbc1c..7ae92056 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPartSeparator.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPartSeparator.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.version.part; public enum VersionPartSeparator diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPhrase.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPhrase.java index ccdd1a62..b677b415 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPhrase.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPhrase.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.version.part; import java.io.Serializable; diff --git a/identities/src/site/site.xml b/identities/src/site/site.xml index 92932c60..0362cb60 100644 --- a/identities/src/site/site.xml +++ b/identities/src/site/site.xml @@ -1,13 +1,20 @@ 4.0.0 @@ -15,7 +22,7 @@ org.commonjava commonjava - 4 + 6-SNAPSHOT org.commonjava.maven.atlas @@ -32,6 +39,10 @@ HEAD + + Red Hat, Inc. + + diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 7c9cd4c7..dc38ee15 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -1,13 +1,20 @@ 4.0.0 diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/AbstractRelationshipGraphListener.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/AbstractRelationshipGraphListener.java index ed3e1e8e..4d3aa2fd 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/AbstractRelationshipGraphListener.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/AbstractRelationshipGraphListener.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph; import java.util.Collection; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java index e6c0107d..6a48911d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph; import static org.apache.commons.lang.StringUtils.join; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphException.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphException.java index e2f36f6d..dce02a22 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphException.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphException.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph; import java.util.IllegalFormatException; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java index e523c682..1755f679 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph; import java.util.Arrays; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListener.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListener.java index fedf4e6c..d93914da 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListener.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListener.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph; import java.util.Collection; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListenerFactory.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListenerFactory.java index a71ecb8c..6130be4e 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListenerFactory.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListenerFactory.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph; public interface RelationshipGraphListenerFactory diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java index 84fd630c..1e7dd9ca 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph; import static org.apache.commons.lang.StringUtils.join; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java index 5fca7d48..776c52f2 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import java.util.ArrayList; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java index 17042168..2eb596da 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import static org.apache.commons.lang.StringUtils.join; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java index 6e77007f..860072c3 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import java.util.Collection; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AnyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AnyFilter.java index 5aafc13b..3452aea7 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AnyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AnyFilter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import java.util.Arrays; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/BomFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/BomFilter.java index ee44f4b8..d08b7036 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/BomFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/BomFilter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java index c54464e3..274b0987 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import java.util.HashSet; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java index b5884c77..398cc479 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import static org.apache.commons.lang.StringUtils.join; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java index 52c82a92..d48529d3 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import static org.apache.commons.lang.StringUtils.join; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionFilter.java index bd1d3de2..9979bc31 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionFilter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionOnlyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionOnlyFilter.java index 99464254..8f018baf 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionOnlyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionOnlyFilter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/NoneFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/NoneFilter.java index f4df52ec..772cfebe 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/NoneFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/NoneFilter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import java.util.Collections; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java index b9c2edf1..605602df 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import java.util.Collection; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ParentFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ParentFilter.java index 0bc8c5e0..bdb4e93c 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ParentFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ParentFilter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import org.commonjava.maven.atlas.graph.rel.ParentRelationship; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyFilter.java index 484f1656..5325396f 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyFilter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyOnlyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyOnlyFilter.java index ad7c1368..9c3e9010 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyOnlyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyOnlyFilter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginOnlyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginOnlyFilter.java index 3f2aa5ff..92da59be 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginOnlyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginOnlyFilter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import org.commonjava.maven.atlas.graph.rel.PluginRelationship; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java index 365d79c5..7632d160 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import java.util.HashSet; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ProjectRelationshipFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ProjectRelationshipFilter.java index 5085b644..f17617b6 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ProjectRelationshipFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ProjectRelationshipFilter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import java.io.Serializable; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/StructuralRelationshipsFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/StructuralRelationshipsFilter.java index 417be73c..75c1d668 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/StructuralRelationshipsFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/StructuralRelationshipsFilter.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import static org.commonjava.maven.atlas.graph.rel.RelationshipType.BOM; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java index bcd76471..a5b724a7 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.model; import static org.apache.commons.lang.StringUtils.join; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java index fa0abaa9..23de055d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.model; import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.filterTerminalParents; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectRelationshipCollection.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectRelationshipCollection.java index 6d6f5307..c216206a 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectRelationshipCollection.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectRelationshipCollection.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.model; import java.io.Serializable; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPath.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPath.java index 2229d2d3..50cf7f62 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPath.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPath.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.model; public interface GraphPath diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPathInfo.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPathInfo.java index ee50fb1f..1e5dfce8 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPathInfo.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPathInfo.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.model; import java.io.Serializable; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/GraphMutator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/GraphMutator.java index 716a8907..bc11c4ef 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/GraphMutator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/GraphMutator.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.mutate; import java.io.Serializable; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java index 94865159..70c2dc94 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.mutate; import org.commonjava.maven.atlas.graph.ViewParams; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java index f6f8f6b1..acafe6fc 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.mutate; import org.commonjava.maven.atlas.graph.ViewParams; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java index ed6cb868..f7709e60 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.mutate; import org.apache.commons.codec.digest.DigestUtils; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractProjectRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractProjectRelationship.java index cfa73b5a..286544bc 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractProjectRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractProjectRelationship.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.rel; import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.POM_ROOT_URI; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java index 4032249b..9e4c0e24 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.rel; import java.net.URI; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java index 839c99e8..be1dd08b 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.rel; import java.io.Serializable; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java index 0c9f83ea..9fb702dc 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.rel; import java.io.Serializable; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java index 3ded5e7e..49fb3006 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.rel; import java.io.Serializable; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java index d4947d21..f130ff7b 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.rel; import java.io.Serializable; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java index 0161b029..83ead9a9 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.rel; import java.io.Serializable; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ProjectRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ProjectRelationship.java index 33067b8b..3097e191 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ProjectRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ProjectRelationship.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.rel; import java.io.Serializable; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparator.java index 60e9bcba..0d52fa39 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparator.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.rel; import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.POM_ROOT_URI; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparator.java index 3d835f12..6141d5e7 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparator.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.rel; import java.util.Comparator; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipType.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipType.java index a4cdc1c4..bfc85287 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipType.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipType.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.rel; import java.util.Arrays; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java index 8abf0d37..93bc42fe 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi; import java.util.Collection; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionException.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionException.java index 18d186d1..834f16e4 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionException.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionException.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi; import org.commonjava.maven.atlas.graph.RelationshipGraphException; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionFactory.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionFactory.java index 76fea29d..76f901cc 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionFactory.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionFactory.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi; import java.util.Set; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractFilteringTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractFilteringTraversal.java index a1894bdf..7ae027af 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractFilteringTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractFilteringTraversal.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.traverse; import java.util.List; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractTraversal.java index 94334d0f..2647fd9a 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractTraversal.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.traverse; import java.util.List; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AncestryTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AncestryTraversal.java index 55022d1c..0b2bf3ea 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AncestryTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AncestryTraversal.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.traverse; import java.util.List; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java index ba2b267f..8d82295b 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.traverse; import java.util.ArrayList; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/FilteringTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/FilteringTraversal.java index 34655d5d..85aeb1be 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/FilteringTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/FilteringTraversal.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.traverse; import java.util.ArrayList; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/ImpactTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/ImpactTraversal.java index 6fac6b24..442aae33 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/ImpactTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/ImpactTraversal.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.traverse; import java.util.ArrayList; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java index f93af976..a9122e37 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.traverse; import java.util.ArrayList; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/RelationshipGraphTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/RelationshipGraphTraversal.java index eadf8bf4..bf07df06 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/RelationshipGraphTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/RelationshipGraphTraversal.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.traverse; import java.util.List; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java index ab086c7a..2575b26d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.traverse; import java.util.ArrayList; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TraversalType.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TraversalType.java index 07e21d08..4a637ec4 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TraversalType.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TraversalType.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.traverse; public enum TraversalType diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/model/BuildOrder.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/model/BuildOrder.java index 16bbbe7e..d154824d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/model/BuildOrder.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/model/BuildOrder.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.traverse.model; import java.util.Collections; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/DependencyTreeRelationshipPrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/DependencyTreeRelationshipPrinter.java index d194ca80..28e24835 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/DependencyTreeRelationshipPrinter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/DependencyTreeRelationshipPrinter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.traverse.print; import java.io.PrintWriter; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java index 2795047b..5dffd2f7 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.traverse.print; import java.io.PrintWriter; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructurePrintingTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructurePrintingTraversal.java index 118b7103..391ee162 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructurePrintingTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructurePrintingTraversal.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.traverse.print; import java.io.PrintWriter; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructureRelationshipPrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructureRelationshipPrinter.java index 0db660dc..7ab655b0 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructureRelationshipPrinter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructureRelationshipPrinter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.traverse.print; import java.io.PrintWriter; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TargetRefPrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TargetRefPrinter.java index eab73aaa..eea08b0d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TargetRefPrinter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TargetRefPrinter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.traverse.print; import java.io.PrintWriter; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java index d285eeb9..744efb39 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.traverse.print; import java.io.PrintWriter; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java index 7dadd885..5b5e229e 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.util; import static org.commonjava.maven.atlas.ident.util.IdentityUtils.artifact; diff --git a/relationships-api/src/site/site.xml b/relationships-api/src/site/site.xml index 92932c60..0362cb60 100644 --- a/relationships-api/src/site/site.xml +++ b/relationships-api/src/site/site.xml @@ -1,13 +1,20 @@ 4.0.0 diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java index e7affce2..244b2c46 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.tck.graph; import java.net.URI; diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/CycleDetectionTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/CycleDetectionTCK.java index ba49cd2f..8b478d5e 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/CycleDetectionTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/CycleDetectionTCK.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.tck.graph; import static org.apache.commons.lang.StringUtils.join; diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphConnection_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphConnection_TCK.java index 6de11cbb..faeb7b4d 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphConnection_TCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphConnection_TCK.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.tck.graph; import static org.hamcrest.CoreMatchers.equalTo; diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphFactoryTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphFactoryTCK.java index cfc82069..f15b95b0 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphFactoryTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphFactoryTCK.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.tck.graph; import static org.hamcrest.CoreMatchers.notNullValue; diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphTCK.java index e03424e5..7c4bff34 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphTCK.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.tck.graph; import static org.hamcrest.CoreMatchers.equalTo; diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/SubGraphSelectionTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/SubGraphSelectionTCK.java index 14790112..f28ff7a1 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/SubGraphSelectionTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/SubGraphSelectionTCK.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.tck.graph; import static org.hamcrest.CoreMatchers.equalTo; diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/AncestryTraversalTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/AncestryTraversalTCK.java index 7cd0d92c..54f68ba9 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/AncestryTraversalTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/AncestryTraversalTCK.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.tck.graph.traverse; import static org.hamcrest.CoreMatchers.equalTo; diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java index c1dae0b3..4947e72f 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.tck.graph.traverse; import static org.apache.commons.lang.StringUtils.join; diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/TransitiveDependencyTraversalTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/TransitiveDependencyTraversalTCK.java index 9f54cf87..c9951984 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/TransitiveDependencyTraversalTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/TransitiveDependencyTraversalTCK.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2014 Red Hat, Inc.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.tck.graph.traverse; import static org.commonjava.maven.atlas.ident.DependencyScope.compile; From 81ab6ba7a2301d14f1d23acea8a18a2041b38a04 Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 17 Apr 2015 15:45:25 -0500 Subject: [PATCH 056/240] update BOM version and adjust TCK deps to compensate for changes in junit inclusion of hamcrest core --- pom.xml | 2 +- tck/pom.xml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 68fd3e31..45d8f927 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,7 @@ org.commonjava.boms web-commons-bom - 9 + 16-SNAPSHOT import pom diff --git a/tck/pom.xml b/tck/pom.xml index ea063ad2..9dc70243 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -39,5 +39,10 @@ junit compile + + org.hamcrest + hamcrest-core + compile + From 3abdedffb75ce1c4621ccef5313e9a3219d11563 Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 23 Apr 2015 23:37:04 -0500 Subject: [PATCH 057/240] bump to release for parent and bom --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 45d8f927..04a46de2 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.commonjava commonjava - 6-SNAPSHOT + 6 org.commonjava.maven.atlas @@ -65,7 +65,7 @@ org.commonjava.boms web-commons-bom - 16-SNAPSHOT + 16 import pom From 0243815bf0e0472ac97e0ca736bb2a48ae1943a2 Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 23 Apr 2015 23:39:44 -0500 Subject: [PATCH 058/240] use latest snapshot of parent for snapshot repo --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 04a46de2..f47b65a3 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.commonjava commonjava - 6 + 7-SNAPSHOT org.commonjava.maven.atlas From ff60601afd2786d318a9ab2ad370a085a3deb170 Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 23 Apr 2015 23:48:47 -0500 Subject: [PATCH 059/240] add travis ci control file. --- .travis.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..33d9deea --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +sudo: required + +language: java +jdk: + - oraclejdk7 + +cache: + directories: + - '$HOME/.m2/repository' + +before_install: + - curl http://repository.commonjava.org/mavdav/settings/group/settings-ci.xml > $HOME/.m2/settings.xml + - sudo rm /etc/mavenrc +install: /bin/true +script: mvn clean deploy -V -Prun-its -q -B -e \ No newline at end of file From 41f92d2f002d791e6c59704625f0001063f8630a Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Thu, 23 Apr 2015 08:33:03 +0200 Subject: [PATCH 060/240] Fix ProjectRef.compareTo to not always return 0 --- .../java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java index 204300d2..57a99108 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java @@ -158,7 +158,7 @@ public int compareTo( final ProjectRef o ) comp = artifactId.compareTo( o.artifactId ); } - return 0; + return comp; } public boolean matches( final ProjectRef ref ) From 7cd065505642b6e411028d888aa0e00b4e546336 Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Thu, 30 Apr 2015 09:49:33 +0200 Subject: [PATCH 061/240] Fix hashCode/equals of Neo4jGraphPath The former implementation did not take into account the case when the path does not contain any relationships, e.g. path with start node id 5, end node id 5 and relationships is an empty array. When there is more than one paths with different start/end id, they were considered to be the same. In the end it prevented us to use more than one root GAVs in AProx's urlmap method, because it only picked the first root and the rest was thrown away. --- .../atlas/graph/spi/neo4j/model/Neo4jGraphPath.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java index f7deeb76..f36a3b40 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java @@ -171,6 +171,8 @@ public int hashCode() { final int prime = 31; int result = 1; + result = prime * result + Long.valueOf( startNode ).hashCode(); + result = prime * result + Long.valueOf( endNode ).hashCode(); result = prime * result + Arrays.hashCode( relationships ); return result; } @@ -191,6 +193,14 @@ public boolean equals( final Object obj ) return false; } final Neo4jGraphPath other = (Neo4jGraphPath) obj; + if ( startNode != other.startNode ) + { + return false; + } + if ( endNode != other.endNode ) + { + return false; + } if ( !Arrays.equals( relationships, other.relationships ) ) { return false; From 6f462ed52a1d9362992a8d777aa5d36d73fc1a7d Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 4 May 2015 11:32:02 -0500 Subject: [PATCH 062/240] update parent and urls. --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index f47b65a3..f3becfe8 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.commonjava commonjava - 7-SNAPSHOT + 7 org.commonjava.maven.atlas @@ -33,9 +33,9 @@ Atlas :: Maven Project-Graph :: Parent - scm:git:http://jdcasey@github.com/jdcasey/atlas.git - scm:git:git@github.com:jdcasey/atlas.git - http://github.com/jdcasey/atlas + scm:git:https://github.com/Commonjava/atlas.git + scm:git:git@github.com:Commonjava/atlas.git + http://github.com/Commonjava/atlas HEAD From e11c62ac9b6543dede38fd2b13cb597053fdfbf0 Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 4 May 2015 11:36:50 -0500 Subject: [PATCH 063/240] [maven-release-plugin] prepare release atlas-parent-0.14.0 --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index aee0a4c5..b58f7147 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.9-SNAPSHOT + 0.14.0 atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 0fa5a976..08191b42 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.13.9-SNAPSHOT + 0.14.0 atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 7f23f74f..d959c9c2 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.9-SNAPSHOT + 0.14.0 atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index 40d922c8..512c8efd 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.9-SNAPSHOT + 0.14.0 atlas-identities diff --git a/pom.xml b/pom.xml index f3becfe8..4951d01f 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.9-SNAPSHOT + 0.14.0 pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - HEAD + atlas-parent-0.14.0 @@ -48,17 +48,17 @@ org.commonjava.maven.atlas atlas-identities - 0.13.9-SNAPSHOT + 0.14.0 org.commonjava.maven.atlas atlas-relationships-api - 0.13.9-SNAPSHOT + 0.14.0 org.commonjava.maven.atlas atlas-drivers-tck - 0.13.9-SNAPSHOT + 0.14.0 test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index dc38ee15..1624cb15 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.9-SNAPSHOT + 0.14.0 atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 9dc70243..a810e29d 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.13.9-SNAPSHOT + 0.14.0 atlas-drivers-tck From 4ef4d3103a820071b394d776a4a773dda61fd838 Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 4 May 2015 11:36:52 -0500 Subject: [PATCH 064/240] [maven-release-plugin] prepare for next development iteration --- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index b58f7147..517290ea 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.14.0 + 0.14.1-SNAPSHOT atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 08191b42..12e116e4 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.14.0 + 0.14.1-SNAPSHOT atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index d959c9c2..a55f7924 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.0 + 0.14.1-SNAPSHOT atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index 512c8efd..8cfce540 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.0 + 0.14.1-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index 4951d01f..493e8ed0 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.0 + 0.14.1-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - atlas-parent-0.14.0 + HEAD @@ -48,17 +48,17 @@ org.commonjava.maven.atlas atlas-identities - 0.14.0 + 0.14.1-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.14.0 + 0.14.1-SNAPSHOT org.commonjava.maven.atlas atlas-drivers-tck - 0.14.0 + 0.14.1-SNAPSHOT test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 1624cb15..0638f889 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.0 + 0.14.1-SNAPSHOT atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index a810e29d..fe064fe2 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.0 + 0.14.1-SNAPSHOT atlas-drivers-tck From 9b22255816b4438d859c7eff13eb24b9c6b6ae3b Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 19 May 2015 10:18:03 -0500 Subject: [PATCH 065/240] initial commit. --- .travis.yml | 12 ++++++++++++ travis-settings.xml | 8 ++++++++ 2 files changed, 20 insertions(+) create mode 100644 .travis.yml create mode 100644 travis-settings.xml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..bac49a19 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +sudo: required + +language: java +jdk: + - oraclejdk7 + +cache: + directories: + - '$HOME/.m2/repository' + +install: /bin/true +script: mvn deploy -V -Prun-its -q -B -e \ No newline at end of file diff --git a/travis-settings.xml b/travis-settings.xml new file mode 100644 index 00000000..c81e1ab6 --- /dev/null +++ b/travis-settings.xml @@ -0,0 +1,8 @@ + + + + sonatype-nexus-snapshots + ${env.SONATYPE_USER} + ${env.SONATYPE_PASS} + + \ No newline at end of file From fe6daa2c262b709982955a8581de8bed7c2bb38f Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 19 May 2015 10:20:17 -0500 Subject: [PATCH 066/240] fixing broken settings.xml --- travis-settings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/travis-settings.xml b/travis-settings.xml index c81e1ab6..43941ac3 100644 --- a/travis-settings.xml +++ b/travis-settings.xml @@ -5,4 +5,5 @@ ${env.SONATYPE_USER} ${env.SONATYPE_PASS} + \ No newline at end of file From 1c837f0f6e18aaba35b3a9f9c94b853853914194 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 19 May 2015 10:23:40 -0500 Subject: [PATCH 067/240] use travis-settings.xml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bac49a19..61f0ad89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,4 +9,4 @@ cache: - '$HOME/.m2/repository' install: /bin/true -script: mvn deploy -V -Prun-its -q -B -e \ No newline at end of file +script: mvn deploy -s ./travis-settings.xml -V -Prun-its -q -B -e \ No newline at end of file From f23831ad23ca52254fa581ad7e0f4dad9f01ff8e Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 19 May 2015 11:52:12 -0500 Subject: [PATCH 068/240] Adding sonatype snapshots repo to active profile. --- travis-settings.xml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/travis-settings.xml b/travis-settings.xml index 43941ac3..3fe92474 100644 --- a/travis-settings.xml +++ b/travis-settings.xml @@ -6,4 +6,36 @@ ${env.SONATYPE_PASS} + + + snapshot-repo + + + sonatype-nexus-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + false + + + true + + + + + + sonatype-nexus-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + false + + + true + + + + + + + snapshot-repo + \ No newline at end of file From 428cafc606bc0e812ef280d8683935c3b5b404cf Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 19 May 2015 17:09:51 -0500 Subject: [PATCH 069/240] Make deployment conditional on whether it's a PR build. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 61f0ad89..9168e80a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,4 +9,5 @@ cache: - '$HOME/.m2/repository' install: /bin/true -script: mvn deploy -s ./travis-settings.xml -V -Prun-its -q -B -e \ No newline at end of file +script: + - '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && mvn -s ./travis-settings.xml -Prun-its -q -B -e install || mvn deploy -s ./travis-settings.xml -V -Prun-its -q -B -e' \ No newline at end of file From 2c705a06f63d1b483e96e15abaf2a067b7f546c1 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 19 May 2015 18:13:06 -0500 Subject: [PATCH 070/240] fixing conditional call to mvn for PRs --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9168e80a..96ed4f43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,4 @@ cache: install: /bin/true script: - - '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && mvn -s ./travis-settings.xml -Prun-its -q -B -e install || mvn deploy -s ./travis-settings.xml -V -Prun-its -q -B -e' \ No newline at end of file + - '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && mvn deploy -s ./travis-settings.xml -V -Prun-its -q -B -e|| mvn install -s ./travis-settings.xml -V -Prun-its -q -B -e' From 9ed9fb7139663e322de6635aaffc6f797cd555c7 Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 20 May 2015 14:28:29 -0500 Subject: [PATCH 071/240] simplify and streamline travis control file --- .travis.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 96ed4f43..16d73dce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,3 @@ -sudo: required - language: java -jdk: - - oraclejdk7 - -cache: - directories: - - '$HOME/.m2/repository' - -install: /bin/true script: - '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && mvn deploy -s ./travis-settings.xml -V -Prun-its -q -B -e|| mvn install -s ./travis-settings.xml -V -Prun-its -q -B -e' From 7aeed215b7961f66e1418a59e8a675778029bca6 Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 20 May 2015 14:39:07 -0500 Subject: [PATCH 072/240] override default maven command in install section --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 16d73dce..735c2031 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ language: java -script: - - '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && mvn deploy -s ./travis-settings.xml -V -Prun-its -q -B -e|| mvn install -s ./travis-settings.xml -V -Prun-its -q -B -e' +install: '/bin/true' +script: '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && mvn deploy -s ./travis-settings.xml -V -Prun-its -q -B -e|| mvn install -s ./travis-settings.xml -V -Prun-its -q -B -e' + From be2582b786710b5c739b68894337a515237d160f Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 7 Jul 2015 09:55:08 -0500 Subject: [PATCH 073/240] Adding bindings modules for jackson to allow reuse of these serializer/deserializers more broadly than just in aprox. --- bindings/jackson-identities/pom.xml | 43 +++ .../ProjectVersionRefSerializerModule.java | 138 ++++++++++ bindings/jackson-relationships/pom.xml | 47 ++++ .../ProjectRelationshipSerializerModule.java | 256 ++++++++++++++++++ .../graph/jackson/SerializationConstants.java | 67 +++++ bindings/pom.xml | 44 +++ pom.xml | 1 + 7 files changed, 596 insertions(+) create mode 100644 bindings/jackson-identities/pom.xml create mode 100644 bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java create mode 100644 bindings/jackson-relationships/pom.xml create mode 100644 bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java create mode 100644 bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java create mode 100644 bindings/pom.xml diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml new file mode 100644 index 00000000..2aa359f8 --- /dev/null +++ b/bindings/jackson-identities/pom.xml @@ -0,0 +1,43 @@ + + + + 4.0.0 + + + org.commonjava.maven.atlas + atlas-bindings-parent + 0.14.1-SNAPSHOT + + + atlas-bindings-jackson-identities + + Atlas :: Maven Project-Graph :: Jackson Identities API Bindings + + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-core + + + + diff --git a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java new file mode 100644 index 00000000..bb9334b3 --- /dev/null +++ b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java @@ -0,0 +1,138 @@ +/** + * Copyright (C) 2011 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.ident.jackson; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.VersionlessArtifactRef; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +public class ProjectVersionRefSerializerModule + extends SimpleModule +{ + + private static final long serialVersionUID = 1L; + + public ProjectVersionRefSerializerModule() + { + super( "ProjectRef (with variants) Serializer" ); + + // ProjectRef + addSerializer( ProjectRef.class, new ProjectRefSerializer( ProjectRef.class ) ); + + addDeserializer( ProjectRef.class, new ProjectRefDeserializer( ProjectRef.class ) ); + + // ProjectVersionRef + addSerializer( ProjectVersionRef.class, new ProjectRefSerializer( ProjectVersionRef.class ) ); + + addDeserializer( ProjectVersionRef.class, + new ProjectRefDeserializer( ProjectVersionRef.class ) ); + + // ArtifactRef + addSerializer( ArtifactRef.class, new ProjectRefSerializer( ArtifactRef.class ) ); + + addDeserializer( ArtifactRef.class, new ProjectRefDeserializer( ArtifactRef.class ) ); + + // VersionlessArtifactRef + addSerializer( VersionlessArtifactRef.class, + new ProjectRefSerializer( VersionlessArtifactRef.class ) ); + + addDeserializer( VersionlessArtifactRef.class, + new ProjectRefDeserializer( VersionlessArtifactRef.class ) ); + } + + @Override + public int hashCode() + { + return getClass().getSimpleName() + .hashCode() + 17; + } + + @Override + public boolean equals( final Object other ) + { + return getClass().equals( other.getClass() ); + } + + private static final class ProjectRefSerializer + extends StdSerializer + { + ProjectRefSerializer( final Class refCls ) + { + super( refCls ); + } + + @Override + public void serialize( final T src, final JsonGenerator generator, + final SerializerProvider provider ) + throws IOException, JsonGenerationException + { + generator.writeString( src.toString() ); + } + } + + private static final class ProjectRefDeserializer + extends StdDeserializer + { + private static final long serialVersionUID = 1L; + + private final Class refCls; + + ProjectRefDeserializer( final Class refCls ) + { + super( refCls ); + this.refCls = refCls; + } + + @Override + public T deserialize( final JsonParser jp, final DeserializationContext ctxt ) + throws IOException, JsonProcessingException + { + try + { + final Method parseMethod = refCls.getMethod( "parse", String.class ); + return refCls.cast( parseMethod.invoke( null, jp.getText() ) ); + } + catch ( final NoSuchMethodException e ) + { + throw new IOException( "Failed to lookup/invoke parse() method on " + refCls.getSimpleName(), e ); + } + catch ( final IllegalAccessException e ) + { + throw new IOException( "Failed to lookup/invoke parse() method on " + refCls.getSimpleName(), e ); + } + catch ( final InvocationTargetException e ) + { + throw new IOException( "Failed to lookup/invoke parse() method on " + refCls.getSimpleName(), e ); + } + } + } + +} diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml new file mode 100644 index 00000000..5bb7b0ce --- /dev/null +++ b/bindings/jackson-relationships/pom.xml @@ -0,0 +1,47 @@ + + + + 4.0.0 + + + org.commonjava.maven.atlas + atlas-bindings-parent + 0.14.1-SNAPSHOT + + + atlas-bindings-jackson-relationships + + Atlas :: Maven Project-Graph :: Jackson Relationships API Bindings + + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-core + + + org.commonjava.maven.atlas + atlas-relationships-api + + + + diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java new file mode 100644 index 00000000..0b7f64a6 --- /dev/null +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java @@ -0,0 +1,256 @@ +/** + * Copyright (C) 2011 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.jackson; + +import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.CURRENT_JSON_VERSION; +import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.DECLARING_REF; +import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.INDEX; +import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.JSON_VERSION; +import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.MANAGED; +import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.PLUGIN_REF; +import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.POM_LOCATION_URI; +import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.RELATIONSHIP_TYPE; +import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.SCOPE; +import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.TARGET_REF; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +import org.commonjava.maven.atlas.graph.rel.BomRelationship; +import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; +import org.commonjava.maven.atlas.graph.rel.ParentRelationship; +import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.PluginRelationship; +import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.io.SerializedString; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +public class ProjectRelationshipSerializerModule + extends SimpleModule +{ + + private static final long serialVersionUID = 1L; + + public ProjectRelationshipSerializerModule() + { + super( "ProjectRelationship Serializer" ); + addSerializer( ProjectRelationship.class, new ProjectRelationshipSerializer() ); + addDeserializer( ProjectRelationship.class, new ProjectRelationshipDeserializer() ); + } + + @Override + public int hashCode() + { + return getClass().getSimpleName() + .hashCode() + 17; + } + + @Override + public boolean equals( final Object other ) + { + return getClass().equals( other.getClass() ); + } + + @SuppressWarnings( "rawtypes" ) + private static final class ProjectRelationshipSerializer + extends StdSerializer + { + ProjectRelationshipSerializer() + { + super( ProjectRelationship.class ); + } + + @SuppressWarnings( "incomplete-switch" ) + @Override + public void serialize( final ProjectRelationship value, final JsonGenerator gen, + final SerializerProvider provider ) + throws IOException, JsonGenerationException + { + gen.writeStartObject(); + gen.writeNumberField( JSON_VERSION.getValue(), SerializationConstants.CURRENT_JSON_VERSION ); + gen.writeStringField( RELATIONSHIP_TYPE.getValue(), value.getType().name() ); + provider.defaultSerializeField( DECLARING_REF.getValue(), value.getDeclaring(), gen ); + provider.defaultSerializeField( TARGET_REF.getValue(), value.getTarget(), gen ); + gen.writeNumberField(INDEX.getValue(), value.getIndex()); + + switch ( value.getType() ) + { + case DEPENDENCY: + { + gen.writeStringField( SCOPE.getValue(), ( (DependencyRelationship) value ).getScope() + .realName() ); + break; + } + case PLUGIN_DEP: + { + provider.defaultSerializeField( PLUGIN_REF.getValue(), ( (PluginDependencyRelationship) value ).getPlugin(), gen ); + break; + } + } + gen.writeEndObject(); + } + + } + + @SuppressWarnings( "rawtypes" ) + private static final class ProjectRelationshipDeserializer + extends StdDeserializer + { + private static final long serialVersionUID = 1L; + + ProjectRelationshipDeserializer() + { + super( ProjectRelationship.class ); + } + + @Override + public ProjectRelationship deserialize( final JsonParser jp, final DeserializationContext ctx ) + throws IOException, JsonProcessingException + { + final int version = expectField( jp, JSON_VERSION ).nextIntValue( CURRENT_JSON_VERSION ); + if ( version > CURRENT_JSON_VERSION ) + { + throw new JsonParseException( "Cannot deserialize ProjectRelationship JSON with version: " + version, + jp.getCurrentLocation() ); + } + + final JsonDeserializer prDeser = + ctx.findRootValueDeserializer( ctx.getTypeFactory() + .constructType( ProjectRef.class ) ); + final JsonDeserializer pvrDeser = + ctx.findRootValueDeserializer( ctx.getTypeFactory() + .constructType( ProjectVersionRef.class ) ); + final JsonDeserializer arDeser = + ctx.findRootValueDeserializer( ctx.getTypeFactory() + .constructType( ArtifactRef.class ) ); + + final RelationshipType type = + RelationshipType.getType( expectField( jp, RELATIONSHIP_TYPE ).nextTextValue() ); + + expectField( jp, DECLARING_REF ).nextTextValue(); + final ProjectVersionRef declaring = (ProjectVersionRef) pvrDeser.deserialize( jp, ctx ); + + final String uri = expectField( jp, POM_LOCATION_URI ).nextTextValue(); + URI pomLocation; + try + { + pomLocation = new URI( uri ); + } + catch ( final URISyntaxException e ) + { + throw new JsonParseException( "Invalid " + POM_LOCATION_URI + ": '" + uri + "': " + + e.getMessage(), jp.getCurrentLocation(), e ); + } + + switch ( type ) + { + case DEPENDENCY: + { + expectField( jp, TARGET_REF ).nextTextValue(); + final ArtifactRef target = (ArtifactRef) arDeser.deserialize( jp, ctx ); + + final DependencyScope scope = DependencyScope.getScope( expectField( jp, SCOPE ).nextTextValue() ); + + return new DependencyRelationship( pomLocation, declaring, target, scope, getIndex( jp ), + isManaged( jp ) ); + } + case EXTENSION: + { + expectField( jp, TARGET_REF ).nextTextValue(); + final ProjectVersionRef target = (ProjectVersionRef) pvrDeser.deserialize( jp, ctx ); + + return new ExtensionRelationship( pomLocation, declaring, target, getIndex( jp ) ); + } + case PARENT: + { + expectField( jp, TARGET_REF ).nextTextValue(); + final ProjectVersionRef target = (ProjectVersionRef) pvrDeser.deserialize( jp, ctx ); + + return new ParentRelationship( pomLocation, declaring, target ); + } + case PLUGIN: + { + expectField( jp, TARGET_REF ).nextTextValue(); + final ProjectVersionRef target = (ProjectVersionRef) pvrDeser.deserialize( jp, ctx ); + + return new PluginRelationship( pomLocation, declaring, target, getIndex( jp ), isManaged( jp ) ); + } + case PLUGIN_DEP: + { + expectField( jp, PLUGIN_REF ).nextTextValue(); + final ProjectRef plugin = (ProjectRef) prDeser.deserialize( jp, ctx ); + + expectField( jp, TARGET_REF ).nextTextValue(); + final ArtifactRef target = (ArtifactRef) arDeser.deserialize( jp, ctx ); + + return new PluginDependencyRelationship( pomLocation, declaring, plugin, target, getIndex( jp ), + isManaged( jp ) ); + } + case BOM: + { + expectField( jp, TARGET_REF ).nextTextValue(); + final ProjectVersionRef target = (ProjectVersionRef) pvrDeser.deserialize( jp, ctx ); + + return new BomRelationship( pomLocation, declaring, target, getIndex( jp ) ); + } + } + + return null; + } + + private JsonParser expectField( final JsonParser jp, final SerializedString named ) + throws JsonParseException, IOException + { + if ( !jp.nextFieldName( named ) ) + { + throw new JsonParseException( "Expected field: " + named, jp.getCurrentLocation() ); + } + + return jp; + } + + private boolean isManaged( final JsonParser jp ) + throws JsonParseException, IOException + { + return expectField( jp, MANAGED ).nextBooleanValue(); + } + + private int getIndex( final JsonParser jp ) + throws JsonParseException, IOException + { + return expectField( jp, INDEX ).nextIntValue( 0 ); + } + } + +} diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java new file mode 100644 index 00000000..b5f3c576 --- /dev/null +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java @@ -0,0 +1,67 @@ +/** + * Copyright (C) 2011 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.jackson; + +import com.fasterxml.jackson.core.io.SerializedString; + +public final class SerializationConstants +{ + + private SerializationConstants() + { + } + + public static final SerializedString SOURCE_URIS = new SerializedString( "source-uris" ); + + public static final SerializedString SOURCE_URI = new SerializedString( "source-uri" ); + + public static final SerializedString POM_LOCATION_URI = new SerializedString( "pom-location-uri" ); + + public static final SerializedString PROJECT_VERSION = new SerializedString( "gav" ); + + public static final SerializedString GAV = PROJECT_VERSION; + + public static final SerializedString RELATIONSHIP_TYPE = new SerializedString( "rel" ); + + public static final SerializedString DECLARING_REF = new SerializedString( "declaring" ); + + public static final SerializedString TARGET_REF = new SerializedString( "target" ); + + public static final SerializedString INDEX = new SerializedString( "idx" ); + + public static final SerializedString MANAGED = new SerializedString( "managed" ); + + public static final SerializedString SCOPE = new SerializedString( "scope" ); + + public static final SerializedString PLUGIN_REF = new SerializedString( "plugin" ); + + public static final SerializedString JSON_VERSION = new SerializedString( "jsonVersion" ); + + public static final int CURRENT_JSON_VERSION = 1; + + public static final SerializedString EPROJECT_KEY = new SerializedString( "ekey" ); + + public static final SerializedString RELATIONSHIPS = new SerializedString( "relationships" ); + + public static final SerializedString EPROFILES = new SerializedString( "eprofiles" ); + + public static final SerializedString CYCLES = new SerializedString( "cycles" ); + + public static final SerializedString WEB_ROOTS = new SerializedString( "gavs" ); + + public static final SerializedString GAVS = WEB_ROOTS; + +} diff --git a/bindings/pom.xml b/bindings/pom.xml new file mode 100644 index 00000000..853afc1a --- /dev/null +++ b/bindings/pom.xml @@ -0,0 +1,44 @@ + + + + 4.0.0 + + + org.commonjava.maven.atlas + atlas-parent + 0.14.1-SNAPSHOT + + + atlas-bindings-parent + pom + + Atlas :: Maven Project-Graph :: Bindings Parent + + + + org.commonjava.maven.atlas + atlas-relationships-api + + + + + jackson-identities + jackson-relationships + + diff --git a/pom.xml b/pom.xml index 493e8ed0..32f31d4f 100644 --- a/pom.xml +++ b/pom.xml @@ -130,5 +130,6 @@ relationships-api tck drivers + bindings From e5f78a15ea445407ffc0365fba1758f7a38c1a06 Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 16 Jul 2015 10:31:17 -0500 Subject: [PATCH 074/240] update parent pom to add victi.ms and direct-dependency enforcer rules --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 32f31d4f..89bd3c3f 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.commonjava commonjava - 7 + 9-SNAPSHOT org.commonjava.maven.atlas From de1a8d476f6bb987081ba4413e9c0e04dafc7a52 Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 31 Jul 2015 16:37:50 -0500 Subject: [PATCH 075/240] use released parent --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 89bd3c3f..69000fe6 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.commonjava commonjava - 9-SNAPSHOT + 9 org.commonjava.maven.atlas From f21480a83c99bf69e0b8f84fc1f0bf7f4a005d35 Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 31 Jul 2015 17:37:25 -0500 Subject: [PATCH 076/240] Fixing license headers. --- .../ProjectVersionRefSerializerModule.java | 2 +- .../ProjectRelationshipSerializerModule.java | 2 +- .../graph/jackson/SerializationConstants.java | 2 +- travis-settings.xml | 17 +++++++++++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java index bb9334b3..9b02bcff 100644 --- a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java +++ b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2011 Red Hat, Inc. (jdcasey@commonjava.org) + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java index 0b7f64a6..c42da782 100644 --- a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2011 Red Hat, Inc. (jdcasey@commonjava.org) + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java index b5f3c576..0fbc0819 100644 --- a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2011 Red Hat, Inc. (jdcasey@commonjava.org) + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/travis-settings.xml b/travis-settings.xml index 3fe92474..377f1262 100644 --- a/travis-settings.xml +++ b/travis-settings.xml @@ -1,3 +1,20 @@ + From ec9ab7918b288c61bf3d1e56a1245841bd7662ce Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 31 Jul 2015 17:40:09 -0500 Subject: [PATCH 077/240] [maven-release-plugin] prepare release atlas-parent-0.14.1 --- bindings/jackson-identities/pom.xml | 2 +- bindings/jackson-relationships/pom.xml | 2 +- bindings/pom.xml | 2 +- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 2aa359f8..765e983f 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.14.1-SNAPSHOT + 0.14.1 atlas-bindings-jackson-identities diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml index 5bb7b0ce..30f663d4 100644 --- a/bindings/jackson-relationships/pom.xml +++ b/bindings/jackson-relationships/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.14.1-SNAPSHOT + 0.14.1 atlas-bindings-jackson-relationships diff --git a/bindings/pom.xml b/bindings/pom.xml index 853afc1a..a09378c5 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.1-SNAPSHOT + 0.14.1 atlas-bindings-parent diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index 517290ea..d22baf46 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.14.1-SNAPSHOT + 0.14.1 atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 12e116e4..02534a07 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.14.1-SNAPSHOT + 0.14.1 atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index a55f7924..685a6a73 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.1-SNAPSHOT + 0.14.1 atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index 8cfce540..6c456558 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.1-SNAPSHOT + 0.14.1 atlas-identities diff --git a/pom.xml b/pom.xml index 69000fe6..96cccaaa 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.1-SNAPSHOT + 0.14.1 pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - HEAD + atlas-parent-0.14.1 @@ -48,17 +48,17 @@ org.commonjava.maven.atlas atlas-identities - 0.14.1-SNAPSHOT + 0.14.1 org.commonjava.maven.atlas atlas-relationships-api - 0.14.1-SNAPSHOT + 0.14.1 org.commonjava.maven.atlas atlas-drivers-tck - 0.14.1-SNAPSHOT + 0.14.1 test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 0638f889..7298a566 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.1-SNAPSHOT + 0.14.1 atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index fe064fe2..79daefa3 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.1-SNAPSHOT + 0.14.1 atlas-drivers-tck From 9a68083d8678f1e094605887b25b248938575026 Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 31 Jul 2015 17:40:11 -0500 Subject: [PATCH 078/240] [maven-release-plugin] prepare for next development iteration --- bindings/jackson-identities/pom.xml | 2 +- bindings/jackson-relationships/pom.xml | 2 +- bindings/pom.xml | 2 +- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 765e983f..dc7be63e 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.14.1 + 0.14.2-SNAPSHOT atlas-bindings-jackson-identities diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml index 30f663d4..44e41136 100644 --- a/bindings/jackson-relationships/pom.xml +++ b/bindings/jackson-relationships/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.14.1 + 0.14.2-SNAPSHOT atlas-bindings-jackson-relationships diff --git a/bindings/pom.xml b/bindings/pom.xml index a09378c5..e91ebee8 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.1 + 0.14.2-SNAPSHOT atlas-bindings-parent diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index d22baf46..9b6b7fe6 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.14.1 + 0.14.2-SNAPSHOT atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 02534a07..90ee1e16 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.14.1 + 0.14.2-SNAPSHOT atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 685a6a73..2cd13c8a 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.1 + 0.14.2-SNAPSHOT atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index 6c456558..e6dacc63 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.1 + 0.14.2-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index 96cccaaa..a21416dc 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.1 + 0.14.2-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - atlas-parent-0.14.1 + HEAD @@ -48,17 +48,17 @@ org.commonjava.maven.atlas atlas-identities - 0.14.1 + 0.14.2-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.14.1 + 0.14.2-SNAPSHOT org.commonjava.maven.atlas atlas-drivers-tck - 0.14.1 + 0.14.2-SNAPSHOT test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 7298a566..d7354d47 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.1 + 0.14.2-SNAPSHOT atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 79daefa3..cad8cf13 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.1 + 0.14.2-SNAPSHOT atlas-drivers-tck From 72fcbb7a00008b7631350e910f61c879ac31a7bb Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 30 Jul 2015 14:38:21 -0500 Subject: [PATCH 079/240] changes supporting ops refactor in cartographer. --- .../ProjectVersionRefSerializerModule.java | 88 ++++++++++++++----- ...ProjectVersionRefSerializerModuleTest.java | 59 +++++++++++++ .../maven/atlas/ident/util/JoinString.java | 5 +- .../maven/atlas/graph/RelationshipGraph.java | 36 +++++++- .../graph/filter/RelationshipTypeFilter.java | 60 +++++++++++++ .../atlas/graph/rel/ParentRelationship.java | 31 ++++++- .../graph/traverse/BuildOrderTraversal.java | 46 ++++++++++ .../atlas/graph/util/RelationshipUtils.java | 20 ++--- 8 files changed, 309 insertions(+), 36 deletions(-) create mode 100644 bindings/jackson-identities/src/test/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModuleTest.java create mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/RelationshipTypeFilter.java diff --git a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java index 9b02bcff..51ab9e58 100644 --- a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java +++ b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java @@ -23,6 +23,8 @@ import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; import org.commonjava.maven.atlas.ident.ref.VersionlessArtifactRef; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; @@ -31,6 +33,7 @@ import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.deser.std.StdKeyDeserializer; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.ser.std.StdSerializer; @@ -38,34 +41,52 @@ public class ProjectVersionRefSerializerModule extends SimpleModule { + private final Logger logger = LoggerFactory.getLogger( getClass() ); + private static final long serialVersionUID = 1L; public ProjectVersionRefSerializerModule() { super( "ProjectRef (with variants) Serializer" ); + logger.debug( "Registering ProjectRef serializer/deserialer" ); // ProjectRef addSerializer( ProjectRef.class, new ProjectRefSerializer( ProjectRef.class ) ); + addKeySerializer( ProjectRef.class, new ProjectRefSerializer( ProjectRef.class ) ); addDeserializer( ProjectRef.class, new ProjectRefDeserializer( ProjectRef.class ) ); + addKeyDeserializer( ProjectRef.class, new ProjectRefKeyDeserializer( ProjectRef.class ) ); + logger.debug( "Registering ProjectVersionRef serializer/deserialer" ); // ProjectVersionRef addSerializer( ProjectVersionRef.class, new ProjectRefSerializer( ProjectVersionRef.class ) ); + addKeySerializer( ProjectVersionRef.class, + new ProjectRefSerializer( ProjectVersionRef.class ) ); addDeserializer( ProjectVersionRef.class, new ProjectRefDeserializer( ProjectVersionRef.class ) ); + addKeyDeserializer( ProjectVersionRef.class, + new ProjectRefKeyDeserializer( ProjectVersionRef.class ) ); + logger.debug( "Registering ArtifactRef serializer/deserialer" ); // ArtifactRef addSerializer( ArtifactRef.class, new ProjectRefSerializer( ArtifactRef.class ) ); + addKeySerializer( ArtifactRef.class, new ProjectRefSerializer( ArtifactRef.class ) ); addDeserializer( ArtifactRef.class, new ProjectRefDeserializer( ArtifactRef.class ) ); + addKeyDeserializer( ArtifactRef.class, new ProjectRefKeyDeserializer( ArtifactRef.class ) ); + logger.debug( "Registering VersionlessArtifactRef serializer/deserialer" ); // VersionlessArtifactRef addSerializer( VersionlessArtifactRef.class, new ProjectRefSerializer( VersionlessArtifactRef.class ) ); + addKeySerializer( VersionlessArtifactRef.class, + new ProjectRefSerializer( VersionlessArtifactRef.class ) ); addDeserializer( VersionlessArtifactRef.class, new ProjectRefDeserializer( VersionlessArtifactRef.class ) ); + addKeyDeserializer( VersionlessArtifactRef.class, + new ProjectRefKeyDeserializer( VersionlessArtifactRef.class ) ); } @Override @@ -81,6 +102,28 @@ public boolean equals( final Object other ) return getClass().equals( other.getClass() ); } + private T parse( final String value, final Class type ) + throws IOException + { + try + { + final Method parseMethod = type.getMethod( "parse", String.class ); + return type.cast( parseMethod.invoke( null, value ) ); + } + catch ( final NoSuchMethodException e ) + { + throw new IOException( "Failed to lookup/invoke parse() method on " + type.getSimpleName(), e ); + } + catch ( final IllegalAccessException e ) + { + throw new IOException( "Failed to lookup/invoke parse() method on " + type.getSimpleName(), e ); + } + catch ( final InvocationTargetException e ) + { + throw new IOException( "Failed to lookup/invoke parse() method on " + type.getSimpleName(), e ); + } + } + private static final class ProjectRefSerializer extends StdSerializer { @@ -90,15 +133,14 @@ private static final class ProjectRefSerializer } @Override - public void serialize( final T src, final JsonGenerator generator, - final SerializerProvider provider ) + public void serialize( final T src, final JsonGenerator generator, final SerializerProvider provider ) throws IOException, JsonGenerationException { generator.writeString( src.toString() ); } } - private static final class ProjectRefDeserializer + private class ProjectRefDeserializer extends StdDeserializer { private static final long serialVersionUID = 1L; @@ -115,24 +157,30 @@ private static final class ProjectRefDeserializer public T deserialize( final JsonParser jp, final DeserializationContext ctxt ) throws IOException, JsonProcessingException { - try - { - final Method parseMethod = refCls.getMethod( "parse", String.class ); - return refCls.cast( parseMethod.invoke( null, jp.getText() ) ); - } - catch ( final NoSuchMethodException e ) - { - throw new IOException( "Failed to lookup/invoke parse() method on " + refCls.getSimpleName(), e ); - } - catch ( final IllegalAccessException e ) - { - throw new IOException( "Failed to lookup/invoke parse() method on " + refCls.getSimpleName(), e ); - } - catch ( final InvocationTargetException e ) - { - throw new IOException( "Failed to lookup/invoke parse() method on " + refCls.getSimpleName(), e ); - } + return parse( jp.getText(), refCls ); + } + } + + public class ProjectRefKeyDeserializer + extends StdKeyDeserializer + { + private static final long serialVersionUID = 1L; + + private final Class refCls; + + public ProjectRefKeyDeserializer( final Class type ) + { + super( type ); + this.refCls = type; + } + + @Override + protected Object _parse( final String key, final DeserializationContext ctxt ) + throws Exception + { + return parse( key, refCls ); } + } } diff --git a/bindings/jackson-identities/src/test/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModuleTest.java b/bindings/jackson-identities/src/test/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModuleTest.java new file mode 100644 index 00000000..0bca69b7 --- /dev/null +++ b/bindings/jackson-identities/src/test/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModuleTest.java @@ -0,0 +1,59 @@ +package org.commonjava.maven.atlas.ident.jackson; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.util.HashMap; +import java.util.Map; + +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.junit.Before; +import org.junit.Test; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class ProjectVersionRefSerializerModuleTest +{ + + private ObjectMapper mapper; + + @Before + public void setup() + { + mapper = new ObjectMapper(); + mapper.registerModule( new ProjectVersionRefSerializerModule() ); + } + + @Test + public void projectRefRoundTrip() + throws Exception + { + final ProjectRef pr = new ProjectRef( "org.foo", "bar" ); + final String json = mapper.writeValueAsString( pr ); + + final ProjectRef result = mapper.readValue( json, ProjectRef.class ); + + assertThat( result, equalTo( pr ) ); + } + + @Test + public void mapWithProjectRefKeyRoundTrip() + throws Exception + { + final ProjectRef pr = new ProjectRef( "org.foo", "bar" ); + final String value = "this is the value"; + + final Map map = new HashMap(); + map.put( pr, value ); + + final String json = mapper.writeValueAsString( map ); + + final Map result = mapper.readValue( json, new TypeReference>() + { + } ); + + assertThat( result.get( pr ), equalTo( value ) ); + } + +} diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/JoinString.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/JoinString.java index 1315c2e9..a2054319 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/JoinString.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/JoinString.java @@ -19,6 +19,7 @@ import java.util.Arrays; import java.util.Collection; +import java.util.Collections; public class JoinString { @@ -30,13 +31,13 @@ public class JoinString public JoinString( final String joint, final Collection items ) { this.joint = joint; - this.items = items; + this.items = items == null ? Collections.emptyList() : items; } public JoinString( final String joint, final Object[] items ) { this.joint = joint; - this.items = Arrays.asList( items ); + this.items = items == null ? Collections.emptyList() : Arrays.asList( items ); } @Override diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java index 6a48911d..1f65d362 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java @@ -17,6 +17,8 @@ import static org.apache.commons.lang.StringUtils.join; +import java.io.Closeable; +import java.io.IOException; import java.net.URI; import java.util.ArrayList; import java.util.Arrays; @@ -46,6 +48,7 @@ import org.slf4j.LoggerFactory; public final class RelationshipGraph + implements Closeable { private final Logger logger = LoggerFactory.getLogger( getClass() ); @@ -194,15 +197,23 @@ public synchronized void forceClose() } } + @Override public synchronized void close() - throws RelationshipGraphException + throws IOException { userCount--; logger.info( "User count decremented to: {} for: {}", userCount, params ); if ( userCount < 1 ) { - forceClose(); + try + { + forceClose(); + } + catch ( final RelationshipGraphException e ) + { + throw new IOException( "Failed to close graph.", e ); + } } logger.info( "NOT closing; there are other users registered!" ); @@ -557,6 +568,15 @@ public Set> findDirectRelationshipsTo( final ProjectVersi return getConnectionInternal().getDirectRelationshipsTo( params, to, includeManagedInfo, true, types ); } + public Set> findDirectRelationshipsTo( final ProjectVersionRef to, + final boolean includeManagedInfo, + final boolean includeConcreteInfo, + final RelationshipType... types ) + { + return getConnectionInternal().getDirectRelationshipsTo( params, to, includeManagedInfo, includeConcreteInfo, + types ); + } + public Set> findDirectRelationshipsFrom( final ProjectVersionRef source, final boolean managed, final RelationshipType... types ) @@ -564,6 +584,13 @@ public Set> findDirectRelationshipsFrom( final ProjectVer return getConnectionInternal().getDirectRelationshipsFrom( params, source, managed, true, types ); } + public Set> findDirectRelationshipsFrom( final ProjectVersionRef source, + final boolean managed, final boolean concrete, + final RelationshipType... types ) + { + return getConnectionInternal().getDirectRelationshipsFrom( params, source, managed, concrete, types ); + } + public Set getAllIncompleteSubgraphs() { return getConnectionInternal().getMissingProjects( params ); @@ -729,4 +756,9 @@ private synchronized RelationshipGraphConnection getConnectionInternal() return connection; } + public Collection> getRelationshipsDeclaring( final ProjectVersionRef root ) + { + return getConnectionInternal().getRelationshipsDeclaredBy( params, root ); + } + } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/RelationshipTypeFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/RelationshipTypeFilter.java new file mode 100644 index 00000000..16f8c40d --- /dev/null +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/RelationshipTypeFilter.java @@ -0,0 +1,60 @@ +package org.commonjava.maven.atlas.graph.filter; + +import java.util.Collection; +import java.util.Set; + +import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.RelationshipType; + +public class RelationshipTypeFilter + extends AbstractTypedFilter +{ + + private static final long serialVersionUID = 1L; + + public RelationshipTypeFilter( final Collection types, final boolean includeManagedInfo, + final boolean includeConcreteInfo ) + { + super( types, types, includeManagedInfo, includeManagedInfo ); + } + + public RelationshipTypeFilter( final Collection types, + final Collection descendantTypes, + final boolean includeManagedInfo, final boolean includeConcreteInfo ) + { + super( types, descendantTypes, includeManagedInfo, includeConcreteInfo ); + } + + public RelationshipTypeFilter( final RelationshipType type, final boolean hasDescendants, + final boolean includeManagedInfo, final boolean includeConcreteInfo ) + { + super( type, hasDescendants, includeManagedInfo, includeConcreteInfo ); + } + + public RelationshipTypeFilter( final RelationshipType type, final Collection descendantTypes, + final boolean includeManagedInfo, final boolean includeConcreteInfo ) + { + super( type, descendantTypes, includeManagedInfo, includeConcreteInfo ); + } + + public RelationshipTypeFilter( final RelationshipType type, final RelationshipType descendantType, + final boolean includeManagedInfo, final boolean includeConcreteInfo ) + { + super( type, descendantType, includeManagedInfo, includeConcreteInfo ); + } + + @Override + public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) + { + final Set descendantTypes = getDescendantRelationshipTypes(); + final Set allowedTypes = getAllowedTypes(); + if ( !allowedTypes.equals( descendantTypes ) ) + { + return new RelationshipTypeFilter( descendantTypes, includeManagedRelationships(), + includeConcreteRelationships() ); + } + + return this; + } + +} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java index 49fb3006..8fcc0191 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java @@ -17,6 +17,7 @@ import java.io.Serializable; import java.net.URI; +import java.net.URISyntaxException; import java.util.Collection; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; @@ -30,12 +31,38 @@ public final class ParentRelationship private static final long serialVersionUID = 1L; + public static final URI TERMINAL_PARENT_SOURCE_URI; + static + { + final String uri = "atlas:terminal-parent"; + try + { + TERMINAL_PARENT_SOURCE_URI = new URI( uri ); + } + catch ( final URISyntaxException e ) + { + throw new IllegalStateException( "Terminal-parent source URI constant is invalid: " + uri, e ); + } + + } + + /** + * Ancestry terminus. This is to signify that the declaring project has NO parent relationship. + */ + public ParentRelationship( final ProjectVersionRef declaring ) + { + super( TERMINAL_PARENT_SOURCE_URI, RelationshipType.PARENT, declaring, declaring, 0 ); + } + /** * Ancestry terminus. This is to signify that the declaring project has NO parent relationship. + * This form is deprecated. + * @see ParentRelationship#ParentRelationship(ProjectVersionRef) */ - public ParentRelationship( final URI source, final ProjectVersionRef declaring ) + @Deprecated + public ParentRelationship( final URI unused, final ProjectVersionRef declaring ) { - super( source, RelationshipType.PARENT, declaring, declaring, 0 ); + super( TERMINAL_PARENT_SOURCE_URI, RelationshipType.PARENT, declaring, declaring, 0 ); } public ParentRelationship( final URI source, final ProjectVersionRef declaring, final ProjectVersionRef target ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java index 8d82295b..84a3a90e 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java @@ -41,6 +41,8 @@ public class BuildOrderTraversal private Set cycles; + private Set allowedProjects; + public BuildOrderTraversal() { } @@ -50,6 +52,11 @@ public BuildOrderTraversal( final ProjectRelationshipFilter filter ) super( new OrFilter( filter, ParentFilter.EXCLUDE_TERMINAL_PARENTS ) ); } + public BuildOrderTraversal( final Set allowedProjects ) + { + this.allowedProjects = allowedProjects; + } + public BuildOrder getBuildOrder() { return new BuildOrder( order, cycles ); @@ -59,6 +66,11 @@ public BuildOrder getBuildOrder() protected boolean shouldTraverseEdge( final ProjectRelationship relationship, final List> path ) { + if ( !verifyProjectsAllowed( relationship, path ) ) + { + return false; + } + final ProjectVersionRef decl = relationship.getDeclaring(); ProjectVersionRef target = relationship.getTarget(); @@ -86,6 +98,40 @@ protected boolean shouldTraverseEdge( final ProjectRelationship relationship, return true; } + private boolean verifyProjectsAllowed( final ProjectRelationship relationship, + final List> path ) + { + if ( allowedProjects == null ) + { + return true; + } + else if ( allowedProjects.isEmpty() ) + { + return false; + } + + if ( !verifyRelationshipProjectsAllowed( relationship ) ) + { + return false; + } + + for ( final ProjectRelationship rel : path ) + { + if ( !verifyRelationshipProjectsAllowed( rel ) ) + { + return false; + } + } + + return true; + } + + private boolean verifyRelationshipProjectsAllowed( final ProjectRelationship relationship ) + { + return allowedProjects == null + || ( allowedProjects.contains( relationship.getDeclaring() ) && allowedProjects.contains( relationship.getTarget() ) ); + } + @Override public void endTraverse( final RelationshipGraph graph ) throws RelationshipGraphConnectionException diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java index 5b5e229e..570d59d2 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java @@ -115,7 +115,7 @@ public static boolean isExcluded( final ProjectRef ref, final Collection>> mapByDeclaring( final Collection> relationships ) + public static Map>> mapByDeclaring( final Collection> relationships ) { final Logger logger = LoggerFactory.getLogger( RelationshipUtils.class ); logger.debug( "Mapping {} relationships by declaring GAV:\n\n {}\n\n", relationships.size(), new JoinString( "\n ", relationships ) ); @@ -158,9 +158,9 @@ public static URI profileLocation( final String profile ) } } - public static void filterTerminalParents( final Collection> rels ) + public static void filterTerminalParents( final Collection> rels ) { - for ( final Iterator> it = rels.iterator(); it.hasNext(); ) + for ( final Iterator> it = rels.iterator(); it.hasNext(); ) { final ProjectRelationship rel = it.next(); if ( ( rel instanceof ParentRelationship ) && ( (ParentRelationship) rel ).isTerminus() ) @@ -170,7 +170,7 @@ public static void filterTerminalParents( final Collection> rels, final RelationshipType... types ) + public static void filter( final Set> rels, final RelationshipType... types ) { if ( rels == null || rels.isEmpty() ) { @@ -183,7 +183,7 @@ public static void filter( final Set> rels, final Relatio } Arrays.sort( types ); - for ( final Iterator> iterator = rels.iterator(); iterator.hasNext(); ) + for ( final Iterator> iterator = rels.iterator(); iterator.hasNext(); ) { final ProjectRelationship rel = iterator.next(); if ( Arrays.binarySearch( types, rel.getType() ) < 0 ) @@ -193,7 +193,7 @@ public static void filter( final Set> rels, final Relatio } } - public static void filter( final Set> rels, final ProjectRelationshipFilter filter ) + public static void filter( final Set> rels, final ProjectRelationshipFilter filter ) { if ( filter == null || filter instanceof AnyFilter ) { @@ -205,7 +205,7 @@ public static void filter( final Set> rels, final Project return; } - for ( final Iterator> iterator = rels.iterator(); iterator.hasNext(); ) + for ( final Iterator> iterator = rels.iterator(); iterator.hasNext(); ) { final ProjectRelationship rel = iterator.next(); if ( !filter.accept( rel ) ) @@ -220,7 +220,7 @@ public static Set declarers( final ProjectRelationship... return declarers( Arrays.asList( relationships ) ); } - public static Set declarers( final Collection> relationships ) + public static Set declarers( final Collection> relationships ) { final Set results = new HashSet(); for ( final ProjectRelationship rel : relationships ) @@ -236,7 +236,7 @@ public static Set targets( final ProjectRelationship... re return targets( Arrays.asList( relationships ) ); } - public static Set targets( final Collection> relationships ) + public static Set targets( final Collection> relationships ) { if ( relationships == null ) { @@ -257,7 +257,7 @@ public static Set gavs( final ProjectRelationship... relat return gavs( Arrays.asList( relationships ) ); } - public static Set gavs( final Collection> relationships ) + public static Set gavs( final Collection> relationships ) { final Set results = new HashSet(); for ( final ProjectRelationship rel : relationships ) From 5dd82e64f092edd175699879b22113c526e8c85f Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 4 Aug 2015 14:52:06 -0500 Subject: [PATCH 080/240] prioritize relationship comparisons over path length in RelationshipPathComparator, and make the target refs more general purpose in PathsTraversal --- .../graph/rel/RelationshipPathComparator.java | 17 +++++++++-------- .../atlas/graph/traverse/PathsTraversal.java | 10 +++++----- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparator.java index 6141d5e7..e80f8b8a 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparator.java @@ -35,14 +35,6 @@ public int compare( final List> one, final List commonLen ) - { - return 1; - } - else if ( two.size() > commonLen ) - { - return -1; - } for ( int i = 0; i < commonLen; i++ ) { @@ -62,6 +54,15 @@ else if ( two.size() > commonLen ) } } + if ( one.size() > commonLen ) + { + return 1; + } + else if ( two.size() > commonLen ) + { + return -1; + } + return 0; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java index a9122e37..6d715e89 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java @@ -41,13 +41,13 @@ public class PathsTraversal private final ProjectRelationshipFilter rootFilter; - private final Set to; + private final Set to; private final Map cache = new HashMap(); private final Set>> paths = new HashSet>>(); - public PathsTraversal( final ProjectRelationshipFilter filter, final Set toGas ) + public PathsTraversal( final ProjectRelationshipFilter filter, final Set toGas ) { this.rootFilter = filter; this.to = toGas; @@ -56,7 +56,7 @@ public PathsTraversal( final ProjectRelationshipFilter filter, final Set relationship, final List> path ) { - ProjectVersionRef declaring = relationship.getDeclaring().asProjectVersionRef(); + final ProjectVersionRef declaring = relationship.getDeclaring().asProjectVersionRef(); if ( path.isEmpty() || path.get( path.size() - 1 ).getTarget().asProjectVersionRef().equals( declaring ) ) { final ProjectRef dRef = declaring.asProjectRef(); @@ -91,8 +91,8 @@ public boolean preCheck( final ProjectRelationship relationship, final List

( f.getFilters() ); if ( child instanceof OrFilter ) { - List childFilters = - (List) ( (OrFilter) child ).getFilters(); + final List childFilters = + ( (OrFilter) child ).getFilters(); if ( !filters.containsAll( childFilters ) ) { filters.addAll( childFilters ); From 31c3543e0db3090337c8d67d54134ba9424b7a80 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 11 Aug 2015 15:50:39 -0500 Subject: [PATCH 081/240] update BOM, and move bindings up above all the drivers that have huge test suites. --- .../ProjectVersionRefSerializerModule.java | 58 +++--- .../ProjectRelationshipSerializerModule.java | 188 ++++++++++++------ .../graph/jackson/SerializationConstants.java | 4 +- .../graph/spi/jung/JungGraphConnection.java | 2 +- .../graph/spi/jung/model/JungGraphPath.java | 6 +- .../spi/neo4j/FileNeo4JGraphConnection.java | 4 +- .../atlas/graph/spi/neo4j/GraphRelType.java | 6 +- .../maven/atlas/graph/spi/neo4j/NodeType.java | 2 +- .../atlas/graph/spi/neo4j/io/Conversions.java | 2 +- .../graph/spi/neo4j/model/CyclePath.java | 4 +- .../graph/spi/neo4j/model/Neo4jGraphPath.java | 6 +- .../graph/spi/neo4j/update/ViewUpdater.java | 7 +- .../maven/atlas/ident/DependencyScope.java | 4 +- .../maven/atlas/ident/ref/ProjectRef.java | 13 +- .../atlas/ident/version/RangeVersionSpec.java | 6 +- .../ident/version/part/SeparatorPart.java | 6 +- .../version/part/VersionPartSeparator.java | 2 +- pom.xml | 4 +- .../maven/atlas/graph/RelationshipGraph.java | 3 +- .../maven/atlas/graph/ViewParams.java | 3 +- .../maven/atlas/graph/filter/AndFilter.java | 1 - .../atlas/graph/filter/DependencyFilter.java | 6 +- .../graph/filter/DependencyOnlyFilter.java | 6 +- .../maven/atlas/graph/filter/OrFilter.java | 1 - .../atlas/graph/filter/ParentFilter.java | 12 +- .../atlas/graph/mutate/NoOpGraphMutator.java | 6 +- .../graph/mutate/VersionManagerMutator.java | 6 +- .../rel/AbstractProjectRelationship.java | 6 +- .../atlas/graph/rel/BomRelationship.java | 5 +- .../graph/rel/DependencyRelationship.java | 18 +- .../atlas/graph/rel/PluginRelationship.java | 6 +- .../atlas/graph/rel/RelationshipType.java | 2 +- .../atlas/graph/traverse/ImpactTraversal.java | 9 +- .../atlas/graph/traverse/TraversalType.java | 2 +- 34 files changed, 209 insertions(+), 207 deletions(-) diff --git a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java index 51ab9e58..fb7c3f43 100644 --- a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java +++ b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java @@ -19,6 +19,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import com.fasterxml.jackson.databind.KeyDeserializer; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; @@ -38,30 +39,30 @@ import com.fasterxml.jackson.databind.ser.std.StdSerializer; public class ProjectVersionRefSerializerModule - extends SimpleModule + extends SimpleModule { - private final Logger logger = LoggerFactory.getLogger( getClass() ); - private static final long serialVersionUID = 1L; public ProjectVersionRefSerializerModule() { super( "ProjectRef (with variants) Serializer" ); + Logger logger = LoggerFactory.getLogger( getClass() ); logger.debug( "Registering ProjectRef serializer/deserialer" ); // ProjectRef - addSerializer( ProjectRef.class, new ProjectRefSerializer( ProjectRef.class ) ); - addKeySerializer( ProjectRef.class, new ProjectRefSerializer( ProjectRef.class ) ); + addSerializer( ProjectRef.class, new ProjectRefSerializer( ProjectRef.class, false ) ); + addKeySerializer( ProjectRef.class, new ProjectRefSerializer( ProjectRef.class, true ) ); addDeserializer( ProjectRef.class, new ProjectRefDeserializer( ProjectRef.class ) ); addKeyDeserializer( ProjectRef.class, new ProjectRefKeyDeserializer( ProjectRef.class ) ); logger.debug( "Registering ProjectVersionRef serializer/deserialer" ); // ProjectVersionRef - addSerializer( ProjectVersionRef.class, new ProjectRefSerializer( ProjectVersionRef.class ) ); + addSerializer( ProjectVersionRef.class, + new ProjectRefSerializer( ProjectVersionRef.class, false ) ); addKeySerializer( ProjectVersionRef.class, - new ProjectRefSerializer( ProjectVersionRef.class ) ); + new ProjectRefSerializer( ProjectVersionRef.class, true ) ); addDeserializer( ProjectVersionRef.class, new ProjectRefDeserializer( ProjectVersionRef.class ) ); @@ -70,8 +71,8 @@ public ProjectVersionRefSerializerModule() logger.debug( "Registering ArtifactRef serializer/deserialer" ); // ArtifactRef - addSerializer( ArtifactRef.class, new ProjectRefSerializer( ArtifactRef.class ) ); - addKeySerializer( ArtifactRef.class, new ProjectRefSerializer( ArtifactRef.class ) ); + addSerializer( ArtifactRef.class, new ProjectRefSerializer( ArtifactRef.class, false ) ); + addKeySerializer( ArtifactRef.class, new ProjectRefSerializer( ArtifactRef.class, true ) ); addDeserializer( ArtifactRef.class, new ProjectRefDeserializer( ArtifactRef.class ) ); addKeyDeserializer( ArtifactRef.class, new ProjectRefKeyDeserializer( ArtifactRef.class ) ); @@ -79,9 +80,9 @@ public ProjectVersionRefSerializerModule() logger.debug( "Registering VersionlessArtifactRef serializer/deserialer" ); // VersionlessArtifactRef addSerializer( VersionlessArtifactRef.class, - new ProjectRefSerializer( VersionlessArtifactRef.class ) ); + new ProjectRefSerializer( VersionlessArtifactRef.class, false ) ); addKeySerializer( VersionlessArtifactRef.class, - new ProjectRefSerializer( VersionlessArtifactRef.class ) ); + new ProjectRefSerializer( VersionlessArtifactRef.class, true ) ); addDeserializer( VersionlessArtifactRef.class, new ProjectRefDeserializer( VersionlessArtifactRef.class ) ); @@ -92,8 +93,7 @@ public ProjectVersionRefSerializerModule() @Override public int hashCode() { - return getClass().getSimpleName() - .hashCode() + 17; + return getClass().getSimpleName().hashCode() + 17; } @Override @@ -103,7 +103,7 @@ public boolean equals( final Object other ) } private T parse( final String value, final Class type ) - throws IOException + throws IOException { try { @@ -125,23 +125,33 @@ private T parse( final String value, final Class type } private static final class ProjectRefSerializer - extends StdSerializer + extends StdSerializer { - ProjectRefSerializer( final Class refCls ) + private boolean keySer; + + ProjectRefSerializer( final Class refCls, boolean keySer ) { super( refCls ); + this.keySer = keySer; } @Override public void serialize( final T src, final JsonGenerator generator, final SerializerProvider provider ) - throws IOException, JsonGenerationException + throws IOException, JsonGenerationException { - generator.writeString( src.toString() ); + if ( keySer ) + { + generator.writeFieldName( src.toString() ); + } + else + { + generator.writeString( src.toString() ); + } } } private class ProjectRefDeserializer - extends StdDeserializer + extends StdDeserializer { private static final long serialVersionUID = 1L; @@ -155,14 +165,14 @@ private class ProjectRefDeserializer @Override public T deserialize( final JsonParser jp, final DeserializationContext ctxt ) - throws IOException, JsonProcessingException + throws IOException, JsonProcessingException { return parse( jp.getText(), refCls ); } } public class ProjectRefKeyDeserializer - extends StdKeyDeserializer + extends KeyDeserializer { private static final long serialVersionUID = 1L; @@ -170,17 +180,15 @@ public class ProjectRefKeyDeserializer public ProjectRefKeyDeserializer( final Class type ) { - super( type ); this.refCls = type; } @Override - protected Object _parse( final String key, final DeserializationContext ctxt ) - throws Exception + public Object deserializeKey( String key, DeserializationContext ctxt ) + throws IOException, JsonProcessingException { return parse( key, refCls ); } - } } diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java index c42da782..9fa60784 100644 --- a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java @@ -15,21 +15,15 @@ */ package org.commonjava.maven.atlas.graph.jackson; -import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.CURRENT_JSON_VERSION; -import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.DECLARING_REF; -import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.INDEX; -import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.JSON_VERSION; -import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.MANAGED; -import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.PLUGIN_REF; -import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.POM_LOCATION_URI; -import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.RELATIONSHIP_TYPE; -import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.SCOPE; -import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.TARGET_REF; - import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import com.fasterxml.jackson.core.*; import org.commonjava.maven.atlas.graph.rel.BomRelationship; import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; @@ -43,11 +37,6 @@ import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.io.SerializedString; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; @@ -55,9 +44,13 @@ import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.*; public class ProjectRelationshipSerializerModule - extends SimpleModule + extends SimpleModule { private static final long serialVersionUID = 1L; @@ -72,8 +65,7 @@ public ProjectRelationshipSerializerModule() @Override public int hashCode() { - return getClass().getSimpleName() - .hashCode() + 17; + return getClass().getSimpleName().hashCode() + 17; } @Override @@ -84,7 +76,7 @@ public boolean equals( final Object other ) @SuppressWarnings( "rawtypes" ) private static final class ProjectRelationshipSerializer - extends StdSerializer + extends StdSerializer { ProjectRelationshipSerializer() { @@ -95,29 +87,47 @@ private static final class ProjectRelationshipSerializer @Override public void serialize( final ProjectRelationship value, final JsonGenerator gen, final SerializerProvider provider ) - throws IOException, JsonGenerationException + throws IOException, JsonGenerationException { gen.writeStartObject(); - gen.writeNumberField( JSON_VERSION.getValue(), SerializationConstants.CURRENT_JSON_VERSION ); gen.writeStringField( RELATIONSHIP_TYPE.getValue(), value.getType().name() ); + gen.writeStringField( POM_LOCATION_URI.getValue(), value.getPomLocation().toString() ); + gen.writeArrayFieldStart( SOURCE_URIS.getValue() ); + + Set sources = value.getSources(); + for ( URI uri : sources ) + { + gen.writeString( uri.toString() ); + } + gen.writeEndArray(); provider.defaultSerializeField( DECLARING_REF.getValue(), value.getDeclaring(), gen ); provider.defaultSerializeField( TARGET_REF.getValue(), value.getTarget(), gen ); - gen.writeNumberField(INDEX.getValue(), value.getIndex()); switch ( value.getType() ) { case DEPENDENCY: { - gen.writeStringField( SCOPE.getValue(), ( (DependencyRelationship) value ).getScope() - .realName() ); + gen.writeStringField( SCOPE.getValue(), ( (DependencyRelationship) value ).getScope().realName() ); + gen.writeBooleanField( MANAGED.getValue(), value.isManaged() ); break; } case PLUGIN_DEP: { - provider.defaultSerializeField( PLUGIN_REF.getValue(), ( (PluginDependencyRelationship) value ).getPlugin(), gen ); + provider.defaultSerializeField( PLUGIN_REF.getValue(), + ( (PluginDependencyRelationship) value ).getPlugin(), gen ); + gen.writeBooleanField( MANAGED.getValue(), value.isManaged() ); + break; + } + case PLUGIN: + { + + gen.writeBooleanField( MANAGED.getValue(), value.isManaged() ); + gen.writeBooleanField( REPORTING.getValue(), ( (PluginRelationship) value ).isReporting() ); break; } } + + gen.writeNumberField( INDEX.getValue(), value.getIndex() ); gen.writeEndObject(); } @@ -125,7 +135,7 @@ public void serialize( final ProjectRelationship value, final JsonGenerator gen, @SuppressWarnings( "rawtypes" ) private static final class ProjectRelationshipDeserializer - extends StdDeserializer + extends StdDeserializer { private static final long serialVersionUID = 1L; @@ -136,30 +146,17 @@ private static final class ProjectRelationshipDeserializer @Override public ProjectRelationship deserialize( final JsonParser jp, final DeserializationContext ctx ) - throws IOException, JsonProcessingException + throws IOException, JsonProcessingException { - final int version = expectField( jp, JSON_VERSION ).nextIntValue( CURRENT_JSON_VERSION ); - if ( version > CURRENT_JSON_VERSION ) - { - throw new JsonParseException( "Cannot deserialize ProjectRelationship JSON with version: " + version, - jp.getCurrentLocation() ); - } - final JsonDeserializer prDeser = - ctx.findRootValueDeserializer( ctx.getTypeFactory() - .constructType( ProjectRef.class ) ); - final JsonDeserializer pvrDeser = - ctx.findRootValueDeserializer( ctx.getTypeFactory() - .constructType( ProjectVersionRef.class ) ); + ctx.findRootValueDeserializer( ctx.getTypeFactory().constructType( ProjectRef.class ) ); + final JsonDeserializer pvrDeser = ctx.findRootValueDeserializer( + ctx.getTypeFactory().constructType( ProjectVersionRef.class ) ); final JsonDeserializer arDeser = - ctx.findRootValueDeserializer( ctx.getTypeFactory() - .constructType( ArtifactRef.class ) ); + ctx.findRootValueDeserializer( ctx.getTypeFactory().constructType( ArtifactRef.class ) ); final RelationshipType type = - RelationshipType.getType( expectField( jp, RELATIONSHIP_TYPE ).nextTextValue() ); - - expectField( jp, DECLARING_REF ).nextTextValue(); - final ProjectVersionRef declaring = (ProjectVersionRef) pvrDeser.deserialize( jp, ctx ); + RelationshipType.getType( expectField( jp, RELATIONSHIP_TYPE ).nextTextValue() ); final String uri = expectField( jp, POM_LOCATION_URI ).nextTextValue(); URI pomLocation; @@ -169,10 +166,35 @@ public ProjectRelationship deserialize( final JsonParser jp, final Deserializati } catch ( final URISyntaxException e ) { - throw new JsonParseException( "Invalid " + POM_LOCATION_URI + ": '" + uri + "': " - + e.getMessage(), jp.getCurrentLocation(), e ); + throw new JsonParseException( "Invalid " + POM_LOCATION_URI + ": '" + uri + "': " + e.getMessage(), + jp.getCurrentLocation(), e ); } + Collection sources = new HashSet(); + expectField( jp, SOURCE_URIS ); + ff( jp, JsonToken.START_ARRAY ); + while ( jp.nextToken() != JsonToken.END_ARRAY && jp.getCurrentToken() != null ) + { + String u = jp.getText(); + if ( u == null ) + { + continue; + } + + try + { + sources.add( new URI( u ) ); + } + catch ( URISyntaxException e ) + { + throw new JsonParseException( "Failed to parse source URI: " + u, jp.getCurrentLocation() ); + } + } + + expectField( jp, DECLARING_REF ).nextTextValue(); + final ProjectVersionRef declaring = (ProjectVersionRef) pvrDeser.deserialize( jp, ctx ); + + ProjectRelationship rel = null; switch ( type ) { case DEPENDENCY: @@ -182,29 +204,34 @@ public ProjectRelationship deserialize( final JsonParser jp, final Deserializati final DependencyScope scope = DependencyScope.getScope( expectField( jp, SCOPE ).nextTextValue() ); - return new DependencyRelationship( pomLocation, declaring, target, scope, getIndex( jp ), - isManaged( jp ) ); + rel = new DependencyRelationship( sources, pomLocation, declaring, target, scope, getIndex( jp ), + isManaged( jp ) ); + break; } case EXTENSION: { expectField( jp, TARGET_REF ).nextTextValue(); final ProjectVersionRef target = (ProjectVersionRef) pvrDeser.deserialize( jp, ctx ); - return new ExtensionRelationship( pomLocation, declaring, target, getIndex( jp ) ); + rel = new ExtensionRelationship( sources, pomLocation, declaring, target, getIndex( jp ) ); + break; } case PARENT: { expectField( jp, TARGET_REF ).nextTextValue(); final ProjectVersionRef target = (ProjectVersionRef) pvrDeser.deserialize( jp, ctx ); - return new ParentRelationship( pomLocation, declaring, target ); + rel = new ParentRelationship( sources, declaring, target ); + break; } case PLUGIN: { expectField( jp, TARGET_REF ).nextTextValue(); final ProjectVersionRef target = (ProjectVersionRef) pvrDeser.deserialize( jp, ctx ); - return new PluginRelationship( pomLocation, declaring, target, getIndex( jp ), isManaged( jp ) ); + rel = new PluginRelationship( sources, pomLocation, declaring, target, getIndex( jp ), + isManaged( jp ), isReporting( jp ) ); + break; } case PLUGIN_DEP: { @@ -214,25 +241,57 @@ public ProjectRelationship deserialize( final JsonParser jp, final Deserializati expectField( jp, TARGET_REF ).nextTextValue(); final ArtifactRef target = (ArtifactRef) arDeser.deserialize( jp, ctx ); - return new PluginDependencyRelationship( pomLocation, declaring, plugin, target, getIndex( jp ), - isManaged( jp ) ); + rel = new PluginDependencyRelationship( sources, pomLocation, declaring, plugin, target, + getIndex( jp ), isManaged( jp ) ); + break; } case BOM: { expectField( jp, TARGET_REF ).nextTextValue(); final ProjectVersionRef target = (ProjectVersionRef) pvrDeser.deserialize( jp, ctx ); - return new BomRelationship( pomLocation, declaring, target, getIndex( jp ) ); + rel = new BomRelationship( sources, pomLocation, declaring, target, getIndex( jp ) ); + break; } } - return null; + while ( jp.getCurrentToken() != JsonToken.END_OBJECT ) + { + jp.nextToken(); + } + + return rel; + } + + private void ff( JsonParser jp, JsonToken token ) + throws JsonParseException, IOException + { + if ( jp.getCurrentToken() == token ) + { + return; + } + + JsonToken t = null; + do + { + t = jp.nextToken(); + if ( t == null ) + { + throw new JsonParseException( "Expected token: " + token, jp.getCurrentLocation() ); + } + } + while ( t != token ); } private JsonParser expectField( final JsonParser jp, final SerializedString named ) - throws JsonParseException, IOException + throws JsonParseException, IOException { - if ( !jp.nextFieldName( named ) ) + while ( jp.getCurrentToken() != null && !named.getValue().equals( jp.getCurrentName() ) ) + { + jp.nextToken(); + } + + if ( !named.getValue().equals( jp.getCurrentName() ) ) { throw new JsonParseException( "Expected field: " + named, jp.getCurrentLocation() ); } @@ -241,16 +300,23 @@ private JsonParser expectField( final JsonParser jp, final SerializedString name } private boolean isManaged( final JsonParser jp ) - throws JsonParseException, IOException + throws IOException { return expectField( jp, MANAGED ).nextBooleanValue(); } private int getIndex( final JsonParser jp ) - throws JsonParseException, IOException + throws IOException { return expectField( jp, INDEX ).nextIntValue( 0 ); } + + private boolean isReporting( final JsonParser jp ) + throws IOException + { + return expectField( jp, REPORTING ).nextBooleanValue(); + } + } } diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java index 0fbc0819..700d33c0 100644 --- a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java @@ -34,7 +34,7 @@ private SerializationConstants() public static final SerializedString GAV = PROJECT_VERSION; - public static final SerializedString RELATIONSHIP_TYPE = new SerializedString( "rel" ); + public static final SerializedString RELATIONSHIP_TYPE = new SerializedString( "type" ); public static final SerializedString DECLARING_REF = new SerializedString( "declaring" ); @@ -44,6 +44,8 @@ private SerializationConstants() public static final SerializedString MANAGED = new SerializedString( "managed" ); + public static final SerializedString REPORTING = new SerializedString( "reporting" ); + public static final SerializedString SCOPE = new SerializedString( "scope" ); public static final SerializedString PLUGIN_REF = new SerializedString( "plugin" ); diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java index a36cf75c..ee2b68e2 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java @@ -547,7 +547,7 @@ public void restrictRelationshipMembership( final Collection[] {} ) ); + addRelationships( rels.toArray( new ProjectRelationship[rels.size()] ) ); recomputeIncompleteSubgraphs(); } diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/model/JungGraphPath.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/model/JungGraphPath.java index aca20505..c1da9701 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/model/JungGraphPath.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/model/JungGraphPath.java @@ -110,11 +110,7 @@ public boolean equals( final Object obj ) return false; } final JungGraphPath other = (JungGraphPath) obj; - if ( !Arrays.equals( rels, other.rels ) ) - { - return false; - } - return true; + return Arrays.equals( rels, other.rels ); } @Override diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java index 3d2cbf00..f8259477 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java @@ -1286,7 +1286,7 @@ private void collectAtlasRelationships( final ViewParams params, final TraverseV try { - final Traverser traverser = description.traverse( start.toArray( new Node[] {} ) ); + final Traverser traverser = description.traverse( start.toArray( new Node[start.size()] ) ); for ( @SuppressWarnings( "unused" ) final Path path : traverser ) { @@ -2236,7 +2236,6 @@ public void registerViewSelection( final ViewParams params, final ProjectRef ref logger.debug( "Uncaching: {}", r ); toUncache.add( r ); uncache = true; - continue; } else { @@ -2244,7 +2243,6 @@ public void registerViewSelection( final ViewParams params, final ProjectRef ref toUncacheNode.add( r.getStartNode() ); toUncacheNode.add( r.getEndNode() ); toUncache.add( r ); - continue; } } } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphRelType.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphRelType.java index ef6b94b3..df0f428f 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphRelType.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphRelType.java @@ -40,16 +40,16 @@ public enum GraphRelType private boolean managed = false; - private GraphRelType() + GraphRelType() { } - private GraphRelType( final org.commonjava.maven.atlas.graph.rel.RelationshipType atlasType ) + GraphRelType( final org.commonjava.maven.atlas.graph.rel.RelationshipType atlasType ) { this.atlasType = atlasType; } - private GraphRelType( final org.commonjava.maven.atlas.graph.rel.RelationshipType atlasType, final boolean managed ) + GraphRelType( final org.commonjava.maven.atlas.graph.rel.RelationshipType atlasType, final boolean managed ) { this.atlasType = atlasType; this.managed = managed; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeType.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeType.java index 6b3a3800..d92874c1 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeType.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeType.java @@ -18,6 +18,6 @@ public enum NodeType { - PROJECT, CYCLE; + PROJECT, CYCLE } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java index 04974a77..a834b806 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java @@ -471,7 +471,7 @@ public static ProjectRelationship toProjectRelationship( final Relationship r result = new DependencyRelationship( source, pomLocation, from, artifact, scope, index, managed, - excludes.toArray( new ProjectRef[] {} ) ); + excludes.toArray( new ProjectRef[excludes.size()] ) ); break; } case PLUGIN_DEP: diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/CyclePath.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/CyclePath.java index d43e0a69..abef6357 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/CyclePath.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/CyclePath.java @@ -201,12 +201,12 @@ public int hashCode() { if ( i % 2 == 1 ) { - result += Long.valueOf( it.next() ) + result += it.next() .hashCode(); } else { - result -= Long.valueOf( it.next() ) + result -= it.next() .hashCode(); } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java index f36a3b40..b43e41e9 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java @@ -201,11 +201,7 @@ public boolean equals( final Object obj ) { return false; } - if ( !Arrays.equals( relationships, other.relationships ) ) - { - return false; - } - return true; + return Arrays.equals( relationships, other.relationships ); } @Override diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java index f7166146..b93c0e3c 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java @@ -214,13 +214,8 @@ public void cycleDetected( final CyclePath path, final Relationship injector ) @Override public boolean includeChildren( final Path path, final Neo4jGraphPath graphPath, final GraphPathInfo pathInfo ) { - if ( stopNode != null && path.endNode() - .getId() == stopNode.getId() ) - { - return false; - } + return !( stopNode != null && path.endNode().getId() == stopNode.getId() ); - return true; } @Override diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/DependencyScope.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/DependencyScope.java index 66cca1db..b6ac945c 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/DependencyScope.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/DependencyScope.java @@ -36,13 +36,13 @@ public enum DependencyScope private String realName; - private DependencyScope( final String realName, final DependencyScope... implied ) + DependencyScope( final String realName, final DependencyScope... implied ) { this.realName = realName; this.implied = new HashSet( Arrays.asList( implied ) ); } - private DependencyScope( final DependencyScope... implied ) + DependencyScope( final DependencyScope... implied ) { realName = name(); this.implied = new HashSet( Arrays.asList( implied ) ); diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java index 57a99108..a26aca96 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java @@ -142,11 +142,7 @@ public boolean equals( final Object obj ) { return false; } - if ( !groupId.equals( other.groupId ) ) - { - return false; - } - return true; + return groupId.equals( other.groupId ); } @Override @@ -176,13 +172,8 @@ public boolean matches( final ProjectRef ref ) } final String aidPattern = toWildcard( getArtifactId() ); - if ( !ref.getArtifactId() - .matches( aidPattern ) ) - { - return false; - } + return ref.getArtifactId().matches( aidPattern ); - return true; } private String toWildcard( final String val ) diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/RangeVersionSpec.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/RangeVersionSpec.java index 349e2bca..86767262 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/RangeVersionSpec.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/RangeVersionSpec.java @@ -294,11 +294,7 @@ else if ( !upper.equals( other.upper ) ) { return false; } - if ( upperInclusive != other.upperInclusive ) - { - return false; - } - return true; + return upperInclusive == other.upperInclusive; } } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SeparatorPart.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SeparatorPart.java index 2d0fd86e..dccb1aa8 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SeparatorPart.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SeparatorPart.java @@ -78,11 +78,7 @@ public boolean equals( final Object obj ) return false; } final SeparatorPart other = (SeparatorPart) obj; - if ( type != other.type ) - { - return false; - } - return true; + return type == other.type; } } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPartSeparator.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPartSeparator.java index 7ae92056..f13e1e68 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPartSeparator.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPartSeparator.java @@ -22,7 +22,7 @@ public enum VersionPartSeparator private String rendered; - private VersionPartSeparator( final String rendered ) + VersionPartSeparator( final String rendered ) { this.rendered = rendered; } diff --git a/pom.xml b/pom.xml index a21416dc..e4a402c0 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,7 @@ org.commonjava.boms web-commons-bom - 16 + 17-SNAPSHOT import pom @@ -128,8 +128,8 @@ identities relationships-api + bindings tck drivers - bindings diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java index 1f65d362..cd7ddec7 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java @@ -217,7 +217,6 @@ public synchronized void close() } logger.info( "NOT closing; there are other users registered!" ); - return; } // +++ IMPORTED FROM EProjectWeb... @@ -276,7 +275,7 @@ public > Set addAll( final Collection rel final Set result = new HashSet( rels ); final Set> rejected = - getConnectionInternal().addRelationships( rels.toArray( new ProjectRelationship[] {} ) ); + getConnectionInternal().addRelationships( rels.toArray( new ProjectRelationship[rels.size()] ) ); result.removeAll( rejected ); if ( !result.isEmpty() ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java index 1e7dd9ca..1964ef90 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java @@ -393,8 +393,7 @@ public final ProjectVersionRef getSelection( final ProjectRef ref ) public boolean hasSelection( final ProjectVersionRef ref ) { - return selections == null ? false : selections.containsKey( ref ) - || selections.containsKey( ref.asProjectRef() ); + return selections != null && ( selections.containsKey( ref ) || selections.containsKey( ref.asProjectRef() ) ); } public String renderSelections() diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java index 860072c3..2b40b953 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java @@ -16,7 +16,6 @@ package org.commonjava.maven.atlas.graph.filter; import java.util.Collection; -import java.util.List; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java index 274b0987..0f71677a 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java @@ -193,11 +193,7 @@ else if ( !excludes.equals( other.excludes ) ) { return false; } - if ( useImpliedScopes != other.useImpliedScopes ) - { - return false; - } - return true; + return useImpliedScopes == other.useImpliedScopes; } @Override diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java index 398cc479..5a4120fc 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java @@ -118,11 +118,7 @@ public boolean equals( final Object obj ) { return false; } - if ( useImpliedScope != other.useImpliedScope ) - { - return false; - } - return true; + return useImpliedScope == other.useImpliedScope; } @Override diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java index 605602df..8ddb3a88 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java @@ -16,7 +16,6 @@ package org.commonjava.maven.atlas.graph.filter; import java.util.Collection; -import java.util.List; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ParentFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ParentFilter.java index bdb4e93c..75fc842d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ParentFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ParentFilter.java @@ -43,12 +43,8 @@ private ParentFilter( final boolean allowTerminalParent ) @Override public boolean doAccept( final ProjectRelationship rel ) { - if ( allowTerminalParent || !( (ParentRelationship) rel ).isTerminus() ) - { - return true; - } + return allowTerminalParent || !( (ParentRelationship) rel ).isTerminus(); - return false; } @Override @@ -82,11 +78,7 @@ public boolean equals( final Object obj ) return false; } final ParentFilter other = (ParentFilter) obj; - if ( allowTerminalParent != other.allowTerminalParent ) - { - return false; - } - return true; + return allowTerminalParent == other.allowTerminalParent; } @Override diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java index acafe6fc..4b61cd7c 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java @@ -81,11 +81,7 @@ public boolean equals( final Object obj ) { return false; } - if ( getClass() != obj.getClass() ) - { - return false; - } - return true; + return getClass() == obj.getClass(); } } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java index f7709e60..9798b3f5 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java @@ -76,11 +76,7 @@ public boolean equals( final Object obj ) { return false; } - if ( getClass() != obj.getClass() ) - { - return false; - } - return true; + return getClass() == obj.getClass(); } @Override diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractProjectRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractProjectRelationship.java index 286544bc..c33121cd 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractProjectRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractProjectRelationship.java @@ -214,11 +214,7 @@ else if ( !target.equals( other.target ) ) { return false; } - if ( type != other.type ) - { - return false; - } - return true; + return type == other.type; } @Override diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java index 9e4c0e24..4f6ed549 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java @@ -16,6 +16,7 @@ package org.commonjava.maven.atlas.graph.rel; import java.net.URI; +import java.util.Collection; import java.util.Set; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; @@ -32,7 +33,7 @@ public class BomRelationship private static final long serialVersionUID = 1L; - public BomRelationship( final Set sources, final ProjectVersionRef d, final ProjectVersionRef t, + public BomRelationship( final Collection sources, final ProjectVersionRef d, final ProjectVersionRef t, final int index ) { // BOMs are actually marked as concrete...somewhat counter-intuitive, @@ -49,7 +50,7 @@ public BomRelationship( final URI source, final ProjectVersionRef d, final Proje super( source, RelationshipType.BOM, d, t, index, false ); } - public BomRelationship( final Set sources, final URI pomLocation, final ProjectVersionRef d, + public BomRelationship( final Collection sources, final URI pomLocation, final ProjectVersionRef d, final ProjectVersionRef t, final int index ) { // BOMs are actually marked as concrete...somewhat counter-intuitive, diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java index be1dd08b..363e6468 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java @@ -113,11 +113,7 @@ public boolean equals( final Object obj ) return false; } final DependencyRelationship other = (DependencyRelationship) obj; - if ( isManaged() != other.isManaged() ) - { - return false; - } - return true; + return isManaged() == other.isManaged(); } @Override @@ -150,8 +146,9 @@ public ProjectRelationship selectDeclaring( final SingleVersion ver final ProjectVersionRef d = getDeclaring().selectVersion( version, force ); final ArtifactRef t = getTarget(); + Set var = getExcludes(); return new DependencyRelationship( getSources(), getPomLocation(), d, t, getScope(), getIndex(), isManaged(), - getExcludes().toArray( new ProjectRef[] {} ) ); + var.toArray( new ProjectRef[var.size()] ) ); } @Override @@ -167,8 +164,9 @@ public ProjectRelationship selectTarget( final SingleVersion versio ArtifactRef t = getTarget(); t = new ArtifactRef( t.selectVersion( version, force ), t.getType(), t.getClassifier(), t.isOptional() ); + Set var = getExcludes(); return new DependencyRelationship( getSources(), getPomLocation(), d, t, getScope(), getIndex(), isManaged(), - getExcludes().toArray( new ProjectRef[] {} ) ); + var.toArray( new ProjectRef[var.size()] ) ); } @Override @@ -176,8 +174,9 @@ public ProjectRelationship selectDeclaring( final ProjectVersionRef { final ArtifactRef t = getTarget(); + Set var = getExcludes(); return new DependencyRelationship( getSources(), getPomLocation(), ref, t, getScope(), getIndex(), isManaged(), - getExcludes().toArray( new ProjectRef[] {} ) ); + var.toArray( new ProjectRef[var.size()] ) ); } @Override @@ -189,8 +188,9 @@ public ProjectRelationship selectTarget( final ProjectVersionRef re (ArtifactRef) ( ( ref instanceof ArtifactRef ) ? ref : new ArtifactRef( ref, t.getType(), t.getClassifier(), t.isOptional() ) ); + Set var = getExcludes(); return new DependencyRelationship( getSources(), getPomLocation(), d, t, getScope(), getIndex(), isManaged(), - getExcludes().toArray( new ProjectRef[] {} ) ); + var.toArray( new ProjectRef[var.size()] ) ); } public boolean isBOM() diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java index 83ead9a9..b20136db 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java @@ -104,11 +104,7 @@ public boolean equals( final Object obj ) return false; } final PluginRelationship other = (PluginRelationship) obj; - if ( isManaged() != other.isManaged() ) - { - return false; - } - return true; + return isManaged() == other.isManaged(); } @Override diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipType.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipType.java index bfc85287..81ea4071 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipType.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipType.java @@ -29,7 +29,7 @@ public enum RelationshipType private final Set names; - private RelationshipType( final String... names ) + RelationshipType( final String... names ) { this.names = Collections.unmodifiableSet( new HashSet( Arrays.asList( names ) ) ); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/ImpactTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/ImpactTraversal.java index 442aae33..0308ae11 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/ImpactTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/ImpactTraversal.java @@ -108,15 +108,8 @@ public boolean preCheck( final ProjectRelationship relationship, final List

>> paths = impactedPaths.get( relationship.getTarget() .asProjectVersionRef() ); - if ( paths != null && paths.isEmpty() ) - { - // we've seen an impact target, we don't need to go further. + return !( paths != null && paths.isEmpty() ); - // TODO: huh?? - return false; - } - - return true; } } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TraversalType.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TraversalType.java index 4a637ec4..559453d8 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TraversalType.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TraversalType.java @@ -18,6 +18,6 @@ public enum TraversalType { - depth_first, breadth_first; + depth_first, breadth_first } From d030ef140c7d8cb0e774f604944b3c01908612d0 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 11 Aug 2015 21:43:28 -0500 Subject: [PATCH 082/240] fix license headers. --- .../ProjectVersionRefSerializerModuleTest.java | 15 +++++++++++++++ .../graph/filter/RelationshipTypeFilter.java | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/bindings/jackson-identities/src/test/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModuleTest.java b/bindings/jackson-identities/src/test/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModuleTest.java index 0bca69b7..9534cc7c 100644 --- a/bindings/jackson-identities/src/test/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModuleTest.java +++ b/bindings/jackson-identities/src/test/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModuleTest.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.jackson; import static org.hamcrest.CoreMatchers.equalTo; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/RelationshipTypeFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/RelationshipTypeFilter.java index 16f8c40d..26ded2b4 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/RelationshipTypeFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/RelationshipTypeFilter.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.filter; import java.util.Collection; From ffa6d64233830a12a6529b05ef5f7f197f033dc1 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 11 Aug 2015 21:46:34 -0500 Subject: [PATCH 083/240] [maven-release-plugin] prepare release atlas-parent-0.14.2 --- bindings/jackson-identities/pom.xml | 2 +- bindings/jackson-relationships/pom.xml | 2 +- bindings/pom.xml | 2 +- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index dc7be63e..bafadf5d 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.14.2-SNAPSHOT + 0.14.2 atlas-bindings-jackson-identities diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml index 44e41136..943bf168 100644 --- a/bindings/jackson-relationships/pom.xml +++ b/bindings/jackson-relationships/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.14.2-SNAPSHOT + 0.14.2 atlas-bindings-jackson-relationships diff --git a/bindings/pom.xml b/bindings/pom.xml index e91ebee8..fcceea05 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.2-SNAPSHOT + 0.14.2 atlas-bindings-parent diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index 9b6b7fe6..01847112 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.14.2-SNAPSHOT + 0.14.2 atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 90ee1e16..88188b56 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.14.2-SNAPSHOT + 0.14.2 atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 2cd13c8a..fec7df71 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.2-SNAPSHOT + 0.14.2 atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index e6dacc63..8482af3a 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.2-SNAPSHOT + 0.14.2 atlas-identities diff --git a/pom.xml b/pom.xml index e4a402c0..e882e2b5 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.2-SNAPSHOT + 0.14.2 pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - HEAD + atlas-parent-0.14.2 @@ -48,17 +48,17 @@ org.commonjava.maven.atlas atlas-identities - 0.14.2-SNAPSHOT + 0.14.2 org.commonjava.maven.atlas atlas-relationships-api - 0.14.2-SNAPSHOT + 0.14.2 org.commonjava.maven.atlas atlas-drivers-tck - 0.14.2-SNAPSHOT + 0.14.2 test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index d7354d47..3f6c512b 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.2-SNAPSHOT + 0.14.2 atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index cad8cf13..19c3c60d 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.2-SNAPSHOT + 0.14.2 atlas-drivers-tck From 767c42503aa7c7e1366d758e402c3da495fd9298 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 11 Aug 2015 21:46:36 -0500 Subject: [PATCH 084/240] [maven-release-plugin] prepare for next development iteration --- bindings/jackson-identities/pom.xml | 2 +- bindings/jackson-relationships/pom.xml | 2 +- bindings/pom.xml | 2 +- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index bafadf5d..cbc497e5 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.14.2 + 0.14.3-SNAPSHOT atlas-bindings-jackson-identities diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml index 943bf168..59b444bf 100644 --- a/bindings/jackson-relationships/pom.xml +++ b/bindings/jackson-relationships/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.14.2 + 0.14.3-SNAPSHOT atlas-bindings-jackson-relationships diff --git a/bindings/pom.xml b/bindings/pom.xml index fcceea05..75f6c0de 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.2 + 0.14.3-SNAPSHOT atlas-bindings-parent diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index 01847112..d1a14b7e 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.14.2 + 0.14.3-SNAPSHOT atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 88188b56..863901cb 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.14.2 + 0.14.3-SNAPSHOT atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index fec7df71..c30d02e5 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.2 + 0.14.3-SNAPSHOT atlas-drivers-parent diff --git a/identities/pom.xml b/identities/pom.xml index 8482af3a..42f7124c 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.2 + 0.14.3-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index e882e2b5..78f55f80 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.2 + 0.14.3-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - atlas-parent-0.14.2 + HEAD @@ -48,17 +48,17 @@ org.commonjava.maven.atlas atlas-identities - 0.14.2 + 0.14.3-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.14.2 + 0.14.3-SNAPSHOT org.commonjava.maven.atlas atlas-drivers-tck - 0.14.2 + 0.14.3-SNAPSHOT test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 3f6c512b..602421e1 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.2 + 0.14.3-SNAPSHOT atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 19c3c60d..876d2148 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.2 + 0.14.3-SNAPSHOT atlas-drivers-tck From e93b51d9a4e0f21fc78a7da906f6e96335594dcf Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 19 Aug 2015 22:02:57 -0500 Subject: [PATCH 085/240] fix NPE in grooming task --- .../commonjava/maven/atlas/graph/RelationshipGraphFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java index 1755f679..9498e4ad 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java @@ -210,7 +210,7 @@ public synchronized void closeNow() final RelationshipGraphConnection conn = connection; connection = null; - if ( !conn.isClosed() ) + if ( conn != null && !conn.isClosed() ) { conn.close(); } From aa8190e5f10c10f7a354764eb243f648207d0b71 Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 20 Aug 2015 16:21:36 -0500 Subject: [PATCH 086/240] fixing log message in RelationshipGraph, and restoring path length as the first comparison in RelationshipPathComparator. --- .../maven/atlas/graph/RelationshipGraph.java | 73 ++++++++++--------- .../graph/rel/RelationshipPathComparator.java | 23 +++--- 2 files changed, 51 insertions(+), 45 deletions(-) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java index cd7ddec7..f89c83e5 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java @@ -48,7 +48,7 @@ import org.slf4j.LoggerFactory; public final class RelationshipGraph - implements Closeable + implements Closeable { private final Logger logger = LoggerFactory.getLogger( getClass() ); @@ -82,11 +82,10 @@ public ViewParams getParams() } public void storeProjectError( final ProjectVersionRef ref, final Throwable error ) - throws RelationshipGraphException + throws RelationshipGraphException { - getConnectionInternal().addProjectError( ref, - String.format( "%s\n%s", error.getMessage(), - join( error.getStackTrace(), "\n " ) ) ); + getConnectionInternal().addProjectError( ref, String.format( "%s\n%s", error.getMessage(), + join( error.getStackTrace(), "\n " ) ) ); for ( final RelationshipGraphListener listener : listeners ) { @@ -105,13 +104,13 @@ public boolean hasProjectError( final ProjectVersionRef ref ) } public void clearProjectError( final ProjectVersionRef ref ) - throws RelationshipGraphException + throws RelationshipGraphException { getConnectionInternal().clearProjectError( ref ); } public Set> storeRelationships( final ProjectRelationship... relationships ) - throws RelationshipGraphException + throws RelationshipGraphException { final List> rels = Arrays.asList( relationships ); @@ -130,16 +129,17 @@ public Set> storeRelationships( final ProjectRelationship return rejected; } - public Set> storeRelationships( final Collection> relationships ) - throws RelationshipGraphException + public Set> storeRelationships( + final Collection> relationships ) + throws RelationshipGraphException { for ( final RelationshipGraphListener listener : listeners ) { listener.storing( this, relationships ); } - final Set> rejected = - getConnectionInternal().addRelationships( relationships.toArray( new ProjectRelationship[relationships.size()] ) ); + final Set> rejected = getConnectionInternal().addRelationships( + relationships.toArray( new ProjectRelationship[relationships.size()] ) ); for ( final RelationshipGraphListener listener : listeners ) { @@ -174,7 +174,7 @@ synchronized void incrementGraphOwnership() } public synchronized void forceClose() - throws RelationshipGraphException + throws RelationshipGraphException { logger.info( "Closing: {}", params ); @@ -199,7 +199,7 @@ public synchronized void forceClose() @Override public synchronized void close() - throws IOException + throws IOException { userCount--; logger.info( "User count decremented to: {} for: {}", userCount, params ); @@ -215,8 +215,10 @@ public synchronized void close() throw new IOException( "Failed to close graph.", e ); } } - - logger.info( "NOT closing; there are other users registered!" ); + else + { + logger.info( "NOT closing; there are other users registered!" ); + } } // +++ IMPORTED FROM EProjectWeb... @@ -247,25 +249,24 @@ public Set getVariableSubgraphs() } public Set> add( final EProjectDirectRelationships rels ) - throws RelationshipGraphException + throws RelationshipGraphException { return addAll( rels.getAllRelationships() ); } public boolean add( final ProjectRelationship rel ) - throws RelationshipGraphException + throws RelationshipGraphException { if ( rel == null ) { return false; } - return getConnectionInternal().addRelationships( rel ) - .isEmpty(); + return getConnectionInternal().addRelationships( rel ).isEmpty(); } public > Set addAll( final Collection rels ) - throws RelationshipGraphException + throws RelationshipGraphException { if ( rels == null ) { @@ -275,7 +276,7 @@ public > Set addAll( final Collection rel final Set result = new HashSet( rels ); final Set> rejected = - getConnectionInternal().addRelationships( rels.toArray( new ProjectRelationship[rels.size()] ) ); + getConnectionInternal().addRelationships( rels.toArray( new ProjectRelationship[rels.size()] ) ); result.removeAll( rejected ); if ( !result.isEmpty() ) @@ -287,7 +288,7 @@ public > Set addAll( final Collection rel } public > Set addAll( final T... rels ) - throws RelationshipGraphException + throws RelationshipGraphException { if ( rels == null ) { @@ -310,19 +311,19 @@ public > Set addAll( final T... rels ) public void traverse( final ProjectVersionRef start, final RelationshipGraphTraversal traversal, final TraversalType type ) - throws RelationshipGraphException + throws RelationshipGraphException { getConnectionInternal().traverse( traversal, start, this, type ); } public void traverse( final ProjectVersionRef start, final RelationshipGraphTraversal traversal ) - throws RelationshipGraphException + throws RelationshipGraphException { traverse( start, traversal, TraversalType.breadth_first ); } public void traverse( final RelationshipGraphTraversal traversal, final TraversalType type ) - throws RelationshipGraphException + throws RelationshipGraphException { for ( final ProjectVersionRef root : params.getRoots() ) { @@ -331,7 +332,7 @@ public void traverse( final RelationshipGraphTraversal traversal, final Traversa } public void traverse( final RelationshipGraphTraversal traversal ) - throws RelationshipGraphException + throws RelationshipGraphException { traverse( traversal, TraversalType.breadth_first ); } @@ -377,7 +378,7 @@ public boolean isCycleParticipant( final ProjectRelationship rel ) } public void addCycle( final EProjectCycle cycle ) - throws RelationshipGraphException + throws RelationshipGraphException { getConnectionInternal().addCycle( cycle ); } @@ -390,7 +391,7 @@ public Set getCycles() public Set> getRelationshipsTargeting( final ProjectVersionRef ref ) { final Collection> rels = - getConnectionInternal().getRelationshipsTargeting( params, ref.asProjectVersionRef() ); + getConnectionInternal().getRelationshipsTargeting( params, ref.asProjectVersionRef() ); if ( rels == null ) { return Collections.emptySet(); @@ -410,13 +411,13 @@ public Set getAllProjects() } public void addMetadata( final ProjectVersionRef ref, final String name, final String value ) - throws RelationshipGraphException + throws RelationshipGraphException { getConnectionInternal().addMetadata( ref, name, value ); } public void addMetadata( final ProjectVersionRef ref, final Map metadata ) - throws RelationshipGraphException + throws RelationshipGraphException { getConnectionInternal().setMetadata( ref, metadata ); } @@ -427,13 +428,13 @@ public Set getProjectsWithMetadata( final String key ) } public void reindex() - throws RelationshipGraphException + throws RelationshipGraphException { getConnectionInternal().reindex(); } public void reindex( final ProjectVersionRef ref ) - throws RelationshipGraphConnectionException + throws RelationshipGraphConnectionException { getConnectionInternal().reindex( ref ); } @@ -449,7 +450,7 @@ public boolean introducesCycle( final ProjectRelationship rel ) } public void addDisconnectedProject( final ProjectVersionRef ref ) - throws RelationshipGraphException + throws RelationshipGraphException { getConnectionInternal().addDisconnectedProject( ref ); } @@ -647,7 +648,7 @@ public Map, Set> collateByMetadata( final final Set keys ) { final Map, Set> result = - new HashMap, Set>(); + new HashMap, Set>(); for ( final ProjectVersionRef ref : refs ) { final Map metadata = getMetadata( ref, keys ); @@ -665,13 +666,13 @@ public Map, Set> collateByMetadata( final } public void setMetadata( final ProjectVersionRef project, final Map metadata ) - throws RelationshipGraphException + throws RelationshipGraphException { getConnectionInternal().setMetadata( project, metadata ); } public void deleteRelationshipsDeclaredBy( final ProjectVersionRef ref ) - throws RelationshipGraphException + throws RelationshipGraphException { getConnectionInternal().deleteRelationshipsDeclaredBy( ref ); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparator.java index e80f8b8a..313fe520 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparator.java @@ -15,6 +15,9 @@ */ package org.commonjava.maven.atlas.graph.rel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.Comparator; import java.util.List; @@ -33,8 +36,19 @@ private RelationshipPathComparator() @Override public int compare( final List> one, final List> two ) { + Logger logger = LoggerFactory.getLogger( getClass() ); + logger.debug("Comparing:\nOne: {}\nTwo: {}", one, two); + final int commonLen = Math.min( one.size(), two.size() ); + if ( one.size() > commonLen ) + { + return 1; + } + else if ( two.size() > commonLen ) + { + return -1; + } for ( int i = 0; i < commonLen; i++ ) { @@ -54,15 +68,6 @@ public int compare( final List> one, final List commonLen ) - { - return 1; - } - else if ( two.size() > commonLen ) - { - return -1; - } - return 0; } From d79c6ad072f0994b4f28d05c576da564ae3c37eb Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 20 Aug 2015 16:55:22 -0500 Subject: [PATCH 087/240] eliminate some unnecessary deserialization from the lucene records. --- .../spi/neo4j/FileNeo4JGraphConnection.java | 8 +- .../atlas/graph/spi/neo4j/NodeToString.java | 27 +++++ .../atlas/graph/spi/neo4j/PathComparator.java | 102 ++++++++++++++++-- .../atlas/graph/spi/neo4j/RelToString.java | 27 +++++ 4 files changed, 148 insertions(+), 16 deletions(-) create mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeToString.java create mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelToString.java diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java index f8259477..5a350520 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java @@ -666,7 +666,7 @@ private Map> addRelationshipsInternal( final Projec } else { - logger.debug( "== {} ({})", relationship, toProjectRelationship( relationship, cache ) ); + logger.debug( "== {} ({})", relationship, new RelToString( relationship, cache ) ); addToURISetProperty( rel.getSources(), SOURCE_URI, relationship ); } @@ -1740,9 +1740,6 @@ public void addDisconnectedProject( final ProjectVersionRef ref ) } } - /** - * @deprecated Use {@link #getDirectRelationshipsFrom(GraphView,ProjectVersionRef,boolean,boolean,RelationshipType...)} instead - */ @Deprecated @Override public Set> getDirectRelationshipsFrom( final ViewParams params, @@ -1966,8 +1963,7 @@ public ProjectVersionRef getManagedTargetFor( final ProjectVersionRef target, fi final Relationship hit = hits.next(); final ProjectVersionRef ref = toProjectVersionRef( hit.getEndNode(), cache ); - final ProjectRelationship rel = Conversions.toProjectRelationship( hit, cache ); - logger.info( "[MUTATION] {} => {} (via: {})", target, ref, rel ); + logger.debug( "[MUTATION] {} => {} (via: {})", target, ref, new RelToString( hit, cache ) ); return ref; } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeToString.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeToString.java new file mode 100644 index 00000000..2ac2fa94 --- /dev/null +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeToString.java @@ -0,0 +1,27 @@ +package org.commonjava.maven.atlas.graph.spi.neo4j; + +import org.commonjava.maven.atlas.graph.spi.neo4j.io.ConversionCache; +import org.neo4j.graphdb.Node; + +import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.toProjectVersionRef; + +/** + * Created by jdcasey on 8/20/15. + */ +public class NodeToString +{ + private final Node node; + + private final ConversionCache cache; + + public NodeToString( Node node, ConversionCache cache ) + { + this.node = node; + this.cache = cache; + } + + public String toString() + { + return toProjectVersionRef( node, cache ).toString(); + } +} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java index 5ba60502..9661cd6b 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java @@ -15,17 +15,19 @@ */ package org.commonjava.maven.atlas.graph.spi.neo4j; -import java.util.Comparator; -import java.util.List; - -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.graph.rel.RelationshipPathComparator; import org.commonjava.maven.atlas.graph.spi.neo4j.io.ConversionCache; import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; import org.neo4j.graphdb.Path; +import org.neo4j.graphdb.Relationship; + +import java.util.Comparator; +import java.util.Iterator; + +import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.POM_ROOT_URI; public final class PathComparator - implements Comparator + implements Comparator { public static final PathComparator INSTANCE = new PathComparator(); @@ -41,12 +43,92 @@ private PathComparator() @Override public int compare( final Path first, final Path second ) { - final List> firstRels = - Conversions.convertToRelationships( first.relationships(), cache ); - final List> secondRels = - Conversions.convertToRelationships( second.relationships(), cache ); + final int commonLen = Math.min( first.length(), second.length() ); + + if ( first.length() > commonLen ) + { + return 1; + } + else if ( second.length() > commonLen ) + { + return -1; + } + + Iterator firstRels = first.relationships().iterator(); + Iterator secondRels = second.relationships().iterator(); + for ( int i = 0; i < commonLen; i++ ) + { + Relationship f = firstRels.next(); + Relationship s = secondRels.next(); + + final int result = compareTypes( f, s ); + if ( result != 0 ) + { + return result; + } + } + + firstRels = first.relationships().iterator(); + secondRels = second.relationships().iterator(); + for ( int i = 0; i < commonLen; i++ ) + { + Relationship f = firstRels.next(); + Relationship s = secondRels.next(); + + final int result = compareRels( f, s ); + if ( result != 0 ) + { + return result; + } + } + + return 0; + } + + private int compareTypes( Relationship f, Relationship s ) + { + GraphRelType ft = GraphRelType.valueOf( f.getType().name() ); + GraphRelType st = GraphRelType.valueOf( s.getType().name() ); + return ft.ordinal() - st.ordinal(); + } + + private int compareRels( Relationship first, Relationship second ) + { + if ( first.getType() == second.getType() ) + { + String firstSrc = Conversions.getStringProperty( Conversions.POM_LOCATION_URI, first ); + String secSrc = Conversions.getStringProperty( Conversions.POM_LOCATION_URI, second ); + + if ( firstSrc.equals( POM_ROOT_URI ) && !secSrc.equals( POM_ROOT_URI ) ) + { + return -1; + } + else if ( !firstSrc.equals( POM_ROOT_URI ) && secSrc.equals( POM_ROOT_URI ) ) + { + return 1; + } + + if ( first.getEndNode().getId() == second.getStartNode().getId() ) + { + return -1; + } + else if ( first.getStartNode().getId() == second.getEndNode().getId() ) + { + return 1; + } + else if ( first.getStartNode().getId() == second.getStartNode().getId() ) + { + return Conversions.getIntegerProperty( Conversions.INDEX, first ) - Conversions.getIntegerProperty( + Conversions.INDEX, second ); + } + } + else + { + // really, we can't reach this because of the way the main compare method works... + return compareTypes( first, second ); + } - return pathComparator.compare( firstRels, secondRels ); + return 0; } } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelToString.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelToString.java new file mode 100644 index 00000000..5d653552 --- /dev/null +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelToString.java @@ -0,0 +1,27 @@ +package org.commonjava.maven.atlas.graph.spi.neo4j; + +import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.spi.neo4j.io.ConversionCache; +import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; +import org.neo4j.graphdb.Relationship; + +/** + * Created by jdcasey on 8/20/15. + */ +public class RelToString +{ + private Relationship rel; + + private final ConversionCache cache; + + public RelToString( Relationship rel, ConversionCache cache ) + { + this.rel = rel; + this.cache = cache; + } + + public String toString() + { + return Conversions.toProjectRelationship( rel, cache ).toString(); + } +} From 71c7ea4c1056dbf8f9209d1243468f26ed80516d Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 20 Aug 2015 17:08:24 -0500 Subject: [PATCH 088/240] make BuildOrder a simple DTO so we can deserialize it using jackson --- .../atlas/graph/traverse/model/BuildOrder.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/model/BuildOrder.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/model/BuildOrder.java index d154824d..d749dbf3 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/model/BuildOrder.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/model/BuildOrder.java @@ -25,9 +25,11 @@ public final class BuildOrder { - private final List order; + private List order; - private final Set cycles; + private Set cycles; + + public BuildOrder(){} public BuildOrder( final List order, final Set cycles ) { @@ -45,4 +47,13 @@ public Set getCycles() return cycles; } + public void setOrder( List order ) + { + this.order = order; + } + + public void setCycles( Set cycles ) + { + this.cycles = cycles; + } } From 488f4dc3fb90ff7cfbb9645242ed1af06bddaf5a Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 20 Aug 2015 17:11:02 -0500 Subject: [PATCH 089/240] fixing debug output in tck --- .../maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java index 4947e72f..4abffc1e 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java @@ -244,7 +244,7 @@ public void simpleDependencyBuildOrder_ignoreExcluded() final BuildOrder buildOrderObj = bo.getBuildOrder(); final List buildOrder = buildOrderObj.getOrder(); - logger.info( "Build order: %s", buildOrder ); + logger.info( "Build order: {}", buildOrder ); assertThat( buildOrder.size(), equalTo( 3 ) ); assertRelativeOrder( relativeOrder, buildOrder ); From 7eb525257e1bc9e5e74ee526ae9ee07abab674a2 Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 20 Aug 2015 17:47:48 -0500 Subject: [PATCH 090/240] adding no-arg ctor to EProjectCycle --- .../org/commonjava/maven/atlas/graph/model/EProjectCycle.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java index a5b724a7..da14d50b 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java @@ -105,6 +105,8 @@ public boolean contains( final ProjectRelationship rel ) } } + public EProjectCycle(){} + public EProjectCycle( final List> cycle ) { this.relationships = new ArrayList>( cycle ); From cc0c226e04662f3c953d65e3c0f2b2962132c2ff Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 21 Aug 2015 12:16:55 -0500 Subject: [PATCH 091/240] Adding serializer tests for project relationships, and rewriting relationship deserializer to be more flexible --- bindings/jackson-relationships/pom.xml | 5 + .../ProjectRelationshipSerializerModule.java | 329 ++++++++++-------- .../graph/jackson/SerializationConstants.java | 40 +-- ...ojectRelationshipSerializerModuleTest.java | 86 +++++ 4 files changed, 287 insertions(+), 173 deletions(-) create mode 100644 bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml index 59b444bf..2d8e2438 100644 --- a/bindings/jackson-relationships/pom.xml +++ b/bindings/jackson-relationships/pom.xml @@ -42,6 +42,11 @@ org.commonjava.maven.atlas atlas-relationships-api + + org.commonjava.maven.atlas + atlas-bindings-jackson-identities + test + diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java index 9fa60784..930f12c4 100644 --- a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java @@ -15,38 +15,26 @@ */ package org.commonjava.maven.atlas.graph.jackson; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - import com.fasterxml.jackson.core.*; -import org.commonjava.maven.atlas.graph.rel.BomRelationship; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; - -import com.fasterxml.jackson.core.io.SerializedString; import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import org.commonjava.maven.atlas.graph.rel.*; +import org.commonjava.maven.atlas.graph.util.RelationshipUtils; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.*; + import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.*; public class ProjectRelationshipSerializerModule @@ -90,9 +78,9 @@ public void serialize( final ProjectRelationship value, final JsonGenerator gen, throws IOException, JsonGenerationException { gen.writeStartObject(); - gen.writeStringField( RELATIONSHIP_TYPE.getValue(), value.getType().name() ); - gen.writeStringField( POM_LOCATION_URI.getValue(), value.getPomLocation().toString() ); - gen.writeArrayFieldStart( SOURCE_URIS.getValue() ); + gen.writeStringField( RELATIONSHIP_TYPE, value.getType().name() ); + gen.writeStringField( POM_LOCATION_URI, value.getPomLocation().toString() ); + gen.writeArrayFieldStart( SOURCE_URIS ); Set sources = value.getSources(); for ( URI uri : sources ) @@ -100,40 +88,40 @@ public void serialize( final ProjectRelationship value, final JsonGenerator gen, gen.writeString( uri.toString() ); } gen.writeEndArray(); - provider.defaultSerializeField( DECLARING_REF.getValue(), value.getDeclaring(), gen ); - provider.defaultSerializeField( TARGET_REF.getValue(), value.getTarget(), gen ); + provider.defaultSerializeField( DECLARING_REF, value.getDeclaring(), gen ); + provider.defaultSerializeField( TARGET_REF, value.getTarget(), gen ); switch ( value.getType() ) { case DEPENDENCY: { - gen.writeStringField( SCOPE.getValue(), ( (DependencyRelationship) value ).getScope().realName() ); - gen.writeBooleanField( MANAGED.getValue(), value.isManaged() ); + gen.writeStringField( SCOPE, ( (DependencyRelationship) value ).getScope().realName() ); + gen.writeBooleanField( MANAGED, value.isManaged() ); break; } case PLUGIN_DEP: { - provider.defaultSerializeField( PLUGIN_REF.getValue(), + provider.defaultSerializeField( PLUGIN_REF, ( (PluginDependencyRelationship) value ).getPlugin(), gen ); - gen.writeBooleanField( MANAGED.getValue(), value.isManaged() ); + gen.writeBooleanField( MANAGED, value.isManaged() ); break; } case PLUGIN: { - gen.writeBooleanField( MANAGED.getValue(), value.isManaged() ); - gen.writeBooleanField( REPORTING.getValue(), ( (PluginRelationship) value ).isReporting() ); + gen.writeBooleanField( MANAGED, value.isManaged() ); + gen.writeBooleanField( REPORTING, ( (PluginRelationship) value ).isReporting() ); break; } } - gen.writeNumberField( INDEX.getValue(), value.getIndex() ); + gen.writeNumberField( INDEX, value.getIndex() ); gen.writeEndObject(); } } - @SuppressWarnings( "rawtypes" ) + @SuppressWarnings( {"rawtypes", "unchecked"} ) private static final class ProjectRelationshipDeserializer extends StdDeserializer { @@ -146,177 +134,212 @@ private static final class ProjectRelationshipDeserializer @Override public ProjectRelationship deserialize( final JsonParser jp, final DeserializationContext ctx ) - throws IOException, JsonProcessingException + throws JsonProcessingException, IOException { - final JsonDeserializer prDeser = - ctx.findRootValueDeserializer( ctx.getTypeFactory().constructType( ProjectRef.class ) ); - final JsonDeserializer pvrDeser = ctx.findRootValueDeserializer( - ctx.getTypeFactory().constructType( ProjectVersionRef.class ) ); - final JsonDeserializer arDeser = - ctx.findRootValueDeserializer( ctx.getTypeFactory().constructType( ArtifactRef.class ) ); + Map ast = new HashMap(); + Map locations = new HashMap(); - final RelationshipType type = - RelationshipType.getType( expectField( jp, RELATIONSHIP_TYPE ).nextTextValue() ); + JsonToken token = jp.getCurrentToken(); + String currentField = null; + List currentArry = null; - final String uri = expectField( jp, POM_LOCATION_URI ).nextTextValue(); - URI pomLocation; - try - { - pomLocation = new URI( uri ); - } - catch ( final URISyntaxException e ) + Logger logger = LoggerFactory.getLogger( getClass() ); + do { - throw new JsonParseException( "Invalid " + POM_LOCATION_URI + ": '" + uri + "': " + e.getMessage(), - jp.getCurrentLocation(), e ); + logger.info( "Token: {}", token ); + switch(token) + { + case START_ARRAY: + { + logger.info( "Starting array for field: {}", currentField ); + currentArry = new ArrayList(); + break; + } + case END_ARRAY: + logger.info( "Ending array for field: {}", currentField ); + locations.put( currentField, jp.getCurrentLocation() ); + ast.put(currentField, currentArry); + currentArry = null; + break; + case FIELD_NAME: + currentField = jp.getCurrentName(); + break; + case VALUE_STRING: + if ( currentArry != null ) + { + currentArry.add(jp.getText()); + } + else + { + locations.put( currentField, jp.getCurrentLocation() ); + ast.put( currentField, jp.getText() ); + } + break; + case VALUE_NUMBER_INT: + locations.put( currentField, jp.getCurrentLocation() ); + ast.put( currentField, jp.getIntValue() ); + break; + case VALUE_NUMBER_FLOAT: + locations.put( currentField, jp.getCurrentLocation() ); + ast.put( currentField, jp.getFloatValue() ); + break; + case VALUE_TRUE: + locations.put( currentField, jp.getCurrentLocation() ); + ast.put( currentField, Boolean.TRUE ); + break; + case VALUE_FALSE: + locations.put( currentField, jp.getCurrentLocation() ); + ast.put( currentField, Boolean.FALSE ); + break; + } + + token = jp.nextToken(); } + while ( token != JsonToken.END_OBJECT ); - Collection sources = new HashSet(); - expectField( jp, SOURCE_URIS ); - ff( jp, JsonToken.START_ARRAY ); - while ( jp.nextToken() != JsonToken.END_ARRAY && jp.getCurrentToken() != null ) + StringBuilder sb = new StringBuilder(); + sb.append( "AST is:" ); + for ( String field : ast.keySet() ) { - String u = jp.getText(); - if ( u == null ) + Object value = ast.get( field ); + sb.append( "\n " ).append(field).append( " = "); + if ( value == null ) { - continue; + sb.append( "null"); } + else + { + sb.append( value ).append( " (type: ").append(value.getClass().getSimpleName()).append(")"); + } + } + logger.info(sb.toString()); + + final RelationshipType type = + RelationshipType.getType( (String) ast.get(RELATIONSHIP_TYPE) ); + + final String uri = (String) ast.get( POM_LOCATION_URI ); + URI pomLocation; + if ( uri == null ) + { + pomLocation = RelationshipUtils.POM_ROOT_URI; + } + else + { try { - sources.add( new URI( u ) ); + pomLocation = new URI( uri ); } - catch ( URISyntaxException e ) + catch ( final URISyntaxException e ) + { + throw new JsonParseException( "Invalid " + POM_LOCATION_URI + ": '" + uri + "': " + e.getMessage(), + locations.get(POM_LOCATION_URI), e ); + } + } + + Collection sources = new HashSet(); + List srcs = (List) ast.get(SOURCE_URIS); + if ( srcs != null ) + { + for ( String u: srcs ) { - throw new JsonParseException( "Failed to parse source URI: " + u, jp.getCurrentLocation() ); + try + { + sources.add( new URI( u ) ); + } + catch ( URISyntaxException e ) + { + throw new JsonParseException( "Failed to parse source URI: " + u, locations.get(SOURCE_URIS) ); + } } } - expectField( jp, DECLARING_REF ).nextTextValue(); - final ProjectVersionRef declaring = (ProjectVersionRef) pvrDeser.deserialize( jp, ctx ); + String decl = (String) ast.get( DECLARING_REF ); + final ProjectVersionRef declaring = ProjectVersionRef.parse( decl ); + + String tgt = (String) ast.get( TARGET_REF ); + Integer index = (Integer) ast.get( INDEX ); + if ( index == null ) + { + index = 0; + } + + // handle null implicitly by comparing to true. + boolean managed = Boolean.TRUE.equals( ast.get( MANAGED ) ); ProjectRelationship rel = null; switch ( type ) { case DEPENDENCY: { - expectField( jp, TARGET_REF ).nextTextValue(); - final ArtifactRef target = (ArtifactRef) arDeser.deserialize( jp, ctx ); - - final DependencyScope scope = DependencyScope.getScope( expectField( jp, SCOPE ).nextTextValue() ); - - rel = new DependencyRelationship( sources, pomLocation, declaring, target, scope, getIndex( jp ), - isManaged( jp ) ); + final ArtifactRef target = ArtifactRef.parse( tgt ); + + String scp = (String) ast.get(SCOPE); + final DependencyScope scope; + if ( scp == null ) + { + scope = DependencyScope.compile; + } + else + { + scope = DependencyScope.getScope( scp ); + } + + rel = new DependencyRelationship( sources, pomLocation, declaring, target, scope, index, + managed ); break; } case EXTENSION: { - expectField( jp, TARGET_REF ).nextTextValue(); - final ProjectVersionRef target = (ProjectVersionRef) pvrDeser.deserialize( jp, ctx ); + final ProjectVersionRef target = ProjectVersionRef.parse( tgt ); - rel = new ExtensionRelationship( sources, pomLocation, declaring, target, getIndex( jp ) ); + rel = new ExtensionRelationship( sources, pomLocation, declaring, target, index ); break; } case PARENT: { - expectField( jp, TARGET_REF ).nextTextValue(); - final ProjectVersionRef target = (ProjectVersionRef) pvrDeser.deserialize( jp, ctx ); + final ProjectVersionRef target = ProjectVersionRef.parse( tgt ); rel = new ParentRelationship( sources, declaring, target ); break; } case PLUGIN: { - expectField( jp, TARGET_REF ).nextTextValue(); - final ProjectVersionRef target = (ProjectVersionRef) pvrDeser.deserialize( jp, ctx ); + final ProjectVersionRef target = ProjectVersionRef.parse( tgt ); - rel = new PluginRelationship( sources, pomLocation, declaring, target, getIndex( jp ), - isManaged( jp ), isReporting( jp ) ); + Boolean report = (Boolean) ast.get( REPORTING ); + rel = new PluginRelationship( sources, pomLocation, declaring, target, index, + managed, Boolean.TRUE.equals(report) ); break; } case PLUGIN_DEP: { - expectField( jp, PLUGIN_REF ).nextTextValue(); - final ProjectRef plugin = (ProjectRef) prDeser.deserialize( jp, ctx ); - - expectField( jp, TARGET_REF ).nextTextValue(); - final ArtifactRef target = (ArtifactRef) arDeser.deserialize( jp, ctx ); - - rel = new PluginDependencyRelationship( sources, pomLocation, declaring, plugin, target, - getIndex( jp ), isManaged( jp ) ); + String plug = (String) ast.get( PLUGIN_REF ); + if ( plug == null ) + { + throw new JsonParseException( + "No plugin reference (field: " + PLUGIN_REF + ") found in plugin-dependency relationship!", + jp.getCurrentLocation() ); + } + + final ProjectRef plugin = ProjectRef.parse( plug ); + final ArtifactRef target = ArtifactRef.parse( tgt ); + + rel = new PluginDependencyRelationship( sources, pomLocation, declaring, plugin, target, index, + managed ); break; } case BOM: { - expectField( jp, TARGET_REF ).nextTextValue(); - final ProjectVersionRef target = (ProjectVersionRef) pvrDeser.deserialize( jp, ctx ); + final ProjectVersionRef target = ProjectVersionRef.parse( tgt ); - rel = new BomRelationship( sources, pomLocation, declaring, target, getIndex( jp ) ); + rel = new BomRelationship( sources, pomLocation, declaring, target, index ); break; } } - while ( jp.getCurrentToken() != JsonToken.END_OBJECT ) - { - jp.nextToken(); - } - return rel; } - - private void ff( JsonParser jp, JsonToken token ) - throws JsonParseException, IOException - { - if ( jp.getCurrentToken() == token ) - { - return; - } - - JsonToken t = null; - do - { - t = jp.nextToken(); - if ( t == null ) - { - throw new JsonParseException( "Expected token: " + token, jp.getCurrentLocation() ); - } - } - while ( t != token ); - } - - private JsonParser expectField( final JsonParser jp, final SerializedString named ) - throws JsonParseException, IOException - { - while ( jp.getCurrentToken() != null && !named.getValue().equals( jp.getCurrentName() ) ) - { - jp.nextToken(); - } - - if ( !named.getValue().equals( jp.getCurrentName() ) ) - { - throw new JsonParseException( "Expected field: " + named, jp.getCurrentLocation() ); - } - - return jp; - } - - private boolean isManaged( final JsonParser jp ) - throws IOException - { - return expectField( jp, MANAGED ).nextBooleanValue(); - } - - private int getIndex( final JsonParser jp ) - throws IOException - { - return expectField( jp, INDEX ).nextIntValue( 0 ); - } - - private boolean isReporting( final JsonParser jp ) - throws IOException - { - return expectField( jp, REPORTING ).nextBooleanValue(); - } - } } diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java index 700d33c0..86893b6a 100644 --- a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java @@ -24,46 +24,46 @@ private SerializationConstants() { } - public static final SerializedString SOURCE_URIS = new SerializedString( "source-uris" ); + public static final String SOURCE_URIS = "source-uris"; - public static final SerializedString SOURCE_URI = new SerializedString( "source-uri" ); + public static final String SOURCE_URI = "source-uri"; - public static final SerializedString POM_LOCATION_URI = new SerializedString( "pom-location-uri" ); + public static final String POM_LOCATION_URI = "pom-location-uri"; - public static final SerializedString PROJECT_VERSION = new SerializedString( "gav" ); + public static final String PROJECT_VERSION = "gav"; - public static final SerializedString GAV = PROJECT_VERSION; + public static final String GAV = PROJECT_VERSION; - public static final SerializedString RELATIONSHIP_TYPE = new SerializedString( "type" ); + public static final String RELATIONSHIP_TYPE = "type"; - public static final SerializedString DECLARING_REF = new SerializedString( "declaring" ); + public static final String DECLARING_REF = "declaring"; - public static final SerializedString TARGET_REF = new SerializedString( "target" ); + public static final String TARGET_REF = "target"; - public static final SerializedString INDEX = new SerializedString( "idx" ); + public static final String INDEX = "idx"; - public static final SerializedString MANAGED = new SerializedString( "managed" ); + public static final String MANAGED = "managed"; - public static final SerializedString REPORTING = new SerializedString( "reporting" ); + public static final String REPORTING = "reporting"; - public static final SerializedString SCOPE = new SerializedString( "scope" ); + public static final String SCOPE = "scope"; - public static final SerializedString PLUGIN_REF = new SerializedString( "plugin" ); + public static final String PLUGIN_REF = "plugin"; - public static final SerializedString JSON_VERSION = new SerializedString( "jsonVersion" ); + public static final String JSON_VERSION = "jsonVersion"; public static final int CURRENT_JSON_VERSION = 1; - public static final SerializedString EPROJECT_KEY = new SerializedString( "ekey" ); + public static final String EPROJECT_KEY = "ekey"; - public static final SerializedString RELATIONSHIPS = new SerializedString( "relationships" ); + public static final String RELATIONSHIPS = "relationships"; - public static final SerializedString EPROFILES = new SerializedString( "eprofiles" ); + public static final String EPROFILES = "eprofiles"; - public static final SerializedString CYCLES = new SerializedString( "cycles" ); + public static final String CYCLES = "cycles"; - public static final SerializedString WEB_ROOTS = new SerializedString( "gavs" ); + public static final String WEB_ROOTS = "gavs"; - public static final SerializedString GAVS = WEB_ROOTS; + public static final String GAVS = WEB_ROOTS; } diff --git a/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java b/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java new file mode 100644 index 00000000..769dd431 --- /dev/null +++ b/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java @@ -0,0 +1,86 @@ +package org.commonjava.maven.atlas.graph.jackson; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.ParentRelationship; +import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.util.RelationshipUtils; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.jackson.ProjectVersionRefSerializerModule; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; +import java.net.URI; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.isA; +import static org.junit.Assert.assertThat; + +/** + * Created by jdcasey on 8/21/15. + */ +public class ProjectRelationshipSerializerModuleTest +{ + + private ObjectMapper mapper; + + @Before + public void before() + { + mapper = new ObjectMapper(); + mapper.registerModules( new ProjectVersionRefSerializerModule(), new ProjectRelationshipSerializerModule() ); + } + + @Test + public void roundTrip_TerminalParentRelationship() + throws Exception + { + ParentRelationship rel = new ParentRelationship( new ProjectVersionRef( "org.foo", "bar", "1" ) ); + + String json = mapper.writeValueAsString( rel ); + System.out.println( json ); + + ProjectRelationship result = mapper.readValue( json, ProjectRelationship.class ); + + assertThat( (ParentRelationship) result, equalTo( rel ) ); + } + + @Test + public void roundTrip_ParentRelationship() + throws Exception + { + ParentRelationship rel = new ParentRelationship( URI.create( "some:test:location" ), + new ProjectVersionRef( "org.foo", "bar", "1" ), + new ProjectVersionRef( "org.foo", "parent", "1001" ) ); + + String json = mapper.writeValueAsString( rel ); + System.out.println( json ); + + ProjectRelationship result = mapper.readValue( json, ProjectRelationship.class ); + + assertThat( (ParentRelationship) result, equalTo( rel ) ); + } + + @Test + public void roundTrip_SimpleConcreteDependency() + throws Exception + { + DependencyRelationship rel = + new DependencyRelationship( URI.create( "some:test:location" ), RelationshipUtils.POM_ROOT_URI, + new ProjectVersionRef( "org.foo", "bar", "1" ), + new ProjectVersionRef( "org.foo", "dep", "1.1" ).asJarArtifact(), + DependencyScope.compile, 0, false ); + + String json = mapper.writeValueAsString( rel ); + System.out.println( json ); + + ProjectRelationship result = mapper.readValue( json, ProjectRelationship.class ); + + assertThat( (DependencyRelationship) result, equalTo( rel ) ); + } +} From 2cfab2d05d31b006d2ad4d8106f588df7efdf9bb Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 21 Aug 2015 12:18:38 -0500 Subject: [PATCH 092/240] adding bindings deps to managed set in root pom --- pom.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pom.xml b/pom.xml index 78f55f80..a5e62121 100644 --- a/pom.xml +++ b/pom.xml @@ -55,6 +55,16 @@ atlas-relationships-api 0.14.3-SNAPSHOT + + org.commonjava.maven.atlas + atlas-bindings-jackson-identities + 0.14.3-SNAPSHOT + + + org.commonjava.maven.atlas + atlas-bindings-jackson-relationships + 0.14.3-SNAPSHOT + org.commonjava.maven.atlas atlas-drivers-tck From 86474a12278e1702d8c5f73557d86b7106005681 Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 21 Aug 2015 14:32:05 -0500 Subject: [PATCH 093/240] update bom version --- .../ProjectRelationshipSerializerModuleTest.java | 15 +++++++++++++++ .../maven/atlas/graph/spi/neo4j/NodeToString.java | 15 +++++++++++++++ .../maven/atlas/graph/spi/neo4j/RelToString.java | 15 +++++++++++++++ pom.xml | 2 +- 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java b/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java index 769dd431..82a3aa3b 100644 --- a/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java +++ b/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.jackson; import com.fasterxml.jackson.core.JsonParseException; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeToString.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeToString.java index 2ac2fa94..9877c85e 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeToString.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeToString.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j; import org.commonjava.maven.atlas.graph.spi.neo4j.io.ConversionCache; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelToString.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelToString.java index 5d653552..ac915c14 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelToString.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelToString.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; diff --git a/pom.xml b/pom.xml index a5e62121..1d6dbc21 100644 --- a/pom.xml +++ b/pom.xml @@ -75,7 +75,7 @@ org.commonjava.boms web-commons-bom - 17-SNAPSHOT + 17 import pom From bf187cae25e7be6abf2927072d6d18c6c8f80779 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 25 Aug 2015 15:06:27 -0500 Subject: [PATCH 094/240] also match on the enum name(). --- .../commonjava/maven/atlas/graph/rel/RelationshipType.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipType.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipType.java index 81ea4071..07cd9b29 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipType.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipType.java @@ -50,6 +50,11 @@ public static RelationshipType getType( String type ) type = type.trim(); for ( final RelationshipType rt : values() ) { + if ( rt.name().equals(type)) + { + return rt; + } + for ( final String name : rt.names() ) { if ( name.equalsIgnoreCase( type ) ) From 318fe79a629a53f97ef735c40f90bb5449824444 Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 21 Aug 2015 18:40:59 -0500 Subject: [PATCH 095/240] refactor into identity interfaces and simple (standalone) impls --- .../ProjectVersionRefSerializerModule.java | 40 ++- ...ProjectVersionRefSerializerModuleTest.java | 5 +- .../ProjectRelationshipSerializerModule.java | 20 +- ...ojectRelationshipSerializerModuleTest.java | 17 +- .../graph/spi/jung/JungGraphConnection.java | 32 +- .../spi/jung/PathDetectionTraversal.java | 1 + .../spi/neo4j/FileNeo4JGraphConnection.java | 54 +-- .../graph/spi/neo4j/io/ConversionCache.java | 8 +- .../atlas/graph/spi/neo4j/io/Conversions.java | 12 +- .../graph/spi/neo4j/CypherQueriesTest.java | 27 +- .../maven/atlas/ident/ref/ArtifactRef.java | 218 +----------- .../maven/atlas/ident/ref/ProjectRef.java | 181 +--------- .../atlas/ident/ref/ProjectVersionRef.java | 316 ++--------------- .../atlas/ident/ref/SimpleArtifactRef.java | 227 ++++++++++++ .../atlas/ident/ref/SimpleProjectRef.java | 192 ++++++++++ .../ident/ref/SimpleProjectVersionRef.java | 335 ++++++++++++++++++ .../ident/ref/SimpleTypeAndClassifier.java | 114 ++++++ .../ref/SimpleVersionlessArtifactRef.java | 232 ++++++++++++ .../atlas/ident/ref/TypeAndClassifier.java | 114 +----- .../ident/ref/VersionlessArtifactRef.java | 219 +----------- .../atlas/ident/util/ArtifactPathInfo.java | 9 +- .../ident/util/ArtifactRefComparator.java | 1 + .../maven/atlas/ident/util/IdentityUtils.java | 20 +- .../util/ProjectVersionRefComparator.java | 1 + .../VersionlessArtifactRefComparator.java | 4 +- .../maven/atlas/ident/ref/ProjectRefTest.java | 24 +- .../ident/ref/ProjectVersionRefTest.java | 19 +- ...efTest.java => SimpleArtifactRefTest.java} | 10 +- .../ident/ref/VersionlessArtifactRefTest.java | 72 ++-- .../maven/atlas/graph/RelationshipGraph.java | 23 +- .../maven/atlas/graph/ViewParams.java | 22 +- .../model/EProjectDirectRelationships.java | 5 +- .../rel/AbstractProjectRelationship.java | 14 +- .../atlas/graph/rel/BomRelationship.java | 1 - .../graph/rel/DependencyRelationship.java | 17 +- .../graph/rel/ExtensionRelationship.java | 11 +- .../atlas/graph/rel/ParentRelationship.java | 11 +- .../rel/PluginDependencyRelationship.java | 13 +- .../atlas/graph/rel/PluginRelationship.java | 4 +- .../atlas/graph/rel/ProjectRelationship.java | 2 + .../spi/RelationshipGraphConnection.java | 6 - .../graph/traverse/BuildOrderTraversal.java | 8 +- .../TransitiveDependencyTraversal.java | 11 +- .../graph/traverse/print/ListPrinter.java | 2 + .../graph/traverse/print/TreePrinter.java | 2 + .../atlas/graph/util/RelationshipUtils.java | 1 + .../graph/EProjectRelationshipsTest.java | 17 +- .../graph/filter/DependencyFilterTest.java | 8 +- .../graph/rel/ParentRelationshipTest.java | 7 +- .../rel/RelationshipPathComparatorTest.java | 1 + .../atlas/tck/graph/CycleDetectionTCK.java | 71 ++-- .../graph/RelationshipGraphFactoryTCK.java | 7 +- .../atlas/tck/graph/RelationshipGraphTCK.java | 23 +- .../atlas/tck/graph/SubGraphSelectionTCK.java | 27 +- .../graph/traverse/AncestryTraversalTCK.java | 33 +- .../traverse/BuildOrderTraversalTCK.java | 63 ++-- .../TransitiveDependencyTraversalTCK.java | 1 + 57 files changed, 1539 insertions(+), 1396 deletions(-) create mode 100644 identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRef.java create mode 100644 identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectRef.java create mode 100644 identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java create mode 100644 identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleTypeAndClassifier.java create mode 100644 identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleVersionlessArtifactRef.java rename identities/src/test/java/org/commonjava/maven/atlas/ident/ref/{ArtifactRefTest.java => SimpleArtifactRefTest.java} (85%) diff --git a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java index fb7c3f43..b597dca4 100644 --- a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java +++ b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java @@ -19,22 +19,15 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.KeyDeserializer; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.VersionlessArtifactRef; +import org.commonjava.maven.atlas.ident.ref.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.fasterxml.jackson.databind.deser.std.StdKeyDeserializer; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.ser.std.StdSerializer; @@ -69,8 +62,8 @@ public ProjectVersionRefSerializerModule() addKeyDeserializer( ProjectVersionRef.class, new ProjectRefKeyDeserializer( ProjectVersionRef.class ) ); - logger.debug( "Registering ArtifactRef serializer/deserialer" ); - // ArtifactRef + logger.debug( "Registering SimpleArtifactRef serializer/deserialer" ); + // SimpleArtifactRef addSerializer( ArtifactRef.class, new ProjectRefSerializer( ArtifactRef.class, false ) ); addKeySerializer( ArtifactRef.class, new ProjectRefSerializer( ArtifactRef.class, true ) ); @@ -105,9 +98,32 @@ public boolean equals( final Object other ) private T parse( final String value, final Class type ) throws IOException { + Class realType = null; + if ( ProjectRef.class.equals( type ) ) + { + realType = SimpleProjectRef.class; + } + else if ( ProjectVersionRef.class.equals( type ) ) + { + realType = SimpleProjectVersionRef.class; + } + else if ( ArtifactRef.class.equals( type ) ) + { + realType = SimpleArtifactRef.class; + } + else if ( VersionlessArtifactRef.class.equals( type ) ) + { + realType = SimpleVersionlessArtifactRef.class; + } + + if ( realType == null ) + { + throw new IOException( "Cannot find concrete class for type: " + type.getSimpleName() ); + } + try { - final Method parseMethod = type.getMethod( "parse", String.class ); + final Method parseMethod = realType.getMethod( "parse", String.class ); return type.cast( parseMethod.invoke( null, value ) ); } catch ( final NoSuchMethodException e ) diff --git a/bindings/jackson-identities/src/test/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModuleTest.java b/bindings/jackson-identities/src/test/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModuleTest.java index 9534cc7c..6ff3d8a6 100644 --- a/bindings/jackson-identities/src/test/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModuleTest.java +++ b/bindings/jackson-identities/src/test/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModuleTest.java @@ -22,6 +22,7 @@ import java.util.Map; import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; import org.junit.Before; import org.junit.Test; @@ -44,7 +45,7 @@ public void setup() public void projectRefRoundTrip() throws Exception { - final ProjectRef pr = new ProjectRef( "org.foo", "bar" ); + final ProjectRef pr = new SimpleProjectRef( "org.foo", "bar" ); final String json = mapper.writeValueAsString( pr ); final ProjectRef result = mapper.readValue( json, ProjectRef.class ); @@ -56,7 +57,7 @@ public void projectRefRoundTrip() public void mapWithProjectRefKeyRoundTrip() throws Exception { - final ProjectRef pr = new ProjectRef( "org.foo", "bar" ); + final ProjectRef pr = new SimpleProjectRef( "org.foo", "bar" ); final String value = "this is the value"; final Map map = new HashMap(); diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java index 930f12c4..1b7d4c94 100644 --- a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java @@ -24,9 +24,7 @@ import org.commonjava.maven.atlas.graph.rel.*; import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -255,7 +253,7 @@ public ProjectRelationship deserialize( final JsonParser jp, final Deserializati } String decl = (String) ast.get( DECLARING_REF ); - final ProjectVersionRef declaring = ProjectVersionRef.parse( decl ); + final ProjectVersionRef declaring = SimpleProjectVersionRef.parse( decl ); String tgt = (String) ast.get( TARGET_REF ); Integer index = (Integer) ast.get( INDEX ); @@ -272,7 +270,7 @@ public ProjectRelationship deserialize( final JsonParser jp, final Deserializati { case DEPENDENCY: { - final ArtifactRef target = ArtifactRef.parse( tgt ); + final ArtifactRef target = SimpleArtifactRef.parse( tgt ); String scp = (String) ast.get(SCOPE); final DependencyScope scope; @@ -291,21 +289,21 @@ public ProjectRelationship deserialize( final JsonParser jp, final Deserializati } case EXTENSION: { - final ProjectVersionRef target = ProjectVersionRef.parse( tgt ); + final ProjectVersionRef target = SimpleProjectVersionRef.parse( tgt ); rel = new ExtensionRelationship( sources, pomLocation, declaring, target, index ); break; } case PARENT: { - final ProjectVersionRef target = ProjectVersionRef.parse( tgt ); + final ProjectVersionRef target = SimpleProjectVersionRef.parse( tgt ); rel = new ParentRelationship( sources, declaring, target ); break; } case PLUGIN: { - final ProjectVersionRef target = ProjectVersionRef.parse( tgt ); + final ProjectVersionRef target = SimpleProjectVersionRef.parse( tgt ); Boolean report = (Boolean) ast.get( REPORTING ); rel = new PluginRelationship( sources, pomLocation, declaring, target, index, @@ -322,8 +320,8 @@ public ProjectRelationship deserialize( final JsonParser jp, final Deserializati jp.getCurrentLocation() ); } - final ProjectRef plugin = ProjectRef.parse( plug ); - final ArtifactRef target = ArtifactRef.parse( tgt ); + final ProjectRef plugin = SimpleProjectRef.parse( plug ); + final ArtifactRef target = SimpleArtifactRef.parse( tgt ); rel = new PluginDependencyRelationship( sources, pomLocation, declaring, plugin, target, index, managed ); @@ -331,7 +329,7 @@ public ProjectRelationship deserialize( final JsonParser jp, final Deserializati } case BOM: { - final ProjectVersionRef target = ProjectVersionRef.parse( tgt ); + final ProjectVersionRef target = SimpleProjectVersionRef.parse( tgt ); rel = new BomRelationship( sources, pomLocation, declaring, target, index ); break; diff --git a/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java b/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java index 82a3aa3b..7b8d43dd 100644 --- a/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java +++ b/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java @@ -15,8 +15,6 @@ */ package org.commonjava.maven.atlas.graph.jackson; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; import org.commonjava.maven.atlas.graph.rel.ParentRelationship; @@ -24,16 +22,13 @@ import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.DependencyScope; import org.commonjava.maven.atlas.ident.jackson.ProjectVersionRefSerializerModule; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.junit.Before; import org.junit.Test; -import java.io.IOException; import java.net.URI; import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.isA; import static org.junit.Assert.assertThat; /** @@ -55,7 +50,7 @@ public void before() public void roundTrip_TerminalParentRelationship() throws Exception { - ParentRelationship rel = new ParentRelationship( new ProjectVersionRef( "org.foo", "bar", "1" ) ); + ParentRelationship rel = new ParentRelationship( new SimpleProjectVersionRef( "org.foo", "bar", "1" ) ); String json = mapper.writeValueAsString( rel ); System.out.println( json ); @@ -70,8 +65,8 @@ public void roundTrip_ParentRelationship() throws Exception { ParentRelationship rel = new ParentRelationship( URI.create( "some:test:location" ), - new ProjectVersionRef( "org.foo", "bar", "1" ), - new ProjectVersionRef( "org.foo", "parent", "1001" ) ); + new SimpleProjectVersionRef( "org.foo", "bar", "1" ), + new SimpleProjectVersionRef( "org.foo", "parent", "1001" ) ); String json = mapper.writeValueAsString( rel ); System.out.println( json ); @@ -87,8 +82,8 @@ public void roundTrip_SimpleConcreteDependency() { DependencyRelationship rel = new DependencyRelationship( URI.create( "some:test:location" ), RelationshipUtils.POM_ROOT_URI, - new ProjectVersionRef( "org.foo", "bar", "1" ), - new ProjectVersionRef( "org.foo", "dep", "1.1" ).asJarArtifact(), + new SimpleProjectVersionRef( "org.foo", "bar", "1" ), + new SimpleProjectVersionRef( "org.foo", "dep", "1.1" ).asJarArtifact(), DependencyScope.compile, 0, false ); String json = mapper.writeValueAsString( rel ); diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java index ee2b68e2..461442f6 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java @@ -15,22 +15,8 @@ */ package org.commonjava.maven.atlas.graph.spi.jung; -import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.POM_ROOT_URI; -import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.UNKNOWN_SOURCE_URI; - -import java.net.URI; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - +import edu.uci.ics.jung.graph.DirectedGraph; +import edu.uci.ics.jung.graph.DirectedSparseMultigraph; import org.apache.commons.lang.StringUtils; import org.commonjava.maven.atlas.graph.RelationshipGraph; import org.commonjava.maven.atlas.graph.ViewParams; @@ -56,8 +42,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import edu.uci.ics.jung.graph.DirectedGraph; -import edu.uci.ics.jung.graph.DirectedSparseMultigraph; +import java.net.URI; +import java.util.*; +import java.util.Map.Entry; + +import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.POM_ROOT_URI; +import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.UNKNOWN_SOURCE_URI; public class JungGraphConnection implements RelationshipGraphConnection @@ -892,9 +882,6 @@ public void addDisconnectedProject( final ProjectVersionRef ref ) } } - /** - * @deprecated Use {@link #getDirectRelationshipsFrom(GraphView,ProjectVersionRef,boolean,boolean,RelationshipType...)} instead - */ @Deprecated @Override public Set> getDirectRelationshipsFrom( final ViewParams params, @@ -968,9 +955,6 @@ private Set> getMatchingRelationships( final Collection

> getDirectRelationshipsTo( final ViewParams params, final ProjectVersionRef to, diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java index ff9ebc91..94ce25b2 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java @@ -29,6 +29,7 @@ import org.commonjava.maven.atlas.graph.spi.jung.model.JungGraphPath; import org.commonjava.maven.atlas.graph.traverse.AbstractTraversal; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; final class PathDetectionTraversal extends AbstractTraversal diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java index 5a350520..e6e0f81d 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java @@ -15,39 +15,6 @@ */ package org.commonjava.maven.atlas.graph.spi.neo4j; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.CONFIG_ID; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.GA; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.GAV; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.NID; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.RELATIONSHIP_ID; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.RID; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.SOURCE_URI; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.VIEW_ID; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.addToURISetProperty; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.convertToProjects; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.convertToRelationships; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.getMetadataMap; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.getStringProperty; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.id; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.isConnected; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.markConnected; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.toNodeProperties; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.toProjectRelationship; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.toProjectVersionRef; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.toRelationshipProperties; -import static org.commonjava.maven.atlas.graph.spi.neo4j.traverse.TraversalUtils.getGraphRelTypes; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - import org.commonjava.maven.atlas.graph.RelationshipGraph; import org.commonjava.maven.atlas.graph.ViewParams; import org.commonjava.maven.atlas.graph.model.EProjectCycle; @@ -62,13 +29,7 @@ import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; -import org.commonjava.maven.atlas.graph.spi.neo4j.traverse.AtlasCollector; -import org.commonjava.maven.atlas.graph.spi.neo4j.traverse.MembershipWrappedTraversalEvaluator; -import org.commonjava.maven.atlas.graph.spi.neo4j.traverse.PathCollectingVisitor; -import org.commonjava.maven.atlas.graph.spi.neo4j.traverse.PathExistenceVisitor; -import org.commonjava.maven.atlas.graph.spi.neo4j.traverse.SubPathsCollectingVisitor; -import org.commonjava.maven.atlas.graph.spi.neo4j.traverse.TraversalUtils; -import org.commonjava.maven.atlas.graph.spi.neo4j.traverse.TraverseVisitor; +import org.commonjava.maven.atlas.graph.spi.neo4j.traverse.*; import org.commonjava.maven.atlas.graph.spi.neo4j.update.CycleCacheUpdater; import org.commonjava.maven.atlas.graph.spi.neo4j.update.ViewUpdater; import org.commonjava.maven.atlas.graph.traverse.RelationshipGraphTraversal; @@ -79,12 +40,7 @@ import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; import org.neo4j.cypher.javacompat.ExecutionEngine; import org.neo4j.cypher.javacompat.ExecutionResult; -import org.neo4j.graphdb.Direction; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Path; -import org.neo4j.graphdb.Relationship; -import org.neo4j.graphdb.Transaction; +import org.neo4j.graphdb.*; import org.neo4j.graphdb.factory.GraphDatabaseFactory; import org.neo4j.graphdb.index.Index; import org.neo4j.graphdb.index.IndexHits; @@ -96,6 +52,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.util.*; + +import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.*; +import static org.commonjava.maven.atlas.graph.spi.neo4j.traverse.TraversalUtils.getGraphRelTypes; + public class FileNeo4JGraphConnection implements Runnable, Neo4JGraphConnection { diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/ConversionCache.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/ConversionCache.java index 71511866..12ddc29c 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/ConversionCache.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/ConversionCache.java @@ -15,16 +15,16 @@ */ package org.commonjava.maven.atlas.graph.spi.neo4j.io; -import java.lang.ref.WeakReference; -import java.util.HashMap; -import java.util.Map; - import org.apache.commons.codec.digest.DigestUtils; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Relationship; +import java.lang.ref.WeakReference; +import java.util.HashMap; +import java.util.Map; + public class ConversionCache { diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java index a834b806..23440b59 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java @@ -50,9 +50,7 @@ import org.commonjava.maven.atlas.graph.spi.neo4j.NodeType; import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.*; import org.neo4j.graphdb.Node; import org.neo4j.graphdb.PropertyContainer; import org.neo4j.graphdb.Relationship; @@ -302,7 +300,7 @@ public static ProjectVersionRef toProjectVersionRef( final Node node, final Conv throw new IllegalArgumentException( String.format( "GAV cannot contain nulls: %s:%s:%s", g, a, v ) ); } - final ProjectVersionRef result = new ProjectVersionRef( g, a, v ); + final ProjectVersionRef result = new SimpleProjectVersionRef( g, a, v ); if ( cache != null ) { cache.cache( node, result ); @@ -464,7 +462,7 @@ public static ProjectRelationship toProjectRelationship( final Relationship r } else { - excludes.add( new ProjectRef( parts[0], parts[1] ) ); + excludes.add( new SimpleProjectRef( parts[0], parts[1] ) ); } } } @@ -482,7 +480,7 @@ public static ProjectRelationship toProjectRelationship( final Relationship r final boolean managed = getBooleanProperty( IS_MANAGED, rel ); result = - new PluginDependencyRelationship( source, pomLocation, from, new ProjectRef( pg, pa ), artifact, + new PluginDependencyRelationship( source, pomLocation, from, new SimpleProjectRef( pg, pa ), artifact, index, managed ); break; } @@ -541,7 +539,7 @@ private static ArtifactRef toArtifactRef( final ProjectVersionRef ref, final Rel final String classifier = getStringProperty( CLASSIFIER, rel ); final boolean optional = getBooleanProperty( OPTIONAL, rel ); - return new ArtifactRef( ref, type, classifier, optional ); + return new SimpleArtifactRef( ref, type, classifier, optional ); } private static void toRelationshipProperties( final ArtifactRef target, final Relationship relationship ) diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/CypherQueriesTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/CypherQueriesTest.java index 7f5a22f9..eaf6563c 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/CypherQueriesTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/CypherQueriesTest.java @@ -23,8 +23,9 @@ import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; import org.commonjava.maven.atlas.graph.spi.neo4j.fixture.FileConnectionFixture; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; import org.junit.Rule; import org.junit.Test; @@ -45,18 +46,18 @@ public class CypherQueriesTest public void projectsWithVariableFlag_PartialQuery() throws Exception { - final ProjectVersionRef project = new ProjectVersionRef( "org.my", "project", "1.0" ); - final ProjectVersionRef varDep = new ProjectVersionRef( "org.other", "dep", "1.0-SNAPSHOT" ); - final ProjectVersionRef varD2 = new ProjectVersionRef( "org.other", "dep2", "1.0-SNAPSHOT" ); - final ProjectVersionRef selected = new ProjectVersionRef( varDep, "1.0-20130314.161200-1" ); + final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); + final ProjectVersionRef varDep = new SimpleProjectVersionRef( "org.other", "dep", "1.0-SNAPSHOT" ); + final ProjectVersionRef varD2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0-SNAPSHOT" ); + final ProjectVersionRef selected = new SimpleProjectVersionRef( varDep, "1.0-20130314.161200-1" ); final URI source = sourceURI(); RelationshipGraph graph = simpleGraph( project ); /* @formatter:off */ graph.storeRelationships( - new DependencyRelationship( source, project, new ArtifactRef( varDep, null, null, false ), null, 0, false ), - new DependencyRelationship( source, varDep, new ArtifactRef( varD2, null, null, false ), null, 0, false ) + new DependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false ), + new DependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false ) ); graph = graphFactory().open( new ViewParams.Builder( graph.getParams() ).withSelection( varDep.asProjectRef(), selected ).build(), false ); @@ -88,18 +89,18 @@ public void projectsWithVariableFlag_PartialQuery() public void projectsWithVariableFlagQuery() throws Exception { - final ProjectVersionRef project = new ProjectVersionRef( "org.my", "project", "1.0" ); - final ProjectVersionRef varDep = new ProjectVersionRef( "org.other", "dep", "1.0-SNAPSHOT" ); - final ProjectVersionRef varD2 = new ProjectVersionRef( "org.other", "dep2", "1.0-SNAPSHOT" ); - final ProjectVersionRef selected = new ProjectVersionRef( varDep, "1.0-20130314.161200-1" ); + final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); + final ProjectVersionRef varDep = new SimpleProjectVersionRef( "org.other", "dep", "1.0-SNAPSHOT" ); + final ProjectVersionRef varD2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0-SNAPSHOT" ); + final ProjectVersionRef selected = new SimpleProjectVersionRef( varDep, "1.0-20130314.161200-1" ); final URI source = sourceURI(); RelationshipGraph graph = simpleGraph( project ); /* @formatter:off */ graph.storeRelationships( - new DependencyRelationship( source, project, new ArtifactRef( varDep, null, null, false ), null, 0, false ), - new DependencyRelationship( source, varDep, new ArtifactRef( varD2, null, null, false ), null, 0, false ) + new DependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false ), + new DependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false ) ); graph = graphFactory().open( new ViewParams.Builder( graph.getParams()).withSelection( varDep.asProjectRef(), selected ).build(), false ); diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java index e927c834..d93df8cb 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java @@ -1,222 +1,20 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.commonjava.maven.atlas.ident.ref; -import static org.apache.commons.lang.StringUtils.isEmpty; - import java.io.Serializable; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; -import org.commonjava.maven.atlas.ident.version.SingleVersion; -import org.commonjava.maven.atlas.ident.version.VersionSpec; - /** - * Represents an artifact, in Maven parlance. A tangible result of a build, which is typically made available in a Maven repository for others - * to consume. NOTE: a POM file is both a piece of metadata AND an artifact in the Maven world! - * - * Artifacts are based on the GAV coordinate for the project release, but also contain a type and optionally, a classifier. Type defaults to 'jar'. - * - * @see {@link ProjectRef} - * @see {@link ProjectVersionRef} - * - * @author jdcasey + * Created by jdcasey on 8/21/15. */ -public class ArtifactRef - extends ProjectVersionRef - implements Serializable +public interface ArtifactRef + extends ProjectVersionRef, Serializable, Comparable, VersionedRef { + String getType(); - private static final long serialVersionUID = 1L; - - private final TypeAndClassifier tc; - - private final boolean optional; - - public ArtifactRef( final String groupId, final String artifactId, final VersionSpec version, final String type, - final String classifier, final boolean optional ) - { - super( groupId, artifactId, version ); - this.optional = optional; - this.tc = new TypeAndClassifier( type, classifier ); - } - - public ArtifactRef( final ProjectVersionRef ref, final String type, final String classifier, final boolean optional ) - { - super( ref.getGroupId(), ref.getArtifactId(), ref.getVersionSpecRaw(), ref.getVersionStringRaw() ); - this.optional = optional; - this.tc = new TypeAndClassifier( type, classifier ); - } - - public ArtifactRef( final ProjectVersionRef ref, final TypeAndClassifier tc, final boolean optional ) - { - super( ref.getGroupId(), ref.getArtifactId(), ref.getVersionSpecRaw(), ref.getVersionStringRaw() ); - this.tc = tc; - this.optional = optional; - } - - public ArtifactRef( final String groupId, final String artifactId, final String versionSpec, final String type, - final String classifier, final boolean optional ) - throws InvalidVersionSpecificationException - { - super( groupId, artifactId, versionSpec ); - this.tc = new TypeAndClassifier( type, classifier ); - this.optional = optional; - } - - @Override - public String toString() - { - return String.format( "%s:%s:%s:%s%s", getGroupId(), getArtifactId(), getType(), getVersionString(), - ( getClassifier() == null ? "" : ":" + getClassifier() ) ); - } - - public static ArtifactRef parse( final String spec ) - { - final String[] parts = spec.split( ":" ); - - if ( parts.length < 3 || isEmpty( parts[0] ) || isEmpty( parts[1] ) || isEmpty( parts[2] ) ) - { - throw new InvalidRefException( - "ArtifactRef must contain AT LEAST non-empty groupId, artifactId, AND version. (Given: '" - + spec + "')" ); - } - - final String g = parts[0]; - final String a = parts[1]; - - // assume we're actually parsing a GAV into a POM artifact... - String v = parts[2]; - String t = "pom"; - String c = null; - - if ( parts.length > 3 ) - { - // oops, it's a type, not a version...see toString() for the specification. - t = v; - v = parts[3]; - - if ( parts.length > 4 ) - { - c = parts[4]; - } - } - - // assume non-optional, because it might not matter if you're parsing a string like this...you'd be more careful if you were reading something - // that had an optional field, because it's not in the normal GATV[C] spec. - return new ArtifactRef( g, a, v, t, c, false ); - } - - @Override - protected ProjectVersionRef newRef( final String groupId, final String artifactId, final SingleVersion version ) - { - return new ArtifactRef( groupId, artifactId, version, tc.getType(), tc.getClassifier(), optional ); - } - - public String getType() - { - return tc.getType(); - } - - public String getClassifier() - { - return tc.getClassifier(); - } - - public TypeAndClassifier getTypeAndClassifier() - { - return tc; - } - - public ArtifactRef setOptional( final boolean optional ) - { - if ( this.optional == optional ) - { - return this; - } - - return new ArtifactRef( this, getType(), getClassifier(), optional ); - } - - public boolean isOptional() - { - return optional; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ( ( tc == null ) ? 0 : tc.hashCode() ); - result = prime * result + Boolean.valueOf( optional ) - .hashCode(); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( !super.equals( obj ) ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final ArtifactRef other = (ArtifactRef) obj; - - return artifactFieldsEqual( other ); - } - - private boolean artifactFieldsEqual( final ArtifactRef other ) - { - if ( tc == null ) - { - if ( other.tc != null ) - { - return false; - } - } - else if ( !tc.equals( other.tc ) ) - { - return false; - } - return true; - } - - @Override - public boolean versionlessEquals( final ProjectVersionRef other ) - { - if ( !super.versionlessEquals( other ) ) - { - return false; - } + String getClassifier(); - if ( !( other instanceof ArtifactRef ) ) - { - // compare vs. POM reference. - return artifactFieldsEqual( new ArtifactRef( other, "pom", null, false ) ); - } + TypeAndClassifier getTypeAndClassifier(); - return artifactFieldsEqual( (ArtifactRef) other ); - } + boolean isOptional(); + boolean versionlessEquals( ProjectVersionRef other ); } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java index a26aca96..e7cbdcb3 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java @@ -1,185 +1,30 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.commonjava.maven.atlas.ident.ref; -import static org.apache.commons.lang.StringUtils.isEmpty; - import java.io.Serializable; /** - * Reference to a whole project (or module, in terms of Maven builds). This reference is not specific to a release of the project (see {@link ProjectVersionRef}). - * - * @author jdcasey + * Created by jdcasey on 8/21/15. */ -public class ProjectRef - implements Serializable, Comparable +public interface ProjectRef + extends Serializable, Comparable { + String getGroupId(); - private static final long serialVersionUID = 1L; - - // NEVER null - private final String groupId; - - // NEVER null - private final String artifactId; - - public ProjectRef( final String groupId, final String artifactId ) - { - if ( isEmpty( groupId ) || isEmpty( artifactId ) ) - { - throw new InvalidRefException( "ProjectId must contain non-empty groupId AND artifactId. (Given: '" - + groupId + "':'" + artifactId + "')" ); - } - - this.groupId = groupId; - this.artifactId = artifactId; - } - - public static ProjectRef parse( final String ga ) - { - final String[] parts = ga.split( ":" ); - if ( parts.length < 2 || isEmpty( parts[0] ) || isEmpty( parts[1] ) ) - { - throw new InvalidRefException( "ProjectRef must contain non-empty groupId AND artifactId. (Given: '" + ga - + "')" ); - } - - return new ProjectRef( parts[0], parts[1] ); - } - - public final String getGroupId() - { - return groupId; - } - - public final String getArtifactId() - { - return artifactId; - } - - public ProjectRef asProjectRef() - { - return ProjectRef.class.equals( getClass() ) ? this : new ProjectRef( getGroupId(), getArtifactId() ); - } - - public VersionlessArtifactRef asVersionlessPomArtifact() - { - return asVersionlessArtifactRef( "pom", null, false ); - } - - public VersionlessArtifactRef asVersionlessJarArtifact() - { - return asVersionlessArtifactRef( "jar", null, false ); - } - - public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier ) - { - return asVersionlessArtifactRef( type, classifier, false ); - } - - public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier, - final boolean optional ) - { - return new VersionlessArtifactRef( this, type, classifier, optional ); - } - - public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc ) - { - return asVersionlessArtifactRef( tc, false ); - } - - public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc, final boolean optional ) - { - return new VersionlessArtifactRef( this, tc, optional ); - } - - @Override - public String toString() - { - return String.format( "%s:%s", groupId, artifactId ); - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + artifactId.hashCode(); - result = prime * result + groupId.hashCode(); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( obj == null ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final ProjectRef other = (ProjectRef) obj; - if ( !artifactId.equals( other.artifactId ) ) - { - return false; - } - return groupId.equals( other.groupId ); - } + String getArtifactId(); - @Override - public int compareTo( final ProjectRef o ) - { - int comp = groupId.compareTo( o.groupId ); - if ( comp == 0 ) - { - comp = artifactId.compareTo( o.artifactId ); - } + ProjectRef asProjectRef(); - return comp; - } + VersionlessArtifactRef asVersionlessPomArtifact(); - public boolean matches( final ProjectRef ref ) - { - if ( equals( ref ) ) - { - return true; - } + VersionlessArtifactRef asVersionlessJarArtifact(); - final String gidPattern = toWildcard( getGroupId() ); - if ( !ref.getGroupId() - .matches( gidPattern ) ) - { - return false; - } + VersionlessArtifactRef asVersionlessArtifactRef( String type, String classifier ); - final String aidPattern = toWildcard( getArtifactId() ); - return ref.getArtifactId().matches( aidPattern ); + VersionlessArtifactRef asVersionlessArtifactRef( String type, String classifier, boolean optional ); - } + VersionlessArtifactRef asVersionlessArtifactRef( TypeAndClassifier tc ); - private String toWildcard( final String val ) - { - return val.replaceAll( "\\.", "\\." ) - .replaceAll( "\\*", ".*" ); - } + VersionlessArtifactRef asVersionlessArtifactRef( TypeAndClassifier tc, boolean optional ); + boolean matches( ProjectRef ref ); } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java index 03c2fa3d..52e00c12 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java @@ -1,330 +1,70 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.commonjava.maven.atlas.ident.ref; -import static org.apache.commons.lang.StringUtils.isEmpty; - -import java.io.Serializable; - -import org.commonjava.maven.atlas.ident.util.VersionUtils; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; import org.commonjava.maven.atlas.ident.version.SingleVersion; import org.commonjava.maven.atlas.ident.version.VersionSpec; +import java.io.Serializable; + /** - * Reference to a particular release of a project (or module, in terms of Maven builds). A release may contain many artifacts (see {@link ArtifactRef}). - * - * @see {@link ProjectRef} - * @see {@link ArtifactRef} - * - * @author jdcasey + * Created by jdcasey on 8/21/15. */ -public class ProjectVersionRef - extends ProjectRef - implements VersionedRef, Serializable +public interface ProjectVersionRef + extends ProjectRef, VersionedRef,Serializable { + ProjectVersionRef asProjectVersionRef(); - private static final long serialVersionUID = 1L; - - // NEVER null - private VersionSpec versionSpec; - - private String versionString; - - public ProjectVersionRef( final ProjectRef ref, final VersionSpec versionSpec ) - { - this( ref.getGroupId(), ref.getArtifactId(), versionSpec, null ); - } - - public ProjectVersionRef( final ProjectRef ref, final String versionSpec ) - throws InvalidVersionSpecificationException - { - this( ref.getGroupId(), ref.getArtifactId(), versionSpec ); - } - - ProjectVersionRef( final String groupId, final String artifactId, final VersionSpec versionSpec, - final String versionString ) - { - super( groupId, artifactId ); - if ( versionSpec == null && versionString == null ) - { - throw new InvalidRefException( "Version spec AND string cannot both be null for '" + groupId + ":" - + artifactId + "'" ); - } - - this.versionString = versionString; - this.versionSpec = versionSpec; - } - - public ProjectVersionRef( final String groupId, final String artifactId, final VersionSpec versionSpec ) - { - this( groupId, artifactId, versionSpec, null ); - } - - public ProjectVersionRef( final String groupId, final String artifactId, final String versionString ) - throws InvalidVersionSpecificationException - { - this( groupId, artifactId, null, versionString ); - } - - public static ProjectVersionRef parse( final String gav ) - { - final String[] parts = gav.split( ":" ); - if ( parts.length < 3 || isEmpty( parts[0] ) || isEmpty( parts[1] ) || isEmpty( parts[2] ) ) - { - throw new InvalidRefException( - "ProjectVersionRef must contain non-empty groupId, artifactId, AND version. (Given: '" - + gav + "')" ); - } - - return new ProjectVersionRef( parts[0], parts[1], parts[2] ); - } + ArtifactRef asPomArtifact(); - public ProjectVersionRef asProjectVersionRef() - { - return ProjectVersionRef.class.equals( getClass() ) ? this : new ProjectVersionRef( getGroupId(), - getArtifactId(), - getVersionSpecRaw(), - getVersionStringRaw() ); - } + ArtifactRef asJarArtifact(); - public ArtifactRef asPomArtifact() - { - return asArtifactRef( "pom", null, false ); - } + ArtifactRef asArtifactRef( String type, String classifier ); - public ArtifactRef asJarArtifact() - { - return asArtifactRef( "jar", null, false ); - } + ArtifactRef asArtifactRef( String type, String classifier, boolean optional ); - public ArtifactRef asArtifactRef( final String type, final String classifier ) - { - return asArtifactRef( type, classifier, false ); - } + ArtifactRef asArtifactRef( TypeAndClassifier tc ); - public ArtifactRef asArtifactRef( final String type, final String classifier, final boolean optional ) - { - return new ArtifactRef( this, type, classifier, optional ); - } + ArtifactRef asArtifactRef( TypeAndClassifier tc, boolean optional ); - public ArtifactRef asArtifactRef( final TypeAndClassifier tc ) - { - return asArtifactRef( tc, false ); - } + VersionSpec getVersionSpecRaw(); - public ArtifactRef asArtifactRef( final TypeAndClassifier tc, final boolean optional ) - { - return new ArtifactRef( this, tc, optional ); - } - - VersionSpec getVersionSpecRaw() - { - return versionSpec; - } - - String getVersionStringRaw() - { - return versionString; - } + String getVersionStringRaw(); @Override - public boolean isRelease() - { - return getVersionSpec().isRelease(); - } + boolean isRelease(); @Override - public boolean isSpecificVersion() - { - return getVersionSpec().isSingle(); - } + boolean isSpecificVersion(); @Override - public boolean matchesVersion( final SingleVersion version ) - { - return getVersionSpec().contains( version ); - } + boolean matchesVersion( SingleVersion version ); @Override - public ProjectVersionRef selectVersion( final String version ) - { - final SingleVersion single = VersionUtils.createSingleVersion( version ); - return selectVersion( single, false ); - } + ProjectVersionRef selectVersion( String version ); @Override - public ProjectVersionRef selectVersion( final String version, final boolean force ) - { - final SingleVersion single = VersionUtils.createSingleVersion( version ); - return selectVersion( single, force ); - } + ProjectVersionRef selectVersion( String version, boolean force ); @Override - public ProjectVersionRef selectVersion( final SingleVersion version ) - { - return selectVersion( version, false ); - } + ProjectVersionRef selectVersion( SingleVersion version ); @Override - public ProjectVersionRef selectVersion( final SingleVersion version, final boolean force ) - { - final VersionSpec versionSpec = getVersionSpec(); - if ( versionSpec.equals( version ) ) - { - return this; - } - - if ( !force && !versionSpec.contains( version ) ) - { - throw new IllegalArgumentException( "Specified version: " + version.renderStandard() - + " is not contained in spec: " + versionSpec.renderStandard() ); - } + ProjectVersionRef selectVersion( SingleVersion version, boolean force ); - return newRef( getGroupId(), getArtifactId(), version ); - } - - protected ProjectVersionRef newRef( final String groupId, final String artifactId, final SingleVersion version ) - { - return new ProjectVersionRef( groupId, artifactId, version ); - } + ProjectVersionRef newRef( String groupId, String artifactId, SingleVersion version ); @Override - public VersionSpec getVersionSpec() - { - if ( versionSpec == null ) - { - versionSpec = VersionUtils.createFromSpec( versionString ); - } - return versionSpec; - } + VersionSpec getVersionSpec(); - @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ( ( getVersionString() == null ) ? 0 : getVersionString().hashCode() ); - return result; - } - - public boolean versionlessEquals( final ProjectVersionRef other ) - { - if ( this == other ) - { - return true; - } - - return super.equals( other ); - } + boolean versionlessEquals( ProjectVersionRef other ); @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( !super.equals( obj ) ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final ProjectVersionRef other = (ProjectVersionRef) obj; - boolean result = true; - try - { - if ( getVersionSpec() == null ) - { - if ( other.getVersionSpec() != null ) - { - result = false; - } - } - else if ( !getVersionSpec().equals( other.getVersionSpec() ) ) - { - result = false; - } - } - catch ( final InvalidVersionSpecificationException e ) - { - if ( getVersionString() == null ) - { - if ( other.getVersionString() != null ) - { - result = false; - } - } - else if ( !getVersionString().equals( other.getVersionString() ) ) - { - result = false; - } - } - - return result; - } + boolean isCompound(); @Override - public String toString() - { - return String.format( "%s:%s:%s", getGroupId(), getArtifactId(), getVersionString() ); - } + boolean isSnapshot(); @Override - public boolean isCompound() - { - return !getVersionSpec().isSingle(); - } - - @Override - public boolean isSnapshot() - { - return getVersionSpec().isSnapshot(); - } - - @Override - public String getVersionString() - { - if ( versionString == null ) - { - versionString = versionSpec.renderStandard(); - } - - return versionString; - } - - public boolean isVariableVersion() - { - return isCompound() || ( isSpecificVersion() && ( (SingleVersion) getVersionSpec() ).isLocalSnapshot() ); - } - - @Override - public int compareTo( final ProjectRef o ) - { - int comp = super.compareTo( o ); - if ( comp == 0 && ( o instanceof ProjectVersionRef ) ) - { - final ProjectVersionRef or = (ProjectVersionRef) o; - comp = getVersionString().compareTo( or.getVersionString() ); - } - - return comp; - } + String getVersionString(); + boolean isVariableVersion(); } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRef.java new file mode 100644 index 00000000..85f94757 --- /dev/null +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRef.java @@ -0,0 +1,227 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.ident.ref; + +import static org.apache.commons.lang.StringUtils.isEmpty; + +import java.io.Serializable; + +import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; +import org.commonjava.maven.atlas.ident.version.SingleVersion; +import org.commonjava.maven.atlas.ident.version.VersionSpec; + +/** + * Represents an artifact, in Maven parlance. A tangible result of a build, which is typically made available in a Maven repository for others + * to consume. NOTE: a POM file is both a piece of metadata AND an artifact in the Maven world! + * + * Artifacts are based on the GAV coordinate for the project release, but also contain a type and optionally, a classifier. Type defaults to 'jar'. + * + * @see {@link SimpleProjectRef} + * @see {@link SimpleProjectVersionRef} + * + * @author jdcasey + */ +public class SimpleArtifactRef + extends SimpleProjectVersionRef + implements Serializable, ArtifactRef +{ + + private static final long serialVersionUID = 1L; + + private final TypeAndClassifier tc; + + private final boolean optional; + + public SimpleArtifactRef( final String groupId, final String artifactId, final VersionSpec version, + final String type, final String classifier, final boolean optional ) + { + super( groupId, artifactId, version ); + this.optional = optional; + this.tc = new SimpleTypeAndClassifier( type, classifier ); + } + + public SimpleArtifactRef( final ProjectVersionRef ref, final String type, final String classifier, + final boolean optional ) + { + super( ref.getGroupId(), ref.getArtifactId(), ref.getVersionSpecRaw(), ref.getVersionStringRaw() ); + this.optional = optional; + this.tc = new SimpleTypeAndClassifier( type, classifier ); + } + + public SimpleArtifactRef( final ProjectVersionRef ref, final TypeAndClassifier tc, final boolean optional ) + { + super( ref.getGroupId(), ref.getArtifactId(), ref.getVersionSpecRaw(), ref.getVersionStringRaw() ); + this.tc = tc; + this.optional = optional; + } + + public SimpleArtifactRef( final String groupId, final String artifactId, final String versionSpec, + final String type, final String classifier, final boolean optional ) + throws InvalidVersionSpecificationException + { + super( groupId, artifactId, versionSpec ); + this.tc = new SimpleTypeAndClassifier( type, classifier ); + this.optional = optional; + } + + @Override + public String toString() + { + return String.format( "%s:%s:%s:%s%s", getGroupId(), getArtifactId(), getType(), getVersionString(), + ( getClassifier() == null ? "" : ":" + getClassifier() ) ); + } + + public static SimpleArtifactRef parse( final String spec ) + { + final String[] parts = spec.split( ":" ); + + if ( parts.length < 3 || isEmpty( parts[0] ) || isEmpty( parts[1] ) || isEmpty( parts[2] ) ) + { + throw new InvalidRefException( + "SimpleArtifactRef must contain AT LEAST non-empty groupId, artifactId, AND version. (Given: '" + + spec + "')" ); + } + + final String g = parts[0]; + final String a = parts[1]; + + // assume we're actually parsing a GAV into a POM artifact... + String v = parts[2]; + String t = "pom"; + String c = null; + + if ( parts.length > 3 ) + { + // oops, it's a type, not a version...see toString() for the specification. + t = v; + v = parts[3]; + + if ( parts.length > 4 ) + { + c = parts[4]; + } + } + + // assume non-optional, because it might not matter if you're parsing a string like this...you'd be more careful if you were reading something + // that had an optional field, because it's not in the normal GATV[C] spec. + return new SimpleArtifactRef( g, a, v, t, c, false ); + } + + @Override + public SimpleArtifactRef newRef( final String groupId, final String artifactId, final SingleVersion version ) + { + return new SimpleArtifactRef( groupId, artifactId, version, tc.getType(), tc.getClassifier(), optional ); + } + + @Override + public String getType() + { + return tc.getType(); + } + + @Override + public String getClassifier() + { + return tc.getClassifier(); + } + + @Override + public TypeAndClassifier getTypeAndClassifier() + { + return tc; + } + + public SimpleArtifactRef setOptional( final boolean optional ) + { + if ( this.optional == optional ) + { + return this; + } + + return new SimpleArtifactRef( this, getType(), getClassifier(), optional ); + } + + @Override + public boolean isOptional() + { + return optional; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ( ( tc == null ) ? 0 : tc.hashCode() ); + result = prime * result + Boolean.valueOf( optional ) + .hashCode(); + return result; + } + + @Override + public boolean equals( final Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( !super.equals( obj ) ) + { + return false; + } + if ( !(obj instanceof ArtifactRef) ) + { + return false; + } + final ArtifactRef other = (ArtifactRef) obj; + + return artifactFieldsEqual( other ); + } + + private boolean artifactFieldsEqual( final ArtifactRef other ) + { + if ( tc == null ) + { + if ( other.getTypeAndClassifier() != null ) + { + return false; + } + } + else if ( !tc.equals( other.getTypeAndClassifier() ) ) + { + return false; + } + return true; + } + + @Override + public boolean versionlessEquals( final ProjectVersionRef other ) + { + if ( !super.versionlessEquals( other ) ) + { + return false; + } + + if ( !( other instanceof ArtifactRef ) ) + { + // compare vs. POM reference. + return artifactFieldsEqual( new SimpleArtifactRef( other, "pom", null, false ) ); + } + + return artifactFieldsEqual( (ArtifactRef) other ); + } + +} diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectRef.java new file mode 100644 index 00000000..d6301af8 --- /dev/null +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectRef.java @@ -0,0 +1,192 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.ident.ref; + +import static org.apache.commons.lang.StringUtils.isEmpty; + +/** + * Reference to a whole project (or module, in terms of Maven builds). This reference is not specific to a release of the project (see {@link SimpleProjectVersionRef}). + * + * @author jdcasey + */ +public class SimpleProjectRef + implements ProjectRef +{ + + private static final long serialVersionUID = 1L; + + // NEVER null + private final String groupId; + + // NEVER null + private final String artifactId; + + public SimpleProjectRef( final String groupId, final String artifactId ) + { + if ( isEmpty( groupId ) || isEmpty( artifactId ) ) + { + throw new InvalidRefException( "ProjectId must contain non-empty groupId AND artifactId. (Given: '" + + groupId + "':'" + artifactId + "')" ); + } + + this.groupId = groupId; + this.artifactId = artifactId; + } + + public static ProjectRef parse( final String ga ) + { + final String[] parts = ga.split( ":" ); + if ( parts.length < 2 || isEmpty( parts[0] ) || isEmpty( parts[1] ) ) + { + throw new InvalidRefException( "ProjectRef must contain non-empty groupId AND artifactId. (Given: '" + ga + + "')" ); + } + + return new SimpleProjectRef( parts[0], parts[1] ); + } + + @Override + public final String getGroupId() + { + return groupId; + } + + @Override + public final String getArtifactId() + { + return artifactId; + } + + @Override + public ProjectRef asProjectRef() + { + return SimpleProjectRef.class.equals( getClass() ) ? this : new SimpleProjectRef( getGroupId(), getArtifactId() ); + } + + @Override + public VersionlessArtifactRef asVersionlessPomArtifact() + { + return asVersionlessArtifactRef( "pom", null, false ); + } + + @Override + public VersionlessArtifactRef asVersionlessJarArtifact() + { + return asVersionlessArtifactRef( "jar", null, false ); + } + + @Override + public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier ) + { + return asVersionlessArtifactRef( type, classifier, false ); + } + + @Override + public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier, + final boolean optional ) + { + return new SimpleVersionlessArtifactRef( this, type, classifier, optional ); + } + + @Override + public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc ) + { + return asVersionlessArtifactRef( tc, false ); + } + + @Override + public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc, final boolean optional ) + { + return new SimpleVersionlessArtifactRef( this, tc, optional ); + } + + @Override + public String toString() + { + return String.format( "%s:%s", groupId, artifactId ); + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + artifactId.hashCode(); + result = prime * result + groupId.hashCode(); + return result; + } + + @Override + public boolean equals( final Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( obj == null ) + { + return false; + } + if ( !(obj instanceof ProjectRef) ) + { + return false; + } + final ProjectRef other = (ProjectRef) obj; + if ( !artifactId.equals( other.getArtifactId() ) ) + { + return false; + } + return groupId.equals( other.getGroupId() ); + } + + public int compareTo( final ProjectRef o ) + { + int comp = groupId.compareTo( o.getGroupId() ); + if ( comp == 0 ) + { + comp = artifactId.compareTo( o.getArtifactId() ); + } + + return comp; + } + + @Override + public boolean matches( final ProjectRef ref ) + { + if ( equals( ref ) ) + { + return true; + } + + final String gidPattern = toWildcard( getGroupId() ); + if ( !ref.getGroupId() + .matches( gidPattern ) ) + { + return false; + } + + final String aidPattern = toWildcard( getArtifactId() ); + return ref.getArtifactId().matches( aidPattern ); + + } + + private String toWildcard( final String val ) + { + return val.replaceAll( "\\.", "\\." ) + .replaceAll( "\\*", ".*" ); + } + +} diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java new file mode 100644 index 00000000..fea63991 --- /dev/null +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java @@ -0,0 +1,335 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.ident.ref; + +import org.commonjava.maven.atlas.ident.util.VersionUtils; +import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; +import org.commonjava.maven.atlas.ident.version.SingleVersion; +import org.commonjava.maven.atlas.ident.version.VersionSpec; + +import static org.apache.commons.lang.StringUtils.isEmpty; + +/** + * Reference to a particular release of a project (or module, in terms of Maven builds). A release may contain many artifacts (see {@link SimpleArtifactRef}). + * + * @see {@link SimpleProjectRef} + * @see {@link SimpleArtifactRef} + * + * @author jdcasey + */ +public class SimpleProjectVersionRef + extends SimpleProjectRef + implements ProjectVersionRef +{ + + private static final long serialVersionUID = 1L; + + // NEVER null + private VersionSpec versionSpec; + + private String versionString; + + public SimpleProjectVersionRef( final ProjectRef ref, final VersionSpec versionSpec ) + { + this( ref.getGroupId(), ref.getArtifactId(), versionSpec, null ); + } + + public SimpleProjectVersionRef( final ProjectRef ref, final String versionSpec ) + throws InvalidVersionSpecificationException + { + this( ref.getGroupId(), ref.getArtifactId(), versionSpec ); + } + + SimpleProjectVersionRef( final String groupId, final String artifactId, final VersionSpec versionSpec, + final String versionString ) + { + super( groupId, artifactId ); + if ( versionSpec == null && versionString == null ) + { + throw new InvalidRefException( "Version spec AND string cannot both be null for '" + groupId + ":" + + artifactId + "'" ); + } + + this.versionString = versionString; + this.versionSpec = versionSpec; + } + + public SimpleProjectVersionRef( final String groupId, final String artifactId, final VersionSpec versionSpec ) + { + this( groupId, artifactId, versionSpec, null ); + } + + public SimpleProjectVersionRef( final String groupId, final String artifactId, final String versionString ) + throws InvalidVersionSpecificationException + { + this( groupId, artifactId, null, versionString ); + } + + public static ProjectVersionRef parse( final String gav ) + { + final String[] parts = gav.split( ":" ); + if ( parts.length < 3 || isEmpty( parts[0] ) || isEmpty( parts[1] ) || isEmpty( parts[2] ) ) + { + throw new InvalidRefException( + "ProjectVersionRef must contain non-empty groupId, artifactId, AND version. (Given: '" + + gav + "')" ); + } + + return new SimpleProjectVersionRef( parts[0], parts[1], parts[2] ); + } + + @Override + public SimpleProjectVersionRef asProjectVersionRef() + { + return SimpleProjectVersionRef.class.equals( getClass() ) ? this : new SimpleProjectVersionRef( getGroupId(), + getArtifactId(), + getVersionSpecRaw(), + getVersionStringRaw() ); + } + + @Override + public ArtifactRef asPomArtifact() + { + return asArtifactRef( "pom", null, false ); + } + + @Override + public ArtifactRef asJarArtifact() + { + return asArtifactRef( "jar", null, false ); + } + + @Override + public ArtifactRef asArtifactRef( final String type, final String classifier ) + { + return asArtifactRef( type, classifier, false ); + } + + @Override + public ArtifactRef asArtifactRef( final String type, final String classifier, final boolean optional ) + { + return new SimpleArtifactRef( this, type, classifier, optional ); + } + + @Override + public ArtifactRef asArtifactRef( final TypeAndClassifier tc ) + { + return asArtifactRef( tc, false ); + } + + @Override + public ArtifactRef asArtifactRef( final TypeAndClassifier tc, final boolean optional ) + { + return new SimpleArtifactRef( this, tc, optional ); + } + + @Override + public VersionSpec getVersionSpecRaw() + { + return versionSpec; + } + + @Override + public String getVersionStringRaw() + { + return versionString; + } + + @Override + public boolean isRelease() + { + return getVersionSpec().isRelease(); + } + + @Override + public boolean isSpecificVersion() + { + return getVersionSpec().isSingle(); + } + + @Override + public boolean matchesVersion( final SingleVersion version ) + { + return getVersionSpec().contains( version ); + } + + @Override + public SimpleProjectVersionRef selectVersion( final String version ) + { + final SingleVersion single = VersionUtils.createSingleVersion( version ); + return selectVersion( single, false ); + } + + @Override + public SimpleProjectVersionRef selectVersion( final String version, final boolean force ) + { + final SingleVersion single = VersionUtils.createSingleVersion( version ); + return selectVersion( single, force ); + } + + @Override + public SimpleProjectVersionRef selectVersion( final SingleVersion version ) + { + return selectVersion( version, false ); + } + + @Override + public SimpleProjectVersionRef selectVersion( final SingleVersion version, final boolean force ) + { + final VersionSpec versionSpec = getVersionSpec(); + if ( versionSpec.equals( version ) ) + { + return this; + } + + if ( !force && !versionSpec.contains( version ) ) + { + throw new IllegalArgumentException( "Specified version: " + version.renderStandard() + + " is not contained in spec: " + versionSpec.renderStandard() ); + } + + return newRef( getGroupId(), getArtifactId(), version ); + } + + @Override + public SimpleProjectVersionRef newRef( final String groupId, final String artifactId, final SingleVersion version ) + { + return new SimpleProjectVersionRef( groupId, artifactId, version ); + } + + @Override + public VersionSpec getVersionSpec() + { + if ( versionSpec == null ) + { + versionSpec = VersionUtils.createFromSpec( versionString ); + } + return versionSpec; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ( ( getVersionString() == null ) ? 0 : getVersionString().hashCode() ); + return result; + } + + public boolean versionlessEquals( final ProjectVersionRef other ) + { + return this == other || super.equals( other ); + } + + @Override + public boolean equals( final Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( !super.equals( obj ) ) + { + return false; + } + if ( !(obj instanceof ProjectVersionRef) ) + { + return false; + } + + final ProjectVersionRef other = (ProjectVersionRef) obj; + boolean result = true; + try + { + if ( getVersionSpec() == null ) + { + if ( other.getVersionSpec() != null ) + { + result = false; + } + } + else if ( !getVersionSpec().equals( other.getVersionSpec() ) ) + { + result = false; + } + } + catch ( final InvalidVersionSpecificationException e ) + { + if ( getVersionString() == null ) + { + if ( other.getVersionString() != null ) + { + result = false; + } + } + else if ( !getVersionString().equals( other.getVersionString() ) ) + { + result = false; + } + } + + return result; + } + + @Override + public String toString() + { + return String.format( "%s:%s:%s", getGroupId(), getArtifactId(), getVersionString() ); + } + + @Override + public boolean isCompound() + { + return !getVersionSpec().isSingle(); + } + + @Override + public boolean isSnapshot() + { + return getVersionSpec().isSnapshot(); + } + + @Override + public String getVersionString() + { + if ( versionString == null ) + { + versionString = versionSpec.renderStandard(); + } + + return versionString; + } + + @Override + public boolean isVariableVersion() + { + return isCompound() || ( isSpecificVersion() && ( (SingleVersion) getVersionSpec() ).isLocalSnapshot() ); + } + + @Override + public int compareTo( final ProjectRef o ) + { + int comp = super.compareTo( o ); + if ( comp == 0 && ( o instanceof ProjectVersionRef ) ) + { + final ProjectVersionRef or = (ProjectVersionRef) o; + comp = getVersionString().compareTo( or.getVersionString() ); + } + + return comp; + } + +} diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleTypeAndClassifier.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleTypeAndClassifier.java new file mode 100644 index 00000000..41ee15b6 --- /dev/null +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleTypeAndClassifier.java @@ -0,0 +1,114 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.ident.ref; + +import static org.apache.commons.lang.StringUtils.isEmpty; + +public class SimpleTypeAndClassifier + implements TypeAndClassifier +{ + private static final long serialVersionUID = 1L; + + private final String type; + + private final String classifier; + + public SimpleTypeAndClassifier( final String type, final String classifier ) + { + this.type = type == null ? "jar" : type; + this.classifier = isEmpty( classifier ) ? null : classifier; + } + + public SimpleTypeAndClassifier( final String type ) + { + this( type, null ); + } + + public SimpleTypeAndClassifier() + { + this( null, null ); + } + + @Override + public String getType() + { + return type; + } + + @Override + public String getClassifier() + { + return classifier; + } + + @Override + public String toString() + { + return String.format( "%s%s", type, ( classifier == null ? "" : ":" + classifier ) ); + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ( ( classifier == null ) ? 0 : classifier.hashCode() ); + result = prime * result + ( ( type == null ) ? 0 : type.hashCode() ); + return result; + } + + @Override + public boolean equals( final Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( obj == null ) + { + return false; + } + if ( !(obj instanceof TypeAndClassifier) ) + { + return false; + } + final TypeAndClassifier other = (TypeAndClassifier) obj; + if ( classifier == null ) + { + if ( other.getClassifier() != null ) + { + return false; + } + } + else if ( !classifier.equals( other.getClassifier() ) ) + { + return false; + } + if ( type == null ) + { + if ( other.getType() != null ) + { + return false; + } + } + else if ( !type.equals( other.getType() ) ) + { + return false; + } + return true; + } + +} diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleVersionlessArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleVersionlessArtifactRef.java new file mode 100644 index 00000000..6022d9d6 --- /dev/null +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleVersionlessArtifactRef.java @@ -0,0 +1,232 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.ident.ref; + +import static org.apache.commons.lang.StringUtils.isEmpty; + +import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; + +/** + * Special implementation of {@link SimpleArtifactRef} that forces all versions to ZERO, to allow calculation of transitive + * dependency graphs, where version collisions of the same project are likely. + * + * @author jdcasey + */ +public class SimpleVersionlessArtifactRef + extends SimpleProjectRef + implements VersionlessArtifactRef +{ + + private static final long serialVersionUID = 1L; + + private final TypeAndClassifier tc; + + private final boolean optional; + + public SimpleVersionlessArtifactRef( final ArtifactRef ref ) + { + super( ref.getGroupId(), ref.getArtifactId() ); + this.optional = ref.isOptional(); + this.tc = ref.getTypeAndClassifier(); + } + + public SimpleVersionlessArtifactRef( final ProjectRef ref, final String type, final String classifier, + final boolean optional ) + { + super( ref.getGroupId(), ref.getArtifactId() ); + this.optional = optional; + this.tc = new SimpleTypeAndClassifier( type, classifier ); + } + + public SimpleVersionlessArtifactRef( final ProjectRef ref, final TypeAndClassifier tc, final boolean optional ) + { + super( ref.getGroupId(), ref.getArtifactId() ); + this.tc = tc == null ? new SimpleTypeAndClassifier() : tc; + this.optional = optional; + } + + public SimpleVersionlessArtifactRef( final String groupId, final String artifactId, final String type, + final String classifier, final boolean optional ) + throws InvalidVersionSpecificationException + { + super( groupId, artifactId ); + this.tc = new SimpleTypeAndClassifier( type, classifier ); + this.optional = optional; + } + + @Override + public String toString() + { + return String.format( "%s:%s:%s", getGroupId(), getArtifactId(), getTypeAndClassifier() ); + } + + public static VersionlessArtifactRef parse( final String spec ) + { + final String[] parts = spec.split( ":" ); + + if ( parts.length < 2 || isEmpty( parts[0] ) || isEmpty( parts[1] ) ) + { + throw new InvalidRefException( + "VersionlessArtifactRef must contain AT LEAST non-empty groupId and artifactId. (Given: '" + + spec + "')" ); + } + + final String g = parts[0]; + final String a = parts[1]; + + String t = "pom"; + String c = null; + + if ( parts.length > 2 ) + { + // we probably have a type in there. + t = parts[2]; + + if ( parts.length > 3 ) + { + // we have a classifier? What if it's GATV?? + // assume it's just a classifier... + c = parts[3]; + + if ( parts.length > 4 ) + { + // okay, wtf? It's a GATVC, and we need to shift to eliminate the V... + c = parts[4]; + } + } + } + + // assume non-optional, because it might not matter if you're parsing a string like this...you'd be more careful if you were reading something + // that had an optional field, because it's not in the normal GATV[C] spec. + return new SimpleVersionlessArtifactRef( g, a, t, c, false ); + } + + @Override + public String getType() + { + return tc.getType(); + } + + @Override + public String getClassifier() + { + return tc.getClassifier(); + } + + @Override + public TypeAndClassifier getTypeAndClassifier() + { + return tc; + } + + @Override + public boolean isOptional() + { + return optional; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ( optional ? 1231 : 1237 ); + result = prime * result + ( ( tc == null ) ? 0 : tc.hashCode() ); + return result; + } + + @Override + public boolean equals( final Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( !super.equals( obj ) ) + { + return false; + } + if ( !(obj instanceof VersionlessArtifactRef) ) + { + return false; + } + final VersionlessArtifactRef other = (VersionlessArtifactRef) obj; + if ( optional != other.isOptional() ) + { + return false; + } + if ( tc == null ) + { + if ( other.getTypeAndClassifier() != null ) + { + return false; + } + } + else if ( !tc.equals( other.getTypeAndClassifier() ) ) + { + return false; + } + return true; + } + + @Override + public VersionlessArtifactRef asVersionlessPomArtifact() + { + return asVersionlessArtifactRef( "pom", null, false ); + } + + @Override + public VersionlessArtifactRef asVersionlessJarArtifact() + { + return asVersionlessArtifactRef( "jar", null, false ); + } + + @Override + public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier ) + { + return asVersionlessArtifactRef( type, classifier, false ); + } + + @Override + public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier, + final boolean optional ) + { + final TypeAndClassifier tc = new SimpleTypeAndClassifier( type, classifier ); + if ( SimpleVersionlessArtifactRef.class.equals( getClass() ) && this.tc.equals( tc ) && this.optional == optional ) + { + return this; + } + + return super.asVersionlessArtifactRef( type, classifier, optional ); + } + + @Override + public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc ) + { + return asVersionlessArtifactRef( tc, false ); + } + + @Override + public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc, final boolean optional ) + { + if ( SimpleVersionlessArtifactRef.class.equals( getClass() ) && this.tc.equals( tc ) && this.optional == optional ) + { + return this; + } + + return super.asVersionlessArtifactRef( tc, optional ); + } +} diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/TypeAndClassifier.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/TypeAndClassifier.java index 8957a994..9c5a1146 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/TypeAndClassifier.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/TypeAndClassifier.java @@ -1,114 +1,14 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.commonjava.maven.atlas.ident.ref; -import static org.apache.commons.lang.StringUtils.isEmpty; - import java.io.Serializable; -public class TypeAndClassifier - implements Serializable +/** + * Created by jdcasey on 8/21/15. + */ +public interface TypeAndClassifier + extends Serializable { - private static final long serialVersionUID = 1L; - - private final String type; - - private final String classifier; - - public TypeAndClassifier( final String type, final String classifier ) - { - this.type = type == null ? "jar" : type; - this.classifier = isEmpty( classifier ) ? null : classifier; - } - - public TypeAndClassifier( final String type ) - { - this( type, null ); - } - - public TypeAndClassifier() - { - this( null, null ); - } - - public String getType() - { - return type; - } - - public String getClassifier() - { - return classifier; - } - - @Override - public String toString() - { - return String.format( "%s%s", type, ( classifier == null ? "" : ":" + classifier ) ); - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ( ( classifier == null ) ? 0 : classifier.hashCode() ); - result = prime * result + ( ( type == null ) ? 0 : type.hashCode() ); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( obj == null ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final TypeAndClassifier other = (TypeAndClassifier) obj; - if ( classifier == null ) - { - if ( other.classifier != null ) - { - return false; - } - } - else if ( !classifier.equals( other.classifier ) ) - { - return false; - } - if ( type == null ) - { - if ( other.type != null ) - { - return false; - } - } - else if ( !type.equals( other.type ) ) - { - return false; - } - return true; - } + String getType(); + String getClassifier(); } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java index 5f8237b3..ba437192 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java @@ -1,227 +1,34 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.commonjava.maven.atlas.ident.ref; -import static org.apache.commons.lang.StringUtils.isEmpty; - -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; - /** - * Special implementation of {@link ArtifactRef} that forces all versions to ZERO, to allow calculation of transitive - * dependency graphs, where version collisions of the same project are likely. - * - * @author jdcasey + * Created by jdcasey on 8/21/15. */ -public class VersionlessArtifactRef - extends ProjectRef +public interface VersionlessArtifactRef + extends ProjectRef { + String getType(); - private static final long serialVersionUID = 1L; - - private final TypeAndClassifier tc; - - private final boolean optional; - - public VersionlessArtifactRef( final ArtifactRef ref ) - { - super( ref.getGroupId(), ref.getArtifactId() ); - this.optional = ref.isOptional(); - this.tc = ref.getTypeAndClassifier(); - } - - public VersionlessArtifactRef( final ProjectRef ref, final String type, final String classifier, - final boolean optional ) - { - super( ref.getGroupId(), ref.getArtifactId() ); - this.optional = optional; - this.tc = new TypeAndClassifier( type, classifier ); - } - - public VersionlessArtifactRef( final ProjectRef ref, final TypeAndClassifier tc, final boolean optional ) - { - super( ref.getGroupId(), ref.getArtifactId() ); - this.tc = tc == null ? new TypeAndClassifier() : tc; - this.optional = optional; - } - - public VersionlessArtifactRef( final String groupId, final String artifactId, final String type, - final String classifier, final boolean optional ) - throws InvalidVersionSpecificationException - { - super( groupId, artifactId ); - this.tc = new TypeAndClassifier( type, classifier ); - this.optional = optional; - } - - @Override - public String toString() - { - return String.format( "%s:%s:%s", getGroupId(), getArtifactId(), getTypeAndClassifier() ); - } - - public static VersionlessArtifactRef parse( final String spec ) - { - final String[] parts = spec.split( ":" ); - - if ( parts.length < 2 || isEmpty( parts[0] ) || isEmpty( parts[1] ) ) - { - throw new InvalidRefException( - "VersionlessArtifactRef must contain AT LEAST non-empty groupId and artifactId. (Given: '" - + spec + "')" ); - } + String getClassifier(); - final String g = parts[0]; - final String a = parts[1]; + TypeAndClassifier getTypeAndClassifier(); - String t = "pom"; - String c = null; - - if ( parts.length > 2 ) - { - // we probably have a type in there. - t = parts[2]; - - if ( parts.length > 3 ) - { - // we have a classifier? What if it's GATV?? - // assume it's just a classifier... - c = parts[3]; - - if ( parts.length > 4 ) - { - // okay, wtf? It's a GATVC, and we need to shift to eliminate the V... - c = parts[4]; - } - } - } - - // assume non-optional, because it might not matter if you're parsing a string like this...you'd be more careful if you were reading something - // that had an optional field, because it's not in the normal GATV[C] spec. - return new VersionlessArtifactRef( g, a, t, c, false ); - } - - public String getType() - { - return tc.getType(); - } - - public String getClassifier() - { - return tc.getClassifier(); - } - - public TypeAndClassifier getTypeAndClassifier() - { - return tc; - } - - public boolean isOptional() - { - return optional; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ( optional ? 1231 : 1237 ); - result = prime * result + ( ( tc == null ) ? 0 : tc.hashCode() ); - return result; - } + boolean isOptional(); @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( !super.equals( obj ) ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final VersionlessArtifactRef other = (VersionlessArtifactRef) obj; - if ( optional != other.optional ) - { - return false; - } - if ( tc == null ) - { - if ( other.tc != null ) - { - return false; - } - } - else if ( !tc.equals( other.tc ) ) - { - return false; - } - return true; - } + VersionlessArtifactRef asVersionlessPomArtifact(); @Override - public VersionlessArtifactRef asVersionlessPomArtifact() - { - return asVersionlessArtifactRef( "pom", null, false ); - } + VersionlessArtifactRef asVersionlessJarArtifact(); @Override - public VersionlessArtifactRef asVersionlessJarArtifact() - { - return asVersionlessArtifactRef( "jar", null, false ); - } + VersionlessArtifactRef asVersionlessArtifactRef( String type, String classifier ); @Override - public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier ) - { - return asVersionlessArtifactRef( type, classifier, false ); - } + VersionlessArtifactRef asVersionlessArtifactRef( String type, String classifier, boolean optional ); @Override - public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier, - final boolean optional ) - { - final TypeAndClassifier tc = new TypeAndClassifier( type, classifier ); - if ( VersionlessArtifactRef.class.equals( getClass() ) && this.tc.equals( tc ) && this.optional == optional ) - { - return this; - } - - return super.asVersionlessArtifactRef( type, classifier, optional ); - } + VersionlessArtifactRef asVersionlessArtifactRef( TypeAndClassifier tc ); @Override - public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc ) - { - return asVersionlessArtifactRef( tc, false ); - } - - @Override - public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc, final boolean optional ) - { - if ( VersionlessArtifactRef.class.equals( getClass() ) && this.tc.equals( tc ) && this.optional == optional ) - { - return this; - } - - return super.asVersionlessArtifactRef( tc, optional ); - } + VersionlessArtifactRef asVersionlessArtifactRef( TypeAndClassifier tc, boolean optional ); } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java index 5d3b4a77..47b29948 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java @@ -15,12 +15,13 @@ */ package org.commonjava.maven.atlas.ident.util; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.commonjava.maven.atlas.ident.version.part.SnapshotPart; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + public class ArtifactPathInfo { @@ -253,7 +254,7 @@ else if ( !version.equals( other.version ) ) public ProjectVersionRef getProjectId() { - return new ProjectVersionRef( getGroupId(), getArtifactId(), getVersion() ); + return new SimpleProjectVersionRef( getGroupId(), getArtifactId(), getVersion() ); } } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactRefComparator.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactRefComparator.java index 84f2935d..1b814046 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactRefComparator.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactRefComparator.java @@ -18,6 +18,7 @@ import java.util.Comparator; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; public class ArtifactRefComparator implements Comparator diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/IdentityUtils.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/IdentityUtils.java index deec501d..14b4e9e7 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/IdentityUtils.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/IdentityUtils.java @@ -15,9 +15,7 @@ */ package org.commonjava.maven.atlas.ident.util; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.*; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; public final class IdentityUtils @@ -30,26 +28,26 @@ private IdentityUtils() public static ArtifactRef artifact( final String groupId, final String artifactId, final String version ) throws InvalidVersionSpecificationException { - return new ArtifactRef( projectVersion( groupId, artifactId, version ), null, null, false ); + return new SimpleArtifactRef( projectVersion( groupId, artifactId, version ), null, null, false ); } public static ArtifactRef artifact( final ProjectVersionRef ref ) throws InvalidVersionSpecificationException { - return new ArtifactRef( ref, null, null, false ); + return new SimpleArtifactRef( ref, null, null, false ); } public static ArtifactRef artifact( final String groupId, final String artifactId, final String version, final String type, final String classifier, final boolean optional ) throws InvalidVersionSpecificationException { - return new ArtifactRef( projectVersion( groupId, artifactId, version ), type, classifier, optional ); + return new SimpleArtifactRef( projectVersion( groupId, artifactId, version ), type, classifier, optional ); } public static ArtifactRef artifact( final ProjectVersionRef dep, final String type, final String classifier, final boolean optional ) { - return new ArtifactRef( dep, type, classifier, optional ); + return new SimpleArtifactRef( dep, type, classifier, optional ); } public static ProjectVersionRef projectVersion( final String src ) @@ -63,7 +61,7 @@ public static ProjectVersionRef projectVersion( final String src ) try { - return new ProjectVersionRef( parts[0], parts[1], parts[2] ); + return new SimpleProjectVersionRef( parts[0], parts[1], parts[2] ); } catch ( final InvalidVersionSpecificationException e ) { @@ -75,7 +73,7 @@ public static ProjectVersionRef projectVersion( final String src ) public static ProjectVersionRef projectVersion( final String groupId, final String artifactId, final String version ) throws InvalidVersionSpecificationException { - return new ProjectVersionRef( groupId, artifactId, version ); + return new SimpleProjectVersionRef( groupId, artifactId, version ); } public static ProjectRef project( final String src ) @@ -87,13 +85,13 @@ public static ProjectRef project( final String src ) + "'. Must contain at least two fields separated by ':'" ); } - return new ProjectRef( parts[0], parts[1] ); + return new SimpleProjectRef( parts[0], parts[1] ); } public static ProjectRef project( final String groupId, final String artifactId ) throws InvalidVersionSpecificationException { - return new ProjectRef( groupId, artifactId ); + return new SimpleProjectRef( groupId, artifactId ); } } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ProjectVersionRefComparator.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ProjectVersionRefComparator.java index 9cb26103..fe969931 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ProjectVersionRefComparator.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ProjectVersionRefComparator.java @@ -18,6 +18,7 @@ import java.util.Comparator; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.commonjava.maven.atlas.ident.version.VersionSpec; public class ProjectVersionRefComparator diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionlessArtifactRefComparator.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionlessArtifactRefComparator.java index 52bfd3e4..dfbe1df4 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionlessArtifactRefComparator.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionlessArtifactRefComparator.java @@ -15,10 +15,10 @@ */ package org.commonjava.maven.atlas.ident.util; -import java.util.Comparator; - import org.commonjava.maven.atlas.ident.ref.VersionlessArtifactRef; +import java.util.Comparator; + public class VersionlessArtifactRefComparator implements Comparator { diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ProjectRefTest.java b/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ProjectRefTest.java index eecb5aa6..2f5ac3c6 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ProjectRefTest.java +++ b/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ProjectRefTest.java @@ -26,8 +26,8 @@ public class ProjectRefTest @Test public void matchesTotalWildcardGroupId() { - final ProjectRef pattern = new ProjectRef( "*", "foo" ); - final ProjectRef test = new ProjectRef( "org.bar", "foo" ); + final ProjectRef pattern = new SimpleProjectRef( "*", "foo" ); + final ProjectRef test = new SimpleProjectRef( "org.bar", "foo" ); assertThat( pattern.matches( test ), equalTo( true ) ); } @@ -35,8 +35,8 @@ public void matchesTotalWildcardGroupId() @Test public void matchesTotalWildcardArtifactId() { - final ProjectRef pattern = new ProjectRef( "org.bar", "*" ); - final ProjectRef test = new ProjectRef( "org.bar", "foo" ); + final ProjectRef pattern = new SimpleProjectRef( "org.bar", "*" ); + final ProjectRef test = new SimpleProjectRef( "org.bar", "foo" ); assertThat( pattern.matches( test ), equalTo( true ) ); } @@ -44,8 +44,8 @@ public void matchesTotalWildcardArtifactId() @Test public void matchesTerminatingWildcardGroupId() { - final ProjectRef pattern = new ProjectRef( "org.*", "foo" ); - final ProjectRef test = new ProjectRef( "org.bar", "foo" ); + final ProjectRef pattern = new SimpleProjectRef( "org.*", "foo" ); + final ProjectRef test = new SimpleProjectRef( "org.bar", "foo" ); assertThat( pattern.matches( test ), equalTo( true ) ); } @@ -53,8 +53,8 @@ public void matchesTerminatingWildcardGroupId() @Test public void matchesTerminatingWildcardArtifactId() { - final ProjectRef pattern = new ProjectRef( "org.bar", "fo*" ); - final ProjectRef test = new ProjectRef( "org.bar", "foo" ); + final ProjectRef pattern = new SimpleProjectRef( "org.bar", "fo*" ); + final ProjectRef test = new SimpleProjectRef( "org.bar", "foo" ); assertThat( pattern.matches( test ), equalTo( true ) ); } @@ -62,8 +62,8 @@ public void matchesTerminatingWildcardArtifactId() @Test public void matchesEmbeddedWildcardGroupId() { - final ProjectRef pattern = new ProjectRef( "org.*r", "foo" ); - final ProjectRef test = new ProjectRef( "org.bar", "foo" ); + final ProjectRef pattern = new SimpleProjectRef( "org.*r", "foo" ); + final ProjectRef test = new SimpleProjectRef( "org.bar", "foo" ); assertThat( pattern.matches( test ), equalTo( true ) ); } @@ -71,8 +71,8 @@ public void matchesEmbeddedWildcardGroupId() @Test public void matchesEmbeddedWildcardArtifactId() { - final ProjectRef pattern = new ProjectRef( "org.bar", "f*o" ); - final ProjectRef test = new ProjectRef( "org.bar", "foo" ); + final ProjectRef pattern = new SimpleProjectRef( "org.bar", "f*o" ); + final ProjectRef test = new SimpleProjectRef( "org.bar", "foo" ); assertThat( pattern.matches( test ), equalTo( true ) ); } diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRefTest.java b/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRefTest.java index 7bf30ceb..aa99d9e0 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRefTest.java +++ b/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRefTest.java @@ -21,7 +21,6 @@ import java.util.HashSet; import java.util.Set; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; import org.commonjava.maven.atlas.ident.version.VersionSpec; import org.junit.Test; @@ -34,7 +33,7 @@ public void constructWithStringVersionAndRenderStandardSpecMatches() throws InvalidVersionSpecificationException { final String ver = "2.1.1.Final"; - final ProjectVersionRef ref = new ProjectVersionRef( "g", "a", ver ); + final ProjectVersionRef ref = new SimpleProjectVersionRef( "g", "a", ver ); final VersionSpec spec = ref.getVersionSpec(); assertThat( spec.renderStandard(), equalTo( ver ) ); @@ -44,8 +43,8 @@ public void constructWithStringVersionAndRenderStandardSpecMatches() public void hashCodeEquality() throws InvalidVersionSpecificationException { - final ProjectVersionRef ref1 = new ProjectVersionRef( "org.foo", "bar", "1.1.1-baz-1" ); - final ProjectVersionRef ref2 = new ProjectVersionRef( "org.foo", "bar", "1.1.1-baz-1" ); + final ProjectVersionRef ref1 = new SimpleProjectVersionRef( "org.foo", "bar", "1.1.1-baz-1" ); + final ProjectVersionRef ref2 = new SimpleProjectVersionRef( "org.foo", "bar", "1.1.1-baz-1" ); assertThat( ref1.hashCode(), equalTo( ref2.hashCode() ) ); } @@ -54,8 +53,8 @@ public void hashCodeEquality() public void objectEquality() throws InvalidVersionSpecificationException { - final ProjectVersionRef ref1 = new ProjectVersionRef( "org.foo", "bar", "1.1.1-baz-1" ); - final ProjectVersionRef ref2 = new ProjectVersionRef( "org.foo", "bar", "1.1.1-baz-1" ); + final ProjectVersionRef ref1 = new SimpleProjectVersionRef( "org.foo", "bar", "1.1.1-baz-1" ); + final ProjectVersionRef ref2 = new SimpleProjectVersionRef( "org.foo", "bar", "1.1.1-baz-1" ); assertThat( ref1, equalTo( ref2 ) ); } @@ -64,8 +63,8 @@ public void objectEquality() public void addTwoIdenticalRefsToASetAndVerifyThatOnlyOneIsAdded() throws InvalidVersionSpecificationException { - final ProjectVersionRef ref1 = new ProjectVersionRef( "org.foo", "bar", "1.1.1-baz-1" ); - final ProjectVersionRef ref2 = new ProjectVersionRef( "org.foo", "bar", "1.1.1-baz-1" ); + final ProjectVersionRef ref1 = new SimpleProjectVersionRef( "org.foo", "bar", "1.1.1-baz-1" ); + final ProjectVersionRef ref2 = new SimpleProjectVersionRef( "org.foo", "bar", "1.1.1-baz-1" ); assertThat( ref1, equalTo( ref2 ) ); @@ -78,8 +77,8 @@ public void addTwoIdenticalRefsToASetAndVerifyThatOnlyOneIsAdded() public void addTwoIdenticalCompoundRefsToASetAndVerifyThatOnlyOneIsAdded() throws InvalidVersionSpecificationException { - final ProjectVersionRef ref1 = new ProjectVersionRef( "org.foo", "bar", "[1.1.1-baz-1,1.1.1-baz-2]" ); - final ProjectVersionRef ref2 = new ProjectVersionRef( "org.foo", "bar", "[1.1.1-baz-1,1.1.1-baz-2]" ); + final ProjectVersionRef ref1 = new SimpleProjectVersionRef( "org.foo", "bar", "[1.1.1-baz-1,1.1.1-baz-2]" ); + final ProjectVersionRef ref2 = new SimpleProjectVersionRef( "org.foo", "bar", "[1.1.1-baz-1,1.1.1-baz-2]" ); assertThat( ref1, equalTo( ref2 ) ); diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ArtifactRefTest.java b/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRefTest.java similarity index 85% rename from identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ArtifactRefTest.java rename to identities/src/test/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRefTest.java index 7f2f3019..a1b9bd5e 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ArtifactRefTest.java +++ b/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRefTest.java @@ -21,13 +21,13 @@ import org.junit.Test; -public class ArtifactRefTest +public class SimpleArtifactRefTest { @Test( expected = InvalidRefException.class ) public void failParsingGA() { - ArtifactRef.parse( "org.foo:bar" ); + SimpleArtifactRef.parse( "org.foo:bar" ); } @Test @@ -37,7 +37,7 @@ public void parseGAVIntoPOM() final String a = "bar"; final String v = "1.0"; - final ArtifactRef ar = ArtifactRef.parse( String.format( "%s:%s:%s", g, a, v ) ); + final ArtifactRef ar = SimpleArtifactRef.parse( String.format( "%s:%s:%s", g, a, v ) ); assertThat( ar.getGroupId(), equalTo( g ) ); assertThat( ar.getArtifactId(), equalTo( a ) ); @@ -54,7 +54,7 @@ public void parseGATV() final String v = "1.0"; final String t = "zip"; - final ArtifactRef ar = ArtifactRef.parse( String.format( "%s:%s:%s:%s", g, a, t, v ) ); + final ArtifactRef ar = SimpleArtifactRef.parse( String.format( "%s:%s:%s:%s", g, a, t, v ) ); assertThat( ar.getGroupId(), equalTo( g ) ); assertThat( ar.getArtifactId(), equalTo( a ) ); @@ -72,7 +72,7 @@ public void parseGATVC() final String t = "zip"; final String c = "sources"; - final ArtifactRef ar = ArtifactRef.parse( String.format( "%s:%s:%s:%s:%s", g, a, t, v, c ) ); + final ArtifactRef ar = SimpleArtifactRef.parse( String.format( "%s:%s:%s:%s:%s", g, a, t, v, c ) ); assertThat( ar.getGroupId(), equalTo( g ) ); assertThat( ar.getArtifactId(), equalTo( a ) ); diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRefTest.java b/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRefTest.java index 06aeaadf..b00a3e47 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRefTest.java +++ b/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRefTest.java @@ -29,7 +29,7 @@ public void parseGA() { final String g = "org.foo"; final String a = "bar"; - final VersionlessArtifactRef var = VersionlessArtifactRef.parse( String.format( "%s:%s", g, a ) ); + final VersionlessArtifactRef var = SimpleVersionlessArtifactRef.parse( String.format( "%s:%s", g, a ) ); assertThat( var.getGroupId(), equalTo( g ) ); assertThat( var.getArtifactId(), equalTo( a ) ); @@ -44,7 +44,7 @@ public void parseGAT() final String a = "bar"; final String t = "zip"; - final VersionlessArtifactRef var = VersionlessArtifactRef.parse( String.format( "%s:%s:%s", g, a, t ) ); + final VersionlessArtifactRef var = SimpleVersionlessArtifactRef.parse( String.format( "%s:%s:%s", g, a, t ) ); assertThat( var.getGroupId(), equalTo( g ) ); assertThat( var.getArtifactId(), equalTo( a ) ); @@ -60,7 +60,8 @@ public void parseGATC() final String t = "zip"; final String c = "sources"; - final VersionlessArtifactRef var = VersionlessArtifactRef.parse( String.format( "%s:%s:%s:%s", g, a, t, c ) ); + final VersionlessArtifactRef var = SimpleVersionlessArtifactRef.parse( + String.format( "%s:%s:%s:%s", g, a, t, c ) ); assertThat( var.getGroupId(), equalTo( g ) ); assertThat( var.getArtifactId(), equalTo( a ) ); @@ -78,7 +79,7 @@ public void parseGATVC_VersionDiscarded() final String c = "sources"; final VersionlessArtifactRef var = - VersionlessArtifactRef.parse( String.format( "%s:%s:%s:%s:%s", g, a, t, v, c ) ); + SimpleVersionlessArtifactRef.parse( String.format( "%s:%s:%s:%s:%s", g, a, t, v, c ) ); assertThat( var.getGroupId(), equalTo( g ) ); assertThat( var.getArtifactId(), equalTo( a ) ); @@ -94,7 +95,8 @@ public void parseGATV_MistakeForGATC() final String t = "zip"; final String v = "1.0"; - final VersionlessArtifactRef var = VersionlessArtifactRef.parse( String.format( "%s:%s:%s:%s", g, a, t, v ) ); + final VersionlessArtifactRef var = SimpleVersionlessArtifactRef.parse( + String.format( "%s:%s:%s:%s", g, a, t, v ) ); assertThat( var.getGroupId(), equalTo( g ) ); assertThat( var.getArtifactId(), equalTo( a ) ); @@ -107,7 +109,7 @@ public void parseGATVC() { final String g = "org.foo"; final String a = "bar"; - final VersionlessArtifactRef var = VersionlessArtifactRef.parse( String.format( "%s:%s", g, a ) ); + final VersionlessArtifactRef var = SimpleVersionlessArtifactRef.parse( String.format( "%s:%s", g, a ) ); assertThat( var.getGroupId(), equalTo( g ) ); assertThat( var.getArtifactId(), equalTo( a ) ); @@ -124,8 +126,8 @@ public void identicalVersionlessArtifactsAreNotEqualWhenOptionalFlagsDiffer() final String v = "1"; final String t = "jar"; - final VersionlessArtifactRef r1 = new VersionlessArtifactRef( new ArtifactRef( g, a, v, t, null, false ) ); - final VersionlessArtifactRef r2 = new VersionlessArtifactRef( new ArtifactRef( g, a, v, t, null, true ) ); + final VersionlessArtifactRef r1 = new SimpleVersionlessArtifactRef( new SimpleArtifactRef( g, a, v, t, null, false ) ); + final VersionlessArtifactRef r2 = new SimpleVersionlessArtifactRef( new SimpleArtifactRef( g, a, v, t, null, true ) ); assertThat( r1.equals( r2 ), equalTo( false ) ); assertThat( r1.hashCode() == r2.hashCode(), equalTo( false ) ); @@ -134,12 +136,12 @@ public void identicalVersionlessArtifactsAreNotEqualWhenOptionalFlagsDiffer() @Test public void twoIdenticalArtifactsWrappedInVersionlessInstanceAreEqual_DefaultTypeAndClassifier() { - final ProjectVersionRef pvr = new ProjectVersionRef( "group", "artifact", "1" ); - final ArtifactRef r1 = new ArtifactRef( pvr, null, null, false ); - final ArtifactRef r2 = new ArtifactRef( pvr, null, null, false ); + final ProjectVersionRef pvr = new SimpleProjectVersionRef( "group", "artifact", "1" ); + final ArtifactRef r1 = new SimpleArtifactRef( pvr, null, null, false ); + final ArtifactRef r2 = new SimpleArtifactRef( pvr, null, null, false ); - final VersionlessArtifactRef vr1 = new VersionlessArtifactRef( r1 ); - final VersionlessArtifactRef vr2 = new VersionlessArtifactRef( r2 ); + final VersionlessArtifactRef vr1 = new SimpleVersionlessArtifactRef( r1 ); + final VersionlessArtifactRef vr2 = new SimpleVersionlessArtifactRef( r2 ); assertThat( vr1, equalTo( vr2 ) ); assertThat( vr1.hashCode(), equalTo( vr2.hashCode() ) ); @@ -148,12 +150,12 @@ public void twoIdenticalArtifactsWrappedInVersionlessInstanceAreEqual_DefaultTyp @Test public void twoArtifactsWrappedInVersionlessInstanceAreNotEqualWhenTypeDiffers() { - final ProjectVersionRef pvr = new ProjectVersionRef( "group", "artifact", "1" ); - final ArtifactRef r1 = new ArtifactRef( pvr, "jar", null, false ); - final ArtifactRef r2 = new ArtifactRef( pvr, "pom", null, false ); + final ProjectVersionRef pvr = new SimpleProjectVersionRef( "group", "artifact", "1" ); + final ArtifactRef r1 = new SimpleArtifactRef( pvr, "jar", null, false ); + final ArtifactRef r2 = new SimpleArtifactRef( pvr, "pom", null, false ); - final VersionlessArtifactRef vr1 = new VersionlessArtifactRef( r1 ); - final VersionlessArtifactRef vr2 = new VersionlessArtifactRef( r2 ); + final VersionlessArtifactRef vr1 = new SimpleVersionlessArtifactRef( r1 ); + final VersionlessArtifactRef vr2 = new SimpleVersionlessArtifactRef( r2 ); assertThat( vr1.equals( vr2 ), equalTo( false ) ); assertThat( vr1.hashCode() == vr2.hashCode(), equalTo( false ) ); @@ -162,12 +164,12 @@ public void twoArtifactsWrappedInVersionlessInstanceAreNotEqualWhenTypeDiffers() @Test public void twoArtifactsWrappedInVersionlessInstanceAreNotEqualWhenClassifierDiffers() { - final ProjectVersionRef pvr = new ProjectVersionRef( "group", "artifact", "1" ); - final ArtifactRef r1 = new ArtifactRef( pvr, "jar", null, false ); - final ArtifactRef r2 = new ArtifactRef( pvr, "jar", "foo", false ); + final ProjectVersionRef pvr = new SimpleProjectVersionRef( "group", "artifact", "1" ); + final ArtifactRef r1 = new SimpleArtifactRef( pvr, "jar", null, false ); + final ArtifactRef r2 = new SimpleArtifactRef( pvr, "jar", "foo", false ); - final VersionlessArtifactRef vr1 = new VersionlessArtifactRef( r1 ); - final VersionlessArtifactRef vr2 = new VersionlessArtifactRef( r2 ); + final VersionlessArtifactRef vr1 = new SimpleVersionlessArtifactRef( r1 ); + final VersionlessArtifactRef vr2 = new SimpleVersionlessArtifactRef( r2 ); assertThat( vr1.equals( vr2 ), equalTo( false ) ); assertThat( vr1.hashCode() == vr2.hashCode(), equalTo( false ) ); @@ -176,13 +178,13 @@ public void twoArtifactsWrappedInVersionlessInstanceAreNotEqualWhenClassifierDif @Test public void twoArtifactsWrappedInVersionlessInstanceAreEqualWhenVersionDiffers() { - final ProjectVersionRef pvr1 = new ProjectVersionRef( "group", "artifact", "1" ); - final ProjectVersionRef pvr2 = new ProjectVersionRef( "group", "artifact", "2" ); - final ArtifactRef r1 = new ArtifactRef( pvr1, null, null, false ); - final ArtifactRef r2 = new ArtifactRef( pvr2, null, null, false ); + final ProjectVersionRef pvr1 = new SimpleProjectVersionRef( "group", "artifact", "1" ); + final ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "group", "artifact", "2" ); + final ArtifactRef r1 = new SimpleArtifactRef( pvr1, null, null, false ); + final ArtifactRef r2 = new SimpleArtifactRef( pvr2, null, null, false ); - final VersionlessArtifactRef vr1 = new VersionlessArtifactRef( r1 ); - final VersionlessArtifactRef vr2 = new VersionlessArtifactRef( r2 ); + final VersionlessArtifactRef vr1 = new SimpleVersionlessArtifactRef( r1 ); + final VersionlessArtifactRef vr2 = new SimpleVersionlessArtifactRef( r2 ); assertThat( vr1, equalTo( vr2 ) ); assertThat( vr1.hashCode(), equalTo( vr2.hashCode() ) ); @@ -191,17 +193,17 @@ public void twoArtifactsWrappedInVersionlessInstanceAreEqualWhenVersionDiffers() @Test public void twoArtifactsWrappedInVersionlessInstanceAreEqualWhenVersionDiffersWithRange() { - final ProjectVersionRef pvr1 = new ProjectVersionRef( "group", "artifact", "1" ); - final ProjectVersionRef pvr2 = new ProjectVersionRef( "group", "artifact", "[2,3.1]" ); - final ArtifactRef r1 = new ArtifactRef( pvr1, null, null, false ); - final ArtifactRef r2 = new ArtifactRef( pvr2, null, null, false ); + final ProjectVersionRef pvr1 = new SimpleProjectVersionRef( "group", "artifact", "1" ); + final ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "group", "artifact", "[2,3.1]" ); + final ArtifactRef r1 = new SimpleArtifactRef( pvr1, null, null, false ); + final ArtifactRef r2 = new SimpleArtifactRef( pvr2, null, null, false ); // trigger parsing. r1.getVersionSpec(); r2.getVersionSpec(); - final VersionlessArtifactRef vr1 = new VersionlessArtifactRef( r1 ); - final VersionlessArtifactRef vr2 = new VersionlessArtifactRef( r2 ); + final VersionlessArtifactRef vr1 = new SimpleVersionlessArtifactRef( r1 ); + final VersionlessArtifactRef vr2 = new SimpleVersionlessArtifactRef( r2 ); assertThat( vr1, equalTo( vr2 ) ); assertThat( vr1.hashCode(), equalTo( vr2.hashCode() ) ); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java index f89c83e5..b21afe74 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java @@ -15,21 +15,6 @@ */ package org.commonjava.maven.atlas.graph; -import static org.apache.commons.lang.StringUtils.join; - -import java.io.Closeable; -import java.io.IOException; -import java.net.URI; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; import org.commonjava.maven.atlas.graph.model.EProjectCycle; import org.commonjava.maven.atlas.graph.model.EProjectDirectRelationships; @@ -44,9 +29,17 @@ import org.commonjava.maven.atlas.graph.traverse.TraversalType; import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.Closeable; +import java.io.IOException; +import java.net.URI; +import java.util.*; + +import static org.apache.commons.lang.StringUtils.join; + public final class RelationshipGraph implements Closeable { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java index 1964ef90..ffbf79f5 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java @@ -15,19 +15,6 @@ */ package org.commonjava.maven.atlas.graph; -import static org.apache.commons.lang.StringUtils.join; - -import java.io.Serializable; -import java.net.URI; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - import org.apache.commons.codec.digest.DigestUtils; import org.commonjava.maven.atlas.graph.filter.AnyFilter; import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; @@ -37,6 +24,13 @@ import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import java.io.Serializable; +import java.net.URI; +import java.util.*; +import java.util.Map.Entry; + +import static org.apache.commons.lang.StringUtils.join; + /** *

* View of a graph database that may include a set of traversal root-nodes, @@ -507,7 +501,7 @@ public Builder withMutator( final GraphMutator mutator ) * Adds selected versions into selections map. To work properly keys * must be instances of {@link ProjectRef} or of the same class as the * one used in {@link ViewParams#getSelection(ProjectRef)} and - * {@link ViewParams#hasSelection(ProjectRef)}. + * {@link ViewParams#hasSelection(ProjectVersionRef)}. * * @param selections * map of {@link ProjectRef} to {@link ProjectVersionRef}, diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java index 23de055d..9abae004 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java @@ -38,9 +38,10 @@ import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; public class EProjectDirectRelationships implements EProjectRelationshipCollection, Serializable @@ -472,7 +473,7 @@ public int getNextExtensionIndex() public Builder withDependency( final ProjectVersionRef ref, final String type, final String classifier, final DependencyScope scope, final boolean managed ) { - withDependencies( new DependencyRelationship( source, ref, new ArtifactRef( ref, type, classifier, false ), + withDependencies( new DependencyRelationship( source, ref, new SimpleArtifactRef( ref, type, classifier, false ), scope, getNextDependencyIndex( managed ), managed ) ); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractProjectRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractProjectRelationship.java index c33121cd..4547b781 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractProjectRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractProjectRelationship.java @@ -15,20 +15,16 @@ */ package org.commonjava.maven.atlas.graph.rel; -import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.POM_ROOT_URI; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import java.io.Serializable; import java.lang.reflect.Constructor; import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.POM_ROOT_URI; public abstract class AbstractProjectRelationship implements ProjectRelationship, Serializable diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java index 4f6ed549..e3b09d40 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java @@ -17,7 +17,6 @@ import java.net.URI; import java.util.Collection; -import java.util.Set; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java index 363e6468..9da8b7dc 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java @@ -15,6 +15,13 @@ */ package org.commonjava.maven.atlas.graph.rel; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.version.SingleVersion; + import java.io.Serializable; import java.net.URI; import java.util.Arrays; @@ -22,12 +29,6 @@ import java.util.HashSet; import java.util.Set; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.version.SingleVersion; - public final class DependencyRelationship extends AbstractProjectRelationship implements Serializable @@ -162,7 +163,7 @@ public ProjectRelationship selectTarget( final SingleVersion versio { final ProjectVersionRef d = getDeclaring(); ArtifactRef t = getTarget(); - t = new ArtifactRef( t.selectVersion( version, force ), t.getType(), t.getClassifier(), t.isOptional() ); + t = new SimpleArtifactRef( t.selectVersion( version, force ), t.getType(), t.getClassifier(), t.isOptional() ); Set var = getExcludes(); return new DependencyRelationship( getSources(), getPomLocation(), d, t, getScope(), getIndex(), isManaged(), @@ -185,7 +186,7 @@ public ProjectRelationship selectTarget( final ProjectVersionRef re final ProjectVersionRef d = getDeclaring(); ArtifactRef t = getTarget(); t = - (ArtifactRef) ( ( ref instanceof ArtifactRef ) ? ref : new ArtifactRef( ref, t.getType(), + (ArtifactRef) ( ( ref instanceof ArtifactRef ) ? ref : new SimpleArtifactRef( ref, t.getType(), t.getClassifier(), t.isOptional() ) ); Set var = getExcludes(); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java index 9fb702dc..e7e76ccd 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java @@ -15,15 +15,16 @@ */ package org.commonjava.maven.atlas.graph.rel; -import java.io.Serializable; -import java.net.URI; -import java.util.Collection; - import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.version.SingleVersion; +import java.io.Serializable; +import java.net.URI; +import java.util.Collection; + public final class ExtensionRelationship extends AbstractProjectRelationship implements Serializable @@ -64,7 +65,7 @@ public String toString() @Override public ArtifactRef getTargetArtifact() { - return new ArtifactRef( getTarget(), null, null, false ); + return new SimpleArtifactRef( getTarget(), null, null, false ); } @Override diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java index 8fcc0191..84f4de83 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java @@ -15,15 +15,16 @@ */ package org.commonjava.maven.atlas.graph.rel; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.version.SingleVersion; + import java.io.Serializable; import java.net.URI; import java.net.URISyntaxException; import java.util.Collection; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.version.SingleVersion; - public final class ParentRelationship extends AbstractProjectRelationship implements Serializable @@ -85,7 +86,7 @@ public String toString() @Override public ArtifactRef getTargetArtifact() { - return new ArtifactRef( getTarget(), "pom", null, false ); + return new SimpleArtifactRef( getTarget(), "pom", null, false ); } public boolean isTerminus() diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java index f130ff7b..3f1a4206 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java @@ -15,15 +15,16 @@ */ package org.commonjava.maven.atlas.graph.rel; -import java.io.Serializable; -import java.net.URI; -import java.util.Collection; - import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.version.SingleVersion; +import java.io.Serializable; +import java.net.URI; +import java.util.Collection; + public final class PluginDependencyRelationship extends AbstractProjectRelationship implements Serializable @@ -152,7 +153,7 @@ public ProjectRelationship selectTarget( final SingleVersion versio { final ProjectVersionRef d = getDeclaring(); ArtifactRef t = getTarget(); - t = new ArtifactRef( t.selectVersion( version, force ), t.getType(), t.getClassifier(), t.isOptional() ); + t = new SimpleArtifactRef( t.selectVersion( version, force ), t.getType(), t.getClassifier(), t.isOptional() ); return new PluginDependencyRelationship( getSources(), getPomLocation(), d, getPlugin(), t, getIndex(), isManaged() ); @@ -173,7 +174,7 @@ public ProjectRelationship selectTarget( final ProjectVersionRef re final ProjectVersionRef d = getDeclaring(); ArtifactRef t = getTarget(); t = - (ArtifactRef) ( ( ref instanceof ArtifactRef ) ? ref : new ArtifactRef( ref, t.getType(), + (ArtifactRef) ( ( ref instanceof ArtifactRef ) ? ref : new SimpleArtifactRef( ref, t.getType(), t.getClassifier(), t.isOptional() ) ); return new PluginDependencyRelationship( getSources(), getPomLocation(), d, getPlugin(), t, getIndex(), diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java index b20136db..73367926 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java @@ -20,7 +20,9 @@ import java.util.Collection; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.commonjava.maven.atlas.ident.version.SingleVersion; public final class PluginRelationship @@ -117,7 +119,7 @@ public String toString() @Override public ArtifactRef getTargetArtifact() { - return new ArtifactRef( getTarget(), "maven-plugin", null, false ); + return new SimpleArtifactRef( getTarget(), "maven-plugin", null, false ); } @Override diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ProjectRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ProjectRelationship.java index 3097e191..7a136273 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ProjectRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ProjectRelationship.java @@ -21,7 +21,9 @@ import java.util.Set; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.commonjava.maven.atlas.ident.version.SingleVersion; public interface ProjectRelationship diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java index 93bc42fe..a8a07bae 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java @@ -133,16 +133,10 @@ void traverse( RelationshipGraphTraversal traversal, ProjectVersionRef root, Rel Set getProjectsWithMetadata( ViewParams params, String key ); - /** - * @deprecated Use {@link #getDirectRelationshipsFrom(GraphView,ProjectVersionRef,boolean,boolean,RelationshipType...)} instead - */ @Deprecated Set> getDirectRelationshipsFrom( ViewParams params, ProjectVersionRef from, boolean includeManagedInfo, RelationshipType... types ); - /** - * @deprecated Use {@link #getDirectRelationshipsTo(GraphView,ProjectVersionRef,boolean,boolean,RelationshipType...)} instead - */ @Deprecated Set> getDirectRelationshipsTo( ViewParams params, ProjectVersionRef to, boolean includeManagedInfo, RelationshipType... types ); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java index 84a3a90e..4b985308 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java @@ -29,9 +29,7 @@ import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; import org.commonjava.maven.atlas.graph.traverse.model.BuildOrder; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.*; public class BuildOrderTraversal extends AbstractFilteringTraversal @@ -79,8 +77,8 @@ protected boolean shouldTraverseEdge( final ProjectRelationship relationship, target = ( (ArtifactRef) target ).asProjectVersionRef(); } - final ProjectRef baseDecl = new ProjectRef( decl.getGroupId(), decl.getArtifactId() ); - final ProjectRef baseTgt = new ProjectRef( target.getGroupId(), target.getArtifactId() ); + final ProjectRef baseDecl = new SimpleProjectRef( decl.getGroupId(), decl.getArtifactId() ); + final ProjectRef baseTgt = new SimpleProjectRef( target.getGroupId(), target.getArtifactId() ); int declIdx = order.indexOf( baseDecl ); final int tgtIdx = order.indexOf( baseTgt ); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java index 2575b26d..06447080 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java @@ -15,12 +15,6 @@ */ package org.commonjava.maven.atlas.graph.traverse; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.commonjava.maven.atlas.graph.filter.DependencyFilter; import org.commonjava.maven.atlas.graph.filter.OrFilter; import org.commonjava.maven.atlas.graph.filter.ParentFilter; @@ -30,10 +24,13 @@ import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.ident.DependencyScope; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleVersionlessArtifactRef; import org.commonjava.maven.atlas.ident.ref.VersionlessArtifactRef; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.*; + public class TransitiveDependencyTraversal extends AbstractFilteringTraversal { @@ -72,7 +69,7 @@ public boolean shouldTraverseEdge( final ProjectRelationship relationship, if ( relationship instanceof DependencyRelationship ) { final ArtifactRef target = (ArtifactRef) relationship.getTarget(); - final VersionlessArtifactRef versionlessTarget = new VersionlessArtifactRef( target ); + final VersionlessArtifactRef versionlessTarget = new SimpleVersionlessArtifactRef( target ); logger.debug( "Checking for seen versionless GA[TC]: {}", versionlessTarget ); final Integer distance = seenArtifacts.get( versionlessTarget ); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java index 5dffd2f7..23b3acee 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java @@ -31,6 +31,8 @@ import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; public class ListPrinter { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java index 744efb39..fa677210 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java @@ -28,6 +28,8 @@ import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; public class TreePrinter { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java index 570d59d2..efce2904 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java @@ -44,6 +44,7 @@ import org.commonjava.maven.atlas.ident.DependencyScope; import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.commonjava.maven.atlas.ident.util.JoinString; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; import org.slf4j.Logger; diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java index c4b99d0a..1461f001 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java @@ -29,8 +29,9 @@ import org.commonjava.maven.atlas.graph.rel.PluginRelationship; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; import org.junit.Rule; import org.junit.Test; @@ -52,32 +53,32 @@ private URI testURI() public void builderWith2Dependencies2PluginsAParentAndAnExtension() throws InvalidVersionSpecificationException, URISyntaxException { - final ProjectVersionRef p = new ProjectVersionRef( "org.apache.maven", "maven-core", "3.0.3" ); + final ProjectVersionRef p = new SimpleProjectVersionRef( "org.apache.maven", "maven-core", "3.0.3" ); final URI source = testURI(); final EProjectDirectRelationships.Builder prb = new EProjectDirectRelationships.Builder( source, p ); - final ProjectVersionRef parent = new ProjectVersionRef( "org.apache.maven", "maven", "3.0.3" ); + final ProjectVersionRef parent = new SimpleProjectVersionRef( "org.apache.maven", "maven", "3.0.3" ); final ParentRelationship parentRel = new ParentRelationship( source, p, parent ); int idx = 0; int pidx = 0; final DependencyRelationship papi = - new DependencyRelationship( source, p, new ArtifactRef( "org.apache.maven", "maven-plugin-api", "3.0.3", + new DependencyRelationship( source, p, new SimpleArtifactRef( "org.apache.maven", "maven-plugin-api", "3.0.3", null, null, false ), DependencyScope.compile, idx++, false ); final DependencyRelationship art = - new DependencyRelationship( source, p, new ArtifactRef( "org.apache.maven", "maven-artifact", "3.0.3", + new DependencyRelationship( source, p, new SimpleArtifactRef( "org.apache.maven", "maven-artifact", "3.0.3", null, null, false ), DependencyScope.compile, idx++, false ); final PluginRelationship jarp = - new PluginRelationship( source, p, new ProjectVersionRef( "org.apache.maven.plugins", "maven-jar-plugin", + new PluginRelationship( source, p, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-jar-plugin", "2.2" ), pidx++, false ); final PluginRelationship comp = - new PluginRelationship( source, p, new ProjectVersionRef( "org.apache.maven.plugins", + new PluginRelationship( source, p, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.3.2" ), pidx++, false ); final ExtensionRelationship wag = - new ExtensionRelationship( source, p, new ProjectVersionRef( "org.apache.maven.wagon", + new ExtensionRelationship( source, p, new SimpleProjectVersionRef( "org.apache.maven.wagon", "wagon-provider-webdav", "1.0" ), 0 ); prb.withParent( parentRel ); diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java index 16627e80..9272fbe0 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java @@ -23,8 +23,8 @@ import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestName; @@ -47,8 +47,8 @@ public void rejectTestScopeForRuntimeFilter() { final DependencyFilter filter = new DependencyFilter( DependencyScope.runtime ); final DependencyRelationship rel = - new DependencyRelationship( testURI(), new ProjectVersionRef( "g", "a", "1" ), - new ArtifactRef( "g", "b", "2", "jar", null, false ), DependencyScope.test, 0, + new DependencyRelationship( testURI(), new SimpleProjectVersionRef( "g", "a", "1" ), + new SimpleArtifactRef( "g", "b", "2", "jar", null, false ), DependencyScope.test, 0, false ); assertThat( filter.accept( rel ), equalTo( false ) ); diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/ParentRelationshipTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/ParentRelationshipTest.java index f13183e6..dc28a7b6 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/ParentRelationshipTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/ParentRelationshipTest.java @@ -22,6 +22,7 @@ import java.net.URISyntaxException; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.commonjava.maven.atlas.ident.util.VersionUtils; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; import org.junit.Rule; @@ -45,13 +46,13 @@ public void cloneToDifferentProject() throws InvalidVersionSpecificationException, URISyntaxException { final ProjectVersionRef projectRef = - new ProjectVersionRef( "org.foo", "foobar", VersionUtils.createSingleVersion( "1.0" ) ); + new SimpleProjectVersionRef( "org.foo", "foobar", VersionUtils.createSingleVersion( "1.0" ) ); final ProjectVersionRef project2Ref = - new ProjectVersionRef( "org.foo", "footoo", VersionUtils.createSingleVersion( "1.0" ) ); + new SimpleProjectVersionRef( "org.foo", "footoo", VersionUtils.createSingleVersion( "1.0" ) ); final ProjectVersionRef parentRef = - new ProjectVersionRef( "org.foo", "foobar-parent", VersionUtils.createSingleVersion( "1" ) ); + new SimpleProjectVersionRef( "org.foo", "foobar-parent", VersionUtils.createSingleVersion( "1" ) ); final URI source = testURI(); final ParentRelationship pr = new ParentRelationship( source, projectRef, parentRef ); diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparatorTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparatorTest.java index ec83ba3d..bcfe5f32 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparatorTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparatorTest.java @@ -27,6 +27,7 @@ import java.util.List; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; import org.junit.Rule; import org.junit.Test; diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/CycleDetectionTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/CycleDetectionTCK.java index 8b478d5e..4c78c5bc 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/CycleDetectionTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/CycleDetectionTCK.java @@ -31,8 +31,9 @@ import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; import org.commonjava.maven.atlas.graph.rel.PluginRelationship; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.junit.Test; public abstract class CycleDetectionTCK @@ -46,17 +47,17 @@ public void introducesCycleCheckWithExistingGraph() { final URI source = sourceURI(); - final ProjectVersionRef project = new ProjectVersionRef( "org.my", "project", "1.0" ); - final ProjectVersionRef dep = new ProjectVersionRef( "org.other", "dep", "1.0" ); - final ProjectVersionRef dep2 = new ProjectVersionRef( "org.other", "dep2", "1.0" ); + final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); + final ProjectVersionRef dep = new SimpleProjectVersionRef( "org.other", "dep", "1.0" ); + final ProjectVersionRef dep2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0" ); final RelationshipGraph graph = simpleGraph( project ); /* @formatter:off */ - graph.storeRelationships( new DependencyRelationship( source, project, new ArtifactRef( dep, null, null, false ), null, 0, false ), - new DependencyRelationship( source, dep, new ArtifactRef( dep2, null, null, false ), null, 0, false ) ); + graph.storeRelationships( new DependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null, false ), null, 0, false ), + new DependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null, false ), null, 0, false ) ); - final boolean introduces = graph.introducesCycle( new DependencyRelationship( source, dep, new ArtifactRef( project, null, null, false ), null, 0, false ) ); + final boolean introduces = graph.introducesCycle( new DependencyRelationship( source, dep, new SimpleArtifactRef( project, null, null, false ), null, 0, false ) ); /* @formatter:on */ assertThat( introduces, equalTo( true ) ); @@ -69,9 +70,9 @@ public void buildGraphWithCycleBackToRootAndRetrieveCycle() { final URI source = sourceURI(); - final ProjectVersionRef project = new ProjectVersionRef( "org.my", "project", "1.0" ); - final ProjectVersionRef dep = new ProjectVersionRef( "org.other", "dep", "1.0" ); - final ProjectVersionRef dep2 = new ProjectVersionRef( "org.other", "dep2", "1.0" ); + final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); + final ProjectVersionRef dep = new SimpleProjectVersionRef( "org.other", "dep", "1.0" ); + final ProjectVersionRef dep2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0" ); final RelationshipGraph graph = simpleGraph( project ); @@ -103,17 +104,17 @@ public void buildGraphWithCycleBetweenDepLevelsAndRetrieveCycle() { final URI source = sourceURI(); - final ProjectVersionRef project = new ProjectVersionRef( "org.my", "project", "1.0" ); - final ProjectVersionRef dep = new ProjectVersionRef( "org.other", "dep", "1.0" ); - final ProjectVersionRef dep2 = new ProjectVersionRef( "org.other", "dep2", "1.0" ); + final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); + final ProjectVersionRef dep = new SimpleProjectVersionRef( "org.other", "dep", "1.0" ); + final ProjectVersionRef dep2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0" ); final RelationshipGraph graph = simpleGraph( project ); /* @formatter:off */ final Set> rejected = graph.storeRelationships( - new DependencyRelationship( source, project, new ArtifactRef( dep, null, null, false ), null, 0, false ), - new DependencyRelationship( source, dep, new ArtifactRef( dep2, null, null, false ), null, 0, false ), - new DependencyRelationship( source, dep2, new ArtifactRef( dep, null, null, false ), null, 0, false ) ); + new DependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null, false ), null, 0, false ), + new DependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null, false ), null, 0, false ), + new DependencyRelationship( source, dep2, new SimpleArtifactRef( dep, null, null, false ), null, 0, false ) ); /* @formatter:on */ assertThat( rejected, notNullValue() ); @@ -147,23 +148,23 @@ public void GB_cycleFromGraph1PresentInGraph2WhenNodeIsCrossReferenced() { final URI source = sourceURI(); - final ProjectVersionRef a = new ProjectVersionRef( "project", "A", "1.0" ); - final ProjectVersionRef b = new ProjectVersionRef( "project", "B", "1.0" ); - final ProjectVersionRef c = new ProjectVersionRef( "project", "C", "1.0" ); + final ProjectVersionRef a = new SimpleProjectVersionRef( "project", "A", "1.0" ); + final ProjectVersionRef b = new SimpleProjectVersionRef( "project", "B", "1.0" ); + final ProjectVersionRef c = new SimpleProjectVersionRef( "project", "C", "1.0" ); - final ProjectVersionRef d = new ProjectVersionRef( "project", "D", "1.0" ); - final ProjectVersionRef e = new ProjectVersionRef( "project", "E", "1.0" ); + final ProjectVersionRef d = new SimpleProjectVersionRef( "project", "D", "1.0" ); + final ProjectVersionRef e = new SimpleProjectVersionRef( "project", "E", "1.0" ); final RelationshipGraph graph = simpleGraph( a ); /* @formatter:off */ // a --> b --> c --> a // d --> e --> c --> a --> b --> c - graph.storeRelationships( new DependencyRelationship( source, a, new ArtifactRef( b, null, null, false ), null, 0, false ), - new DependencyRelationship( source, b, new ArtifactRef( c, null, null, false ), null, 0, false ), - new DependencyRelationship( source, c, new ArtifactRef( a, null, null, false ), null, 0, false ), - new DependencyRelationship( source, d, new ArtifactRef( e, null, null, false ), null, 0, false ), - new DependencyRelationship( source, e, new ArtifactRef( c, null, null, false ), null, 0, false ) ); + graph.storeRelationships( new DependencyRelationship( source, a, new SimpleArtifactRef( b, null, null, false ), null, 0, false ), + new DependencyRelationship( source, b, new SimpleArtifactRef( c, null, null, false ), null, 0, false ), + new DependencyRelationship( source, c, new SimpleArtifactRef( a, null, null, false ), null, 0, false ), + new DependencyRelationship( source, d, new SimpleArtifactRef( e, null, null, false ), null, 0, false ), + new DependencyRelationship( source, e, new SimpleArtifactRef( c, null, null, false ), null, 0, false ) ); /* @formatter:on */ final RelationshipGraph graph2 = @@ -206,23 +207,23 @@ public void cycleFromGraph1MissingInFilteredGraph2WhenOneRelationshipInCycleFilt { final URI source = sourceURI(); - final ProjectVersionRef a = new ProjectVersionRef( "project", "A", "1.0" ); - final ProjectVersionRef b = new ProjectVersionRef( "project", "B", "1.0" ); - final ProjectVersionRef c = new ProjectVersionRef( "project", "C", "1.0" ); + final ProjectVersionRef a = new SimpleProjectVersionRef( "project", "A", "1.0" ); + final ProjectVersionRef b = new SimpleProjectVersionRef( "project", "B", "1.0" ); + final ProjectVersionRef c = new SimpleProjectVersionRef( "project", "C", "1.0" ); - final ProjectVersionRef d = new ProjectVersionRef( "project", "D", "1.0" ); - final ProjectVersionRef e = new ProjectVersionRef( "project", "E", "1.0" ); + final ProjectVersionRef d = new SimpleProjectVersionRef( "project", "D", "1.0" ); + final ProjectVersionRef e = new SimpleProjectVersionRef( "project", "E", "1.0" ); final RelationshipGraph graph = simpleGraph( a ); /* @formatter:off */ // a --> b --> c --> a // d --> e --> c --> a --> b --> c - graph.storeRelationships( new DependencyRelationship( source, a, new ArtifactRef( b, null, null, false ), null, 0, false ), - new DependencyRelationship( source, c, new ArtifactRef( a, null, null, false ), null, 0, false ), + graph.storeRelationships( new DependencyRelationship( source, a, new SimpleArtifactRef( b, null, null, false ), null, 0, false ), + new DependencyRelationship( source, c, new SimpleArtifactRef( a, null, null, false ), null, 0, false ), new PluginRelationship( source, b, c, 0, false ), - new DependencyRelationship( source, d, new ArtifactRef( e, null, null, false ), null, 0, false ), - new DependencyRelationship( source, e, new ArtifactRef( c, null, null, false ), null, 0, false ) ); + new DependencyRelationship( source, d, new SimpleArtifactRef( e, null, null, false ), null, 0, false ), + new DependencyRelationship( source, e, new SimpleArtifactRef( c, null, null, false ), null, 0, false ) ); /* @formatter:on */ final RelationshipGraph graph2 = diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphFactoryTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphFactoryTCK.java index f15b95b0..33dbdcc4 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphFactoryTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphFactoryTCK.java @@ -29,6 +29,7 @@ import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; import org.commonjava.maven.atlas.graph.traverse.RelationshipGraphTraversal; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.junit.Test; public abstract class RelationshipGraphFactoryTCK @@ -39,9 +40,9 @@ public abstract class RelationshipGraphFactoryTCK public void openStoreDeleteAndReopen() throws Exception { - final ProjectVersionRef r = new ProjectVersionRef( "org.test", "root", "1" ); - final ProjectVersionRef p = new ProjectVersionRef( "org.test", "parent", "1.0" ); - final ProjectVersionRef c = new ProjectVersionRef( "org.test", "child", "1.0" ); + final ProjectVersionRef r = new SimpleProjectVersionRef( "org.test", "root", "1" ); + final ProjectVersionRef p = new SimpleProjectVersionRef( "org.test", "parent", "1.0" ); + final ProjectVersionRef c = new SimpleProjectVersionRef( "org.test", "child", "1.0" ); final URI source = sourceURI(); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphTCK.java index 7c4bff34..fab9bbb5 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphTCK.java @@ -36,6 +36,7 @@ import org.commonjava.maven.atlas.graph.traverse.TraversalType; import org.commonjava.maven.atlas.ident.DependencyScope; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.junit.Test; import org.slf4j.LoggerFactory; @@ -47,8 +48,8 @@ public abstract class RelationshipGraphTCK public void createPath_ReturnNullWhenTargetVersionIsAnExpression() throws Exception { - final ProjectVersionRef from = new ProjectVersionRef( "org.from", "project", "1.0" ); - final ProjectVersionRef to = new ProjectVersionRef( "org.to", "artifact", "${version.target}" ); + final ProjectVersionRef from = new SimpleProjectVersionRef( "org.from", "project", "1.0" ); + final ProjectVersionRef to = new SimpleProjectVersionRef( "org.to", "artifact", "${version.target}" ); final URI src = new URI( "test:source-uri" ); final ProjectRelationship rel = @@ -65,10 +66,10 @@ public void storeBOMThenVerifyBomGAVPresentInView() throws Exception { final URI src = sourceURI(); - final ProjectVersionRef gav = new ProjectVersionRef( "g", "a", "v" ); + final ProjectVersionRef gav = new SimpleProjectVersionRef( "g", "a", "v" ); - final ProjectVersionRef d1 = new ProjectVersionRef( "g", "d1", "1" ); - final ProjectVersionRef d2 = new ProjectVersionRef( "g", "d2", "2" ); + final ProjectVersionRef d1 = new SimpleProjectVersionRef( "g", "d1", "1" ); + final ProjectVersionRef d2 = new SimpleProjectVersionRef( "g", "d2", "2" ); final RelationshipGraph graph = openGraph( new ViewParams( newWorkspaceId(), new DependencyFilter(), new ManagedDependencyMutator(), gav ), @@ -90,9 +91,9 @@ public void storeBOMThenVerifyBomGAVPresentInView() public void connectThreeGraphsWithParentInterrelationships() throws Exception { - final ProjectVersionRef r = new ProjectVersionRef( "org.test", "root", "1" ); - final ProjectVersionRef p = new ProjectVersionRef( "org.test", "parent", "1.0" ); - final ProjectVersionRef c = new ProjectVersionRef( "org.test", "child", "1.0" ); + final ProjectVersionRef r = new SimpleProjectVersionRef( "org.test", "root", "1" ); + final ProjectVersionRef p = new SimpleProjectVersionRef( "org.test", "parent", "1.0" ); + final ProjectVersionRef c = new SimpleProjectVersionRef( "org.test", "child", "1.0" ); final URI source = sourceURI(); @@ -130,9 +131,9 @@ public void connectThreeGraphsWithParentInterrelationships() public void connectThreeGraphsWithParentInterrelationships_WrongOrder() throws Exception { - final ProjectVersionRef r = new ProjectVersionRef( "org.test", "root", "1" ); - final ProjectVersionRef p = new ProjectVersionRef( "org.test", "parent", "1.0" ); - final ProjectVersionRef c = new ProjectVersionRef( "org.test", "child", "1.0" ); + final ProjectVersionRef r = new SimpleProjectVersionRef( "org.test", "root", "1" ); + final ProjectVersionRef p = new SimpleProjectVersionRef( "org.test", "parent", "1.0" ); + final ProjectVersionRef c = new SimpleProjectVersionRef( "org.test", "child", "1.0" ); final URI source = sourceURI(); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/SubGraphSelectionTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/SubGraphSelectionTCK.java index f28ff7a1..1599e0a3 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/SubGraphSelectionTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/SubGraphSelectionTCK.java @@ -25,8 +25,9 @@ import org.commonjava.maven.atlas.graph.RelationshipGraph; import org.commonjava.maven.atlas.graph.ViewParams; import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.junit.Test; public abstract class SubGraphSelectionTCK @@ -38,17 +39,17 @@ public abstract class SubGraphSelectionTCK public void selectVersionForVariableSubgraph() throws Exception { - final ProjectVersionRef project = new ProjectVersionRef( "org.my", "project", "1.0" ); - final ProjectVersionRef varDep = new ProjectVersionRef( "org.other", "dep", "1.0-SNAPSHOT" ); - final ProjectVersionRef varD2 = new ProjectVersionRef( "org.other", "dep2", "1.0-SNAPSHOT" ); - final ProjectVersionRef selected = new ProjectVersionRef( varDep, "1.0-20130314.161200-1" ); + final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); + final ProjectVersionRef varDep = new SimpleProjectVersionRef( "org.other", "dep", "1.0-SNAPSHOT" ); + final ProjectVersionRef varD2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0-SNAPSHOT" ); + final ProjectVersionRef selected = new SimpleProjectVersionRef( varDep, "1.0-20130314.161200-1" ); final URI source = sourceURI(); final RelationshipGraph graph = simpleGraph( project ); /* @formatter:off */ - graph.storeRelationships( new DependencyRelationship( source, project, new ArtifactRef( varDep, null, null, false ), null, 0, false ), - new DependencyRelationship( source, varDep, new ArtifactRef( varD2, null, null, false ), null, 0, false ) ); + graph.storeRelationships( new DependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false ), + new DependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false ) ); /* @formatter:on */ Set variables = graph.getVariableSubgraphs(); @@ -77,17 +78,17 @@ public void selectVersionForVariableSubgraph() public void selectVersionForVariableSubgraph_SelectionsContextualToView() throws Exception { - final ProjectVersionRef project = new ProjectVersionRef( "org.my", "project", "1.0" ); - final ProjectVersionRef varDep = new ProjectVersionRef( "org.other", "dep", "1.0-SNAPSHOT" ); - final ProjectVersionRef varD2 = new ProjectVersionRef( "org.other", "dep2", "1.0-SNAPSHOT" ); - final ProjectVersionRef selected = new ProjectVersionRef( varDep, "1.0-20130314.161200-1" ); + final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); + final ProjectVersionRef varDep = new SimpleProjectVersionRef( "org.other", "dep", "1.0-SNAPSHOT" ); + final ProjectVersionRef varD2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0-SNAPSHOT" ); + final ProjectVersionRef selected = new SimpleProjectVersionRef( varDep, "1.0-20130314.161200-1" ); final URI source = sourceURI(); final RelationshipGraph graph = simpleGraph( project ); /* @formatter:off */ - graph.storeRelationships( new DependencyRelationship( source, project, new ArtifactRef( varDep, null, null, false ), null, 0, false ), - new DependencyRelationship( source, varDep, new ArtifactRef( varD2, null, null, false ), null, 0, false ) ); + graph.storeRelationships( new DependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false ), + new DependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false ) ); /* @formatter:on */ Set variables = graph.getVariableSubgraphs(); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/AncestryTraversalTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/AncestryTraversalTCK.java index 54f68ba9..020b0f5f 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/AncestryTraversalTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/AncestryTraversalTCK.java @@ -28,8 +28,9 @@ import org.commonjava.maven.atlas.graph.rel.ParentRelationship; import org.commonjava.maven.atlas.graph.rel.PluginRelationship; import org.commonjava.maven.atlas.graph.traverse.AncestryTraversal; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; import org.junit.Test; @@ -41,9 +42,9 @@ public abstract class AncestryTraversalTCK public void traverseTwoAncestors() throws Exception { - final ProjectVersionRef myRef = new ProjectVersionRef( "my.group", "my-artifact", "1.0" ); - final ProjectVersionRef parentRef = new ProjectVersionRef( "my.group", "my-dad", "1" ); - final ProjectVersionRef grandRef = new ProjectVersionRef( "other.group", "grandpa", "20120821" ); + final ProjectVersionRef myRef = new SimpleProjectVersionRef( "my.group", "my-artifact", "1.0" ); + final ProjectVersionRef parentRef = new SimpleProjectVersionRef( "my.group", "my-dad", "1" ); + final ProjectVersionRef grandRef = new SimpleProjectVersionRef( "other.group", "grandpa", "20120821" ); final URI source = sourceURI(); final RelationshipGraph graph = simpleGraph( myRef ); @@ -89,9 +90,9 @@ public void traverseTwoAncestors() public void traverseTwoAncestorsWithEmptyGrandParentRels() throws Exception { - final ProjectVersionRef myRef = new ProjectVersionRef( "my.group", "my-artifact", "1.0" ); - final ProjectVersionRef parentRef = new ProjectVersionRef( "my.group", "my-dad", "1" ); - final ProjectVersionRef grandRef = new ProjectVersionRef( "other.group", "grandpa", "20120821" ); + final ProjectVersionRef myRef = new SimpleProjectVersionRef( "my.group", "my-artifact", "1.0" ); + final ProjectVersionRef parentRef = new SimpleProjectVersionRef( "my.group", "my-dad", "1" ); + final ProjectVersionRef grandRef = new SimpleProjectVersionRef( "other.group", "grandpa", "20120821" ); final URI source = sourceURI(); final RelationshipGraph graph = simpleGraph( myRef ); @@ -128,22 +129,22 @@ public void traverseTwoAncestorsWithEmptyGrandParentRels() public void traverseTwoAncestors_IgnoreNonParentRelationships() throws Exception { - final ProjectVersionRef myRef = new ProjectVersionRef( "my.group", "my-artifact", "1.0" ); - final ProjectVersionRef parentRef = new ProjectVersionRef( "my.group", "my-dad", "1" ); - final ProjectVersionRef grandRef = new ProjectVersionRef( "other.group", "grandpa", "20120821" ); + final ProjectVersionRef myRef = new SimpleProjectVersionRef( "my.group", "my-artifact", "1.0" ); + final ProjectVersionRef parentRef = new SimpleProjectVersionRef( "my.group", "my-dad", "1" ); + final ProjectVersionRef grandRef = new SimpleProjectVersionRef( "other.group", "grandpa", "20120821" ); final URI source = sourceURI(); final RelationshipGraph graph = simpleGraph( myRef ); /* @formatter:off */ graph.storeRelationships( new ParentRelationship( source, myRef, parentRef ), - new DependencyRelationship( source, myRef, new ArtifactRef( new ProjectVersionRef( "some.group", "foo", "1.0" ), null, null, false ), null, 0, false ), - new DependencyRelationship( source, myRef, new ArtifactRef( new ProjectVersionRef( "some.group", "bar", "1.2.1" ), null, null, false ), null, 1, false ), - new PluginRelationship( source, myRef, new ProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.5.1" ), 0, false ), - new PluginRelationship( source, myRef, new ProjectVersionRef( "org.apache.maven.plugins","maven-jar-plugin", "2.2" ), 1, false ), - new ExtensionRelationship( source, myRef, new ProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.5.1" ), 0 ), + new DependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "foo", "1.0" ), null, null, false ), null, 0, false ), + new DependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "bar", "1.2.1" ), null, null, false ), null, 1, false ), + new PluginRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.5.1" ), 0, false ), + new PluginRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins","maven-jar-plugin", "2.2" ), 1, false ), + new ExtensionRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.5.1" ), 0 ), new ParentRelationship( source, parentRef, grandRef ), - new DependencyRelationship( source, parentRef, new ProjectVersionRef( "other.group", "utils", "3-1" ).asJarArtifact(), null, 0, false ) + new DependencyRelationship( source, parentRef, new SimpleProjectVersionRef( "other.group", "utils", "3-1" ).asJarArtifact(), null, 0, false ) ); /* @formatter:on */ diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java index 4abffc1e..e65b2f04 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java @@ -33,9 +33,10 @@ import org.commonjava.maven.atlas.graph.traverse.BuildOrderTraversal; import org.commonjava.maven.atlas.graph.traverse.model.BuildOrder; import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; import org.junit.Test; import org.slf4j.LoggerFactory; @@ -48,9 +49,9 @@ public abstract class BuildOrderTraversalTCK public void simpleDependencyBuildOrder() throws Exception { - final ProjectVersionRef c = new ProjectVersionRef( "group.id", "c", "3" ); - final ProjectVersionRef b = new ProjectVersionRef( "group.id", "b", "2" ); - final ProjectVersionRef a = new ProjectVersionRef( "group.id", "a", "1" ); + final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); + final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); + final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); final Map relativeOrder = new HashMap(); @@ -61,8 +62,8 @@ public void simpleDependencyBuildOrder() final RelationshipGraph graph = simpleGraph( c ); /* @formatter:off */ - graph.storeRelationships( new DependencyRelationship( source, c, new ArtifactRef( b, null, null, false ), null, 0, false ), - new DependencyRelationship( source, b, new ArtifactRef( a, null, null, false ), null, 0, false ) ); + graph.storeRelationships( new DependencyRelationship( source, c, new SimpleArtifactRef( b, null, null, false ), null, 0, false ), + new DependencyRelationship( source, b, new SimpleArtifactRef( a, null, null, false ), null, 0, false ) ); /* @formatter:on */ assertThat( graph.getAllRelationships() @@ -84,10 +85,10 @@ public void simpleDependencyBuildOrder_includeDepParent() throws Exception { - final ProjectVersionRef c = new ProjectVersionRef( "group.id", "c", "3" ); - final ProjectVersionRef b = new ProjectVersionRef( "group.id", "b", "2" ); - final ProjectVersionRef a = new ProjectVersionRef( "group.id", "a", "1" ); - final ProjectVersionRef p = new ProjectVersionRef( "group.id", "b-parent", "1001" ); + final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); + final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); + final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); + final ProjectVersionRef p = new SimpleProjectVersionRef( "group.id", "b-parent", "1001" ); final Map relativeOrder = new HashMap(); @@ -128,11 +129,11 @@ public void simpleDependencyBuildOrder_includeDepParent() public void simpleDependencyBuildOrder_IgnorePluginPath() throws Exception { - final ProjectVersionRef c = new ProjectVersionRef( "group.id", "c", "3" ); - final ProjectVersionRef b = new ProjectVersionRef( "group.id", "b", "2" ); - final ProjectVersionRef a = new ProjectVersionRef( "group.id", "a", "1" ); - final ProjectVersionRef pa = new ProjectVersionRef( "plugin.id", "p-a", "1" ); - final ProjectVersionRef pb = new ProjectVersionRef( "plugin.id", "p-b", "2" ); + final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); + final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); + final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); + final ProjectVersionRef pa = new SimpleProjectVersionRef( "plugin.id", "p-a", "1" ); + final ProjectVersionRef pb = new SimpleProjectVersionRef( "plugin.id", "p-b", "2" ); final Map relativeOrder = new HashMap(); @@ -168,13 +169,13 @@ public void simpleDependencyBuildOrder_IgnorePluginPath() public void simpleDependencyBuildOrder_runtimeDepsOnly() throws Exception { - final ProjectVersionRef e = new ProjectVersionRef( "group.id", "e", "5" ); - final ProjectVersionRef d = new ProjectVersionRef( "group.id", "d", "4" ); - final ProjectVersionRef c = new ProjectVersionRef( "group.id", "c", "3" ); - final ProjectVersionRef b = new ProjectVersionRef( "group.id", "b", "2" ); - final ProjectVersionRef a = new ProjectVersionRef( "group.id", "a", "1" ); - final ProjectVersionRef pa = new ProjectVersionRef( "plugin.id", "p-a", "1" ); - final ProjectVersionRef pb = new ProjectVersionRef( "plugin.id", "p-b", "2" ); + final ProjectVersionRef e = new SimpleProjectVersionRef( "group.id", "e", "5" ); + final ProjectVersionRef d = new SimpleProjectVersionRef( "group.id", "d", "4" ); + final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); + final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); + final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); + final ProjectVersionRef pa = new SimpleProjectVersionRef( "plugin.id", "p-a", "1" ); + final ProjectVersionRef pb = new SimpleProjectVersionRef( "plugin.id", "p-b", "2" ); final Map relativeOrder = new HashMap(); @@ -214,10 +215,10 @@ public void simpleDependencyBuildOrder_runtimeDepsOnly() public void simpleDependencyBuildOrder_ignoreExcluded() throws Exception { - final ProjectVersionRef d = new ProjectVersionRef( "group.id", "d", "4" ); - final ProjectVersionRef c = new ProjectVersionRef( "group.id", "c", "3" ); - final ProjectVersionRef b = new ProjectVersionRef( "group.id", "b", "2" ); - final ProjectVersionRef a = new ProjectVersionRef( "group.id", "a", "1" ); + final ProjectVersionRef d = new SimpleProjectVersionRef( "group.id", "d", "4" ); + final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); + final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); + final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); final Map relativeOrder = new HashMap(); @@ -255,11 +256,11 @@ public void simpleDependencyBuildOrder_ignoreExcluded() public void simpleEverythingBuildOrder() throws Exception { - final ProjectVersionRef c = new ProjectVersionRef( "group.id", "c", "3" ); - final ProjectVersionRef b = new ProjectVersionRef( "group.id", "b", "2" ); - final ProjectVersionRef a = new ProjectVersionRef( "group.id", "a", "1" ); - final ProjectVersionRef pa = new ProjectVersionRef( "plugin.dep.id", "p-a", "1" ); - final ProjectVersionRef pb = new ProjectVersionRef( "plugin.id", "p-b", "2" ); + final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); + final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); + final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); + final ProjectVersionRef pa = new SimpleProjectVersionRef( "plugin.dep.id", "p-a", "1" ); + final ProjectVersionRef pb = new SimpleProjectVersionRef( "plugin.id", "p-b", "2" ); final Map relativeOrder = new HashMap(); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/TransitiveDependencyTraversalTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/TransitiveDependencyTraversalTCK.java index c9951984..ebbaed59 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/TransitiveDependencyTraversalTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/TransitiveDependencyTraversalTCK.java @@ -29,6 +29,7 @@ import org.commonjava.maven.atlas.graph.rel.ParentRelationship; import org.commonjava.maven.atlas.graph.traverse.TransitiveDependencyTraversal; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; import org.junit.Test; From 94a60292e67dff0ee09123598ffece711a33f7be Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 24 Aug 2015 08:42:42 -0500 Subject: [PATCH 096/240] re-add the setOptional() method to ArtifactRef. --- .../java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java index d93df8cb..a22964be 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java @@ -16,5 +16,7 @@ public interface ArtifactRef boolean isOptional(); + ArtifactRef setOptional(boolean optional ); + boolean versionlessEquals( ProjectVersionRef other ); } From 92c2714404a252ef4774d94576275869d49601ef Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 24 Aug 2015 23:47:33 -0500 Subject: [PATCH 097/240] Refactored relationships api to interfaces + impls, then split tests into parallelizable classes. I refactored TCK framework into tests + driver interface to make it easier to run from an IDE and debug individually. --- .../ProjectRelationshipSerializerModule.java | 14 +- ...ojectRelationshipSerializerModuleTest.java | 16 +- .../spi/jung/CycleDetectionTraversal.java | 8 +- .../graph/spi/jung/JungGraphConnection.java | 152 ++++---- .../spi/jung/PathDetectionTraversal.java | 4 +- .../graph/spi/jung/model/JungGraphPath.java | 30 +- .../graph/spi/jung/CycleDetectionTest.java | 33 -- .../jung/RelationshipGraphConnectionTest.java | 33 -- .../graph/spi/jung/RelationshipGraphTest.java | 34 -- .../graph/spi/jung/SubGraphSelectionTest.java | 33 -- .../jung/traverse/AncestryTraversalTest.java | 34 -- .../traverse/BuildOrderTraversalTest.java | 34 -- .../TransitiveDependencyTraversalTest.java | 34 -- drivers/neo4j-embedded/pom.xml | 9 +- .../spi/neo4j/FileNeo4JGraphConnection.java | 138 ++++--- .../graph/spi/neo4j/Neo4JGraphConnection.java | 4 +- .../graph/spi/neo4j/io/ConversionCache.java | 14 +- .../atlas/graph/spi/neo4j/io/Conversions.java | 149 +++---- .../model/AbstractNeoProjectRelationship.java | 122 ++++++ .../graph/spi/neo4j/model/NeoArtifactRef.java | 253 ++++++++++++ .../spi/neo4j/model/NeoBomRelationship.java | 98 +++++ .../model/NeoDependencyRelationship.java | 179 +++++++++ .../neo4j/model/NeoExtensionRelationship.java | 105 +++++ .../spi/neo4j/model/NeoIdentityUtils.java | 79 ++++ .../neo4j/model/NeoParentRelationship.java | 120 ++++++ .../NeoPluginDependencyRelationship.java | 161 ++++++++ .../neo4j/model/NeoPluginRelationship.java | 140 +++++++ .../graph/spi/neo4j/model/NeoProjectRef.java | 247 ++++++++++++ .../spi/neo4j/model/NeoProjectVersionRef.java | 369 ++++++++++++++++++ .../spi/neo4j/model/NeoTypeAndClassifier.java | 157 ++++++++ .../model/NeoVersionlessArtifactRef.java | 233 +++++++++++ .../spi/neo4j/traverse/AtlasCollector.java | 8 +- .../MembershipWrappedTraversalEvaluator.java | 12 +- .../traverse/RootedRelationshipsVisitor.java | 8 +- .../spi/neo4j/traverse/TraversalUtils.java | 2 +- .../spi/neo4j/update/CycleCacheUpdater.java | 2 +- .../graph/spi/neo4j/update/ViewUpdater.java | 4 +- .../graph/spi/neo4j/CypherQueriesTest.java | 138 ------- .../spi/neo4j/FileCycleDetectionTest.java | 35 -- .../spi/neo4j/FileGraphWorkspaceTest.java | 36 -- .../spi/neo4j/FileSubGraphSelectionTest.java | 35 -- .../neo4j/RelationshipGraphFactoryTest.java | 35 -- .../spi/neo4j/RelationshipGraphTest.java | 35 -- .../neo4j/fixture/FileConnectionFixture.java | 71 ---- .../traverse/FileAncestryTraversalTest.java | 35 -- .../traverse/FileBuildOrderTraversalTest.java | 35 -- ...FileTransitiveDependencyTraversalTest.java | 35 -- drivers/pom.xml | 6 +- ftests/jung/pom.xml | 43 ++ .../graph/spi/jung/fixture/JungTCKDriver.java | 56 +++ ...a.maven.atlas.tck.graph.testutil.TCKDriver | 1 + .../jung/src/main}/resources/logback-test.xml | 0 ftests/neo4j/pom.xml | 60 +++ .../graph/spi/neo4j/fixture/NeoTCKDriver.java | 56 +++ ...a.maven.atlas.tck.graph.testutil.TCKDriver | 1 + .../src/main}/resources/logback-test.xml | 0 ftests/pom.xml | 80 ++++ .../ident/ref/SimpleTypeAndClassifier.java | 2 +- pom.xml | 11 + .../AbstractRelationshipGraphListener.java | 6 +- .../maven/atlas/graph/RelationshipGraph.java | 66 ++-- .../graph/RelationshipGraphListener.java | 6 +- .../maven/atlas/graph/ViewParams.java | 5 + .../filter/AbstractAggregatingFilter.java | 2 +- .../graph/filter/AbstractTypedFilter.java | 4 +- .../maven/atlas/graph/filter/AndFilter.java | 2 +- .../maven/atlas/graph/filter/AnyFilter.java | 4 +- .../maven/atlas/graph/filter/BomFilter.java | 4 +- .../atlas/graph/filter/DependencyFilter.java | 15 +- .../graph/filter/DependencyOnlyFilter.java | 4 +- .../atlas/graph/filter/ExcludingFilter.java | 4 +- .../atlas/graph/filter/ExtensionFilter.java | 6 +- .../graph/filter/ExtensionOnlyFilter.java | 2 +- .../maven/atlas/graph/filter/NoneFilter.java | 4 +- .../maven/atlas/graph/filter/OrFilter.java | 2 +- .../atlas/graph/filter/ParentFilter.java | 4 +- .../graph/filter/PluginDependencyFilter.java | 4 +- .../filter/PluginDependencyOnlyFilter.java | 4 +- .../atlas/graph/filter/PluginOnlyFilter.java | 4 +- .../graph/filter/PluginRuntimeFilter.java | 9 +- .../filter/ProjectRelationshipFilter.java | 4 +- .../graph/filter/RelationshipTypeFilter.java | 2 +- .../filter/StructuralRelationshipsFilter.java | 2 +- .../atlas/graph/model/EProjectCycle.java | 60 +-- .../model/EProjectDirectRelationships.java | 37 +- .../model/EProjectRelationshipCollection.java | 4 +- .../atlas/graph/model/GraphPathInfo.java | 4 +- .../atlas/graph/mutate/GraphMutator.java | 4 +- .../mutate/ManagedDependencyMutator.java | 4 +- .../atlas/graph/mutate/NoOpGraphMutator.java | 4 +- .../graph/mutate/VersionManagerMutator.java | 4 +- ...=> AbstractSimpleProjectRelationship.java} | 94 ++--- .../atlas/graph/rel/BomRelationship.java | 128 +----- .../graph/rel/DependencyRelationship.java | 192 +-------- .../graph/rel/ExtensionRelationship.java | 116 +----- .../atlas/graph/rel/ParentRelationship.java | 146 +------ .../rel/PluginDependencyRelationship.java | 176 +-------- .../atlas/graph/rel/PluginRelationship.java | 168 +------- .../atlas/graph/rel/ProjectRelationship.java | 24 +- .../graph/rel/RelationshipComparator.java | 4 +- .../graph/rel/RelationshipPathComparator.java | 8 +- .../graph/rel/SimpleBomRelationship.java | 123 ++++++ .../rel/SimpleDependencyRelationship.java | 187 +++++++++ .../rel/SimpleExtensionRelationship.java | 109 ++++++ .../graph/rel/SimpleParentRelationship.java | 120 ++++++ .../SimplePluginDependencyRelationship.java | 170 ++++++++ .../graph/rel/SimplePluginRelationship.java | 159 ++++++++ .../spi/RelationshipGraphConnection.java | 28 +- .../traverse/AbstractFilteringTraversal.java | 25 +- .../graph/traverse/AbstractTraversal.java | 4 +- .../graph/traverse/BuildOrderTraversal.java | 14 +- .../graph/traverse/FilteringTraversal.java | 10 +- .../atlas/graph/traverse/ImpactTraversal.java | 20 +- .../atlas/graph/traverse/PathsTraversal.java | 8 +- .../traverse/RelationshipGraphTraversal.java | 6 +- .../TransitiveDependencyTraversal.java | 10 +- .../DependencyTreeRelationshipPrinter.java | 2 +- .../graph/traverse/print/ListPrinter.java | 15 +- .../print/StructurePrintingTraversal.java | 19 +- .../print/StructureRelationshipPrinter.java | 2 +- .../traverse/print/TargetRefPrinter.java | 2 +- .../graph/traverse/print/TreePrinter.java | 17 +- .../atlas/graph/util/RelationshipUtils.java | 99 ++--- .../graph/EProjectRelationshipsTest.java | 20 +- .../graph/filter/DependencyFilterTest.java | 3 +- .../graph/rel/ParentRelationshipTest.java | 2 +- .../rel/RelationshipPathComparatorTest.java | 15 +- .../atlas/tck/graph/AbstractSPI_TCK.java | 38 +- .../atlas/tck/graph/CycleDetectionTCK.java | 263 ------------- .../atlas/tck/graph/RelationshipGraphTCK.java | 168 -------- ...hConnection_CreateAndRetrieveByIdTCK.java} | 30 +- ...onnection_CreateAndVerifyInListingTCK.java | 55 +++ .../cycle/CycleDetection_BackToRootTCK.java | 78 ++++ .../CycleDetection_BetweenDepLevelsTCK.java | 88 +++++ .../CycleDetection_FilterRemovesCycleTCK.java | 105 +++++ ...CycleDetection_IntroduceToExistingTCK.java | 67 ++++ .../CycleDetection_RootDependentTCK.java | 101 +++++ ...raphFactory_OpenStoreDeleteReopenTCK.java} | 31 +- ...elationshipGraph_ConnectOutOfOrderTCK.java | 87 +++++ ...ationshipGraph_ConnectWParentInterTCK.java | 81 ++++ ...pGraph_NullPathOnTargetExprVersionTCK.java | 62 +++ ...ionshipGraph_StoreAndVerifyInView_TCK.java | 70 ++++ .../graph/selection/SubGraphSelectionTCK.java | 80 ++++ ...ubGraphSelection_ContextualToViewTCK.java} | 70 +--- .../atlas/tck/graph/testutil/TCKDriver.java | 19 + .../graph/traverse/AncestryTraversalTCK.java | 176 --------- .../traverse/BuildOrderTraversalTCK.java | 330 ---------------- .../TransitiveDependencyTraversalTCK.java | 192 --------- ...tryTraversal_EmptyGrandparentRels_TCK.java | 80 ++++ ...stryTraversal_IgnoreNonParentRels_TCK.java | 87 +++++ .../AncestryTraversal_TwoAncestors_TCK.java | 90 +++++ .../buildorder/AbstractBuildOrderTCK.java | 79 ++++ ...ndencyBuildOrderIgnoringPluginPathTCK.java | 71 ++++ .../DependencyExcludesBuildOrderTCK.java | 70 ++++ .../ParentDependencyBuildOrderTCK.java | 75 ++++ .../RuntimeDependencyBuildOrderTCK.java | 77 ++++ .../SimpleDependencyBuildOrderTCK.java | 64 +++ .../SimpleEverythingBuildOrderTCK.java | 76 ++++ ...sitiveDependencyTraversal_DepOfDepTCK.java | 75 ++++ ...pendencyTraversal_DepOfDep_ExtMgmtTCK.java | 83 ++++ ...veDependencyTraversal_PreferDirectTCK.java | 79 ++++ ...iveDependencyTraversal_PreferLocalTCK.java | 77 ++++ 162 files changed, 6194 insertions(+), 3493 deletions(-) delete mode 100644 drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTest.java delete mode 100644 drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/RelationshipGraphConnectionTest.java delete mode 100644 drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/RelationshipGraphTest.java delete mode 100644 drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/SubGraphSelectionTest.java delete mode 100644 drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/AncestryTraversalTest.java delete mode 100644 drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/BuildOrderTraversalTest.java delete mode 100644 drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/TransitiveDependencyTraversalTest.java create mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java create mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java create mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoBomRelationship.java create mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java create mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoExtensionRelationship.java create mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentityUtils.java create mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoParentRelationship.java create mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java create mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java create mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java create mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java create mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoTypeAndClassifier.java create mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java delete mode 100644 drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/CypherQueriesTest.java delete mode 100644 drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileCycleDetectionTest.java delete mode 100644 drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileGraphWorkspaceTest.java delete mode 100644 drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileSubGraphSelectionTest.java delete mode 100644 drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphFactoryTest.java delete mode 100644 drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphTest.java delete mode 100644 drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/FileConnectionFixture.java delete mode 100644 drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileAncestryTraversalTest.java delete mode 100644 drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileBuildOrderTraversalTest.java delete mode 100644 drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileTransitiveDependencyTraversalTest.java create mode 100644 ftests/jung/pom.xml create mode 100644 ftests/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/fixture/JungTCKDriver.java create mode 100644 ftests/jung/src/main/resources/META-INF/services/org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver rename {drivers/jung/src/test => ftests/jung/src/main}/resources/logback-test.xml (100%) create mode 100644 ftests/neo4j/pom.xml create mode 100644 ftests/neo4j/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/NeoTCKDriver.java create mode 100644 ftests/neo4j/src/main/resources/META-INF/services/org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver rename {drivers/neo4j-embedded/src/test => ftests/neo4j/src/main}/resources/logback-test.xml (100%) create mode 100644 ftests/pom.xml rename relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/{AbstractProjectRelationship.java => AbstractSimpleProjectRelationship.java} (59%) create mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleBomRelationship.java create mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java create mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java create mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java create mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java create mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/CycleDetectionTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphTCK.java rename tck/src/main/java/org/commonjava/maven/atlas/tck/graph/{RelationshipGraphConnection_TCK.java => conn/RelationshipGraphConnection_CreateAndRetrieveByIdTCK.java} (65%) create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/conn/RelationshipGraphConnection_CreateAndVerifyInListingTCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BackToRootTCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java rename tck/src/main/java/org/commonjava/maven/atlas/tck/graph/{RelationshipGraphFactoryTCK.java => fac/RelationshipGraphFactory_OpenStoreDeleteReopenTCK.java} (85%) create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_ConnectOutOfOrderTCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_ConnectWParentInterTCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_NullPathOnTargetExprVersionTCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java rename tck/src/main/java/org/commonjava/maven/atlas/tck/graph/{SubGraphSelectionTCK.java => selection/SubGraphSelection_ContextualToViewTCK.java} (55%) create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/testutil/TCKDriver.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/AncestryTraversalTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/TransitiveDependencyTraversalTCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_EmptyGrandparentRels_TCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_TwoAncestors_TCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/AbstractBuildOrderTCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDepTCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDep_ExtMgmtTCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferDirectTCK.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferLocalTCK.java diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java index 1b7d4c94..8b1ced86 100644 --- a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java @@ -265,7 +265,7 @@ public ProjectRelationship deserialize( final JsonParser jp, final Deserializati // handle null implicitly by comparing to true. boolean managed = Boolean.TRUE.equals( ast.get( MANAGED ) ); - ProjectRelationship rel = null; + ProjectRelationship rel = null; switch ( type ) { case DEPENDENCY: @@ -283,7 +283,7 @@ public ProjectRelationship deserialize( final JsonParser jp, final Deserializati scope = DependencyScope.getScope( scp ); } - rel = new DependencyRelationship( sources, pomLocation, declaring, target, scope, index, + rel = new SimpleDependencyRelationship( sources, pomLocation, declaring, target, scope, index, managed ); break; } @@ -291,14 +291,14 @@ public ProjectRelationship deserialize( final JsonParser jp, final Deserializati { final ProjectVersionRef target = SimpleProjectVersionRef.parse( tgt ); - rel = new ExtensionRelationship( sources, pomLocation, declaring, target, index ); + rel = new SimpleExtensionRelationship( sources, pomLocation, declaring, target, index ); break; } case PARENT: { final ProjectVersionRef target = SimpleProjectVersionRef.parse( tgt ); - rel = new ParentRelationship( sources, declaring, target ); + rel = new SimpleParentRelationship( sources, declaring, target ); break; } case PLUGIN: @@ -306,7 +306,7 @@ public ProjectRelationship deserialize( final JsonParser jp, final Deserializati final ProjectVersionRef target = SimpleProjectVersionRef.parse( tgt ); Boolean report = (Boolean) ast.get( REPORTING ); - rel = new PluginRelationship( sources, pomLocation, declaring, target, index, + rel = new SimplePluginRelationship( sources, pomLocation, declaring, target, index, managed, Boolean.TRUE.equals(report) ); break; } @@ -323,7 +323,7 @@ public ProjectRelationship deserialize( final JsonParser jp, final Deserializati final ProjectRef plugin = SimpleProjectRef.parse( plug ); final ArtifactRef target = SimpleArtifactRef.parse( tgt ); - rel = new PluginDependencyRelationship( sources, pomLocation, declaring, plugin, target, index, + rel = new SimplePluginDependencyRelationship( sources, pomLocation, declaring, plugin, target, index, managed ); break; } @@ -331,7 +331,7 @@ public ProjectRelationship deserialize( final JsonParser jp, final Deserializati { final ProjectVersionRef target = SimpleProjectVersionRef.parse( tgt ); - rel = new BomRelationship( sources, pomLocation, declaring, target, index ); + rel = new SimpleBomRelationship( sources, pomLocation, declaring, target, index ); break; } } diff --git a/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java b/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java index 7b8d43dd..3ee0a34e 100644 --- a/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java +++ b/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java @@ -16,9 +16,7 @@ package org.commonjava.maven.atlas.graph.jackson; import com.fasterxml.jackson.databind.ObjectMapper; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.*; import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.DependencyScope; import org.commonjava.maven.atlas.ident.jackson.ProjectVersionRefSerializerModule; @@ -50,12 +48,12 @@ public void before() public void roundTrip_TerminalParentRelationship() throws Exception { - ParentRelationship rel = new ParentRelationship( new SimpleProjectVersionRef( "org.foo", "bar", "1" ) ); + ParentRelationship rel = new SimpleParentRelationship( new SimpleProjectVersionRef( "org.foo", "bar", "1" ) ); String json = mapper.writeValueAsString( rel ); System.out.println( json ); - ProjectRelationship result = mapper.readValue( json, ProjectRelationship.class ); + ProjectRelationship result = mapper.readValue( json, ProjectRelationship.class ); assertThat( (ParentRelationship) result, equalTo( rel ) ); } @@ -64,14 +62,14 @@ public void roundTrip_TerminalParentRelationship() public void roundTrip_ParentRelationship() throws Exception { - ParentRelationship rel = new ParentRelationship( URI.create( "some:test:location" ), + ParentRelationship rel = new SimpleParentRelationship( URI.create( "some:test:location" ), new SimpleProjectVersionRef( "org.foo", "bar", "1" ), new SimpleProjectVersionRef( "org.foo", "parent", "1001" ) ); String json = mapper.writeValueAsString( rel ); System.out.println( json ); - ProjectRelationship result = mapper.readValue( json, ProjectRelationship.class ); + ProjectRelationship result = mapper.readValue( json, ProjectRelationship.class ); assertThat( (ParentRelationship) result, equalTo( rel ) ); } @@ -81,7 +79,7 @@ public void roundTrip_SimpleConcreteDependency() throws Exception { DependencyRelationship rel = - new DependencyRelationship( URI.create( "some:test:location" ), RelationshipUtils.POM_ROOT_URI, + new SimpleDependencyRelationship( URI.create( "some:test:location" ), RelationshipUtils.POM_ROOT_URI, new SimpleProjectVersionRef( "org.foo", "bar", "1" ), new SimpleProjectVersionRef( "org.foo", "dep", "1.1" ).asJarArtifact(), DependencyScope.compile, 0, false ); @@ -89,7 +87,7 @@ public void roundTrip_SimpleConcreteDependency() String json = mapper.writeValueAsString( rel ); System.out.println( json ); - ProjectRelationship result = mapper.readValue( json, ProjectRelationship.class ); + ProjectRelationship result = mapper.readValue( json, ProjectRelationship.class ); assertThat( (DependencyRelationship) result, equalTo( rel ) ); } diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTraversal.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTraversal.java index eed018d6..b36cb9bd 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTraversal.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTraversal.java @@ -33,9 +33,9 @@ final class CycleDetectionTraversal { private final List cycles = new ArrayList(); - private final ProjectRelationship rel; + private final ProjectRelationship rel; - CycleDetectionTraversal( final ProjectRelationship rel ) + CycleDetectionTraversal( final ProjectRelationship rel ) { this.rel = rel; } @@ -46,7 +46,7 @@ public List getCycles() } @Override - public boolean preCheck( final ProjectRelationship relationship, final List> path ) + public boolean preCheck( final ProjectRelationship relationship, final List> path ) { if ( rel.getDeclaring() .equals( rel.getTarget() @@ -63,7 +63,7 @@ public boolean preCheck( final ProjectRelationship relationship, final List

> cycle = new ArrayList>( path ); + final List> cycle = new ArrayList>( path ); cycle.add( rel ); cycles.add( new EProjectCycle( cycle ) ); diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java index 461442f6..b89415af 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java @@ -25,10 +25,7 @@ import org.commonjava.maven.atlas.graph.model.EProjectCycle; import org.commonjava.maven.atlas.graph.model.GraphPath; import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipComparator; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.graph.rel.*; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; import org.commonjava.maven.atlas.graph.spi.jung.model.JungGraphPath; @@ -56,8 +53,8 @@ public class JungGraphConnection private boolean closed = false; - private DirectedGraph> graph = - new DirectedSparseMultigraph>(); + private DirectedGraph> graph = + new DirectedSparseMultigraph>(); private final Map> byGA = new HashMap>(); @@ -82,37 +79,37 @@ public JungGraphConnection( final String workspaceId ) } @Override - public Collection> getRelationshipsDeclaredBy( final ViewParams params, + public Collection> getRelationshipsDeclaredBy( final ViewParams params, final ProjectVersionRef ref ) { return imposeSelections( params, graph.getOutEdges( ref.asProjectVersionRef() ) ); } @Override - public Collection> getRelationshipsTargeting( final ViewParams params, + public Collection> getRelationshipsTargeting( final ViewParams params, final ProjectVersionRef ref ) { return imposeSelections( params, graph.getInEdges( ref.asProjectVersionRef() ) ); } @Override - public Collection> getAllRelationships( final ViewParams params ) + public Collection> getAllRelationships( final ViewParams params ) { return imposeSelections( params, graph.getEdges() ); } - private Collection> imposeSelections( final ViewParams params, - final Collection> edges ) + private Collection> imposeSelections( final ViewParams params, + final Collection> edges ) { if ( edges == null || edges.isEmpty() ) { return edges; } - final List> result = new ArrayList>( edges.size() ); - for ( final ProjectRelationship edge : edges ) + final List> result = new ArrayList>( edges.size() ); + for ( final ProjectRelationship edge : edges ) { - if ( ( edge instanceof ParentRelationship ) && ( (ParentRelationship) edge ).isTerminus() ) + if ( ( edge instanceof SimpleParentRelationship ) && ( (ParentRelationship) edge ).isTerminus() ) { continue; } @@ -180,10 +177,10 @@ private Collection> imposeSelections( final ViewParams pa } @Override - public Set> addRelationships( final ProjectRelationship... rels ) + public Set> addRelationships( final ProjectRelationship... rels ) { - final Set> skipped = new HashSet>(); - for ( final ProjectRelationship rel : rels ) + final Set> skipped = new HashSet>(); + for ( final ProjectRelationship rel : rels ) { if ( !graph.containsVertex( rel.getDeclaring() ) ) { @@ -194,10 +191,10 @@ public Set> addRelationships( final ProjectRelationship> edges = - new ArrayList>( graph.findEdgeSet( rel.getDeclaring(), target ) ); + final List> edges = + new ArrayList>( graph.findEdgeSet( rel.getDeclaring(), target ) ); if ( !edges.contains( rel ) ) { // logger.info( "Adding edge: %s -> %s", rel.getDeclaring(), target ); @@ -223,7 +220,7 @@ else if ( !graph.containsVertex( target ) ) else { final int idx = edges.indexOf( rel ); - final ProjectRelationship existing = edges.get( idx ); + final ProjectRelationship existing = edges.get( idx ); // logger.info( "Adding sources: %s to existing edge: %s", rel.getSources(), existing ); @@ -234,7 +231,7 @@ else if ( !graph.containsVertex( target ) ) incompleteSubgraphs.remove( rel.getDeclaring() ); } - for ( final ProjectRelationship rel : rels ) + for ( final ProjectRelationship rel : rels ) { if ( skipped.contains( rel ) ) { @@ -278,7 +275,7 @@ private boolean addGA( final ProjectVersionRef ref ) } @Override - public Set>> getAllPathsTo( final ViewParams params, final ProjectVersionRef... refs ) + public Set>> getAllPathsTo( final ViewParams params, final ProjectVersionRef... refs ) { final PathDetectionTraversal traversal = new PathDetectionTraversal( this, params, refs ); @@ -297,7 +294,7 @@ public Set>> getAllPathsTo( final ViewParams params, } final Set paths = traversal.getPaths(); - final Set>> result = new HashSet>>( paths.size() ); + final Set>> result = new HashSet>>( paths.size() ); for ( final JungGraphPath path : paths ) { result.add( path.getPathElements() ); @@ -307,7 +304,7 @@ public Set>> getAllPathsTo( final ViewParams params, } @Override - public boolean introducesCycle( final ViewParams params, final ProjectRelationship rel ) + public boolean introducesCycle( final ViewParams params, final ProjectRelationship rel ) { final CycleDetectionTraversal traversal = new CycleDetectionTraversal( rel ); @@ -359,24 +356,24 @@ private void dfsIterate( final ViewParams params, final ProjectVersionRef node, final RelationshipGraphTraversal traversal, final JungGraphPath path, final GraphPathInfo pathInfo ) { - final List> edges = getSortedOutEdges( params, node ); + final List> edges = getSortedOutEdges( params, node ); if ( edges != null ) { - for ( final ProjectRelationship edge : edges ) + for ( final ProjectRelationship edge : edges ) { - final ProjectRelationship realEdge = pathInfo.selectRelationship( edge, path ); + final ProjectRelationship realEdge = pathInfo.selectRelationship( edge, path ); if ( realEdge == null ) { continue; } final JungGraphPath next = new JungGraphPath( path, realEdge ); - final List> pathElements = next.getPathElements(); + final List> pathElements = next.getPathElements(); if ( traversal.traverseEdge( realEdge, pathElements ) ) { final GraphPathInfo nextInfo = pathInfo.getChildPathInfo( realEdge ); - if ( !( edge instanceof ParentRelationship ) || !( (ParentRelationship) edge ).isTerminus() ) + if ( !( edge instanceof SimpleParentRelationship ) || !( (ParentRelationship) edge ).isTerminus() ) { if ( next.hasCycle() ) { @@ -420,18 +417,18 @@ private void bfsIterate( final ViewParams params, final Map> edges = getSortedOutEdges( params, node ); + final List> edges = getSortedOutEdges( params, node ); if ( edges != null ) { - for ( final ProjectRelationship edge : edges ) + for ( final ProjectRelationship edge : edges ) { - final ProjectRelationship realEdge = pathInfo.selectRelationship( edge, path ); + final ProjectRelationship realEdge = pathInfo.selectRelationship( edge, path ); if ( realEdge == null ) { continue; } - final List> pathElements = path.getPathElements(); + final List> pathElements = path.getPathElements(); // call traverseEdge no matter what, to allow traversal to "see" all relationships. if ( traversal.traverseEdge( realEdge, pathElements ) ) { @@ -439,7 +436,7 @@ private void bfsIterate( final ViewParams params, final Map> getSortedOutEdges( final ViewParams params, final ProjectVersionRef node ) + private List> getSortedOutEdges( final ViewParams params, final ProjectVersionRef node ) { - Collection> unsorted = graph.getOutEdges( node.asProjectVersionRef() ); + Collection> unsorted = graph.getOutEdges( node.asProjectVersionRef() ); if ( unsorted == null ) { return null; } - unsorted = new ArrayList>( unsorted ); + unsorted = new ArrayList>( unsorted ); RelationshipUtils.filterTerminalParents( unsorted ); - final List> sorted = - new ArrayList>( imposeSelections( params, unsorted ) ); + final List> sorted = + new ArrayList>( imposeSelections( params, unsorted ) ); Collections.sort( sorted, RelationshipComparator.INSTANCE ); return sorted; @@ -511,17 +508,17 @@ public boolean containsProject( final ViewParams params, final ProjectVersionRef } @Override - public boolean containsRelationship( final ViewParams params, final ProjectRelationship rel ) + public boolean containsRelationship( final ViewParams params, final ProjectRelationship rel ) { return graph.containsEdge( rel ); } public void restrictProjectMembership( final Collection refs ) { - final Set> rels = new HashSet>(); + final Set> rels = new HashSet>(); for ( final ProjectVersionRef ref : refs ) { - final Collection> edges = graph.getOutEdges( ref.asProjectVersionRef() ); + final Collection> edges = graph.getOutEdges( ref.asProjectVersionRef() ); if ( edges != null ) { rels.addAll( edges ); @@ -531,13 +528,13 @@ public void restrictProjectMembership( final Collection refs restrictRelationshipMembership( rels ); } - public void restrictRelationshipMembership( final Collection> rels ) + public void restrictRelationshipMembership( final Collection> rels ) { - graph = new DirectedSparseMultigraph>(); + graph = new DirectedSparseMultigraph>(); incompleteSubgraphs.clear(); variableSubgraphs.clear(); - addRelationships( rels.toArray( new ProjectRelationship[rels.size()] ) ); + addRelationships( rels.toArray( new ProjectRelationship[rels.size()] ) ); recomputeIncompleteSubgraphs(); } @@ -577,6 +574,14 @@ public boolean hasMissingProjects( final ViewParams params ) public Set getMissingProjects( final ViewParams params ) { final Set result = new HashSet( incompleteSubgraphs ); + for ( ProjectVersionRef ref: variableSubgraphs ) + { + ProjectVersionRef selected = params.getSelection( ref ); + if ( selected != null && !containsProject( params, selected ) ) + { + result.add( selected ); + } + } // logger.info( "Got %d missing projects: %s", result.size(), result ); return result; } @@ -590,7 +595,20 @@ public boolean hasVariableProjects( final ViewParams params ) @Override public Set getVariableProjects( final ViewParams params ) { - return new HashSet( variableSubgraphs ); + Set refs = new HashSet( variableSubgraphs ); + for ( Iterator iter = refs.iterator(); iter.hasNext(); ) + { + ProjectVersionRef gav = iter.next(); + logger.debug("Checking for selection of: {}", gav); + if ( params.hasSelection( gav ) ) + { + logger.debug( "Removing variable GAV: {}", gav ); + iter.remove(); + } + } + + logger.debug( "Resulting variable set: {}", refs ); + return refs; } @Override @@ -602,7 +620,7 @@ public boolean addCycle( final EProjectCycle cycle ) changed = this.cycles.add( cycle ); } - for ( final ProjectRelationship rel : cycle ) + for ( final ProjectRelationship rel : cycle ) { incompleteSubgraphs.remove( rel.getDeclaring() ); } @@ -625,7 +643,7 @@ public Set getCycles( final ViewParams params ) final ProjectRelationshipFilter filter = params.getFilter(); nextCycle: for ( final EProjectCycle cycle : cycles ) { - for ( final ProjectRelationship r : cycle ) + for ( final ProjectRelationship r : cycle ) { if ( !filter.accept( r ) ) { @@ -641,7 +659,7 @@ public Set getCycles( final ViewParams params ) } @Override - public boolean isCycleParticipant( final ViewParams params, final ProjectRelationship rel ) + public boolean isCycleParticipant( final ViewParams params, final ProjectRelationship rel ) { for ( final EProjectCycle cycle : cycles ) { @@ -677,7 +695,7 @@ public void recomputeIncompleteSubgraphs() for ( final ProjectVersionRef vertex : getAllProjects( params ) ) { - final Collection> outEdges = getRelationshipsDeclaredBy( params, vertex ); + final Collection> outEdges = getRelationshipsDeclaredBy( params, vertex ); if ( outEdges != null && !outEdges.isEmpty() ) { incompleteSubgraphs.remove( vertex ); @@ -884,7 +902,7 @@ public void addDisconnectedProject( final ProjectVersionRef ref ) @Deprecated @Override - public Set> getDirectRelationshipsFrom( final ViewParams params, + public Set> getDirectRelationshipsFrom( final ViewParams params, final ProjectVersionRef from, final boolean includeManagedInfo, final RelationshipType... types ) @@ -893,7 +911,7 @@ public Set> getDirectRelationshipsFrom( final ViewParams } @Override - public Set> getDirectRelationshipsFrom( final ViewParams params, + public Set> getDirectRelationshipsFrom( final ViewParams params, final ProjectVersionRef from, final boolean includeManagedInfo, final boolean includeConcreteInfo, @@ -903,7 +921,7 @@ public Set> getDirectRelationshipsFrom( final ViewParams includeConcreteInfo, types ); } - private Set> getMatchingRelationships( final Collection> edges, + private Set> getMatchingRelationships( final Collection> edges, final ViewParams params, final boolean includeManagedInfo, final boolean includeConcreteInfo, @@ -916,12 +934,12 @@ private Set> getMatchingRelationships( final Collection

> rels = new HashSet>( edges.size() ); + final Set> rels = new HashSet>( edges.size() ); final List typeList = Arrays.asList( types ); Collections.sort( typeList ); - for ( final ProjectRelationship rel : edges ) + for ( final ProjectRelationship rel : edges ) { if ( !typeList.isEmpty() && !typeList.contains( rel.getType() ) ) { @@ -957,7 +975,7 @@ private Set> getMatchingRelationships( final Collection

> getDirectRelationshipsTo( final ViewParams params, final ProjectVersionRef to, + public Set> getDirectRelationshipsTo( final ViewParams params, final ProjectVersionRef to, final boolean includeManagedInfo, final RelationshipType... types ) { @@ -965,7 +983,7 @@ public Set> getDirectRelationshipsTo( final ViewParams pa } @Override - public Set> getDirectRelationshipsTo( final ViewParams params, final ProjectVersionRef to, + public Set> getDirectRelationshipsTo( final ViewParams params, final ProjectVersionRef to, final boolean includeManagedInfo, final boolean includeConcreteInfo, final RelationshipType... types ) @@ -986,10 +1004,10 @@ public Set getProjectsMatching( final ViewParams params, fina public void deleteRelationshipsDeclaredBy( final ProjectVersionRef ref ) throws RelationshipGraphConnectionException { - final Collection> edges = graph.getOutEdges( ref.asProjectVersionRef() ); + final Collection> edges = graph.getOutEdges( ref.asProjectVersionRef() ); if ( edges != null ) { - for ( final ProjectRelationship rel : edges ) + for ( final ProjectRelationship rel : edges ) { graph.removeEdge( rel ); } @@ -1024,10 +1042,10 @@ public ProjectVersionRef getManagedTargetFor( final ProjectVersionRef target, fi final ProjectRef targetGA = target.asProjectRef(); final JungGraphPath jungpath = (JungGraphPath) path; - for ( final ProjectRelationship ref : jungpath ) + for ( final ProjectRelationship ref : jungpath ) { - final Collection> outEdges = graph.getOutEdges( ref.getDeclaring() ); - for ( final ProjectRelationship edge : outEdges ) + final Collection> outEdges = graph.getOutEdges( ref.getDeclaring() ); + for ( final ProjectRelationship edge : outEdges ) { if ( edge.isManaged() && type == edge.getType() && targetGA.equals( edge.getTarget() ) ) { @@ -1041,7 +1059,7 @@ public ProjectVersionRef getManagedTargetFor( final ProjectVersionRef target, fi } @Override - public GraphPath createPath( final ProjectRelationship... rels ) + public GraphPath createPath( final ProjectRelationship... rels ) { if ( rels.length > 0 ) { @@ -1060,7 +1078,7 @@ public GraphPath createPath( final ProjectRelationship... rels ) } @Override - public GraphPath createPath( final GraphPath parent, final ProjectRelationship child ) + public GraphPath createPath( final GraphPath parent, final ProjectRelationship child ) { try { @@ -1150,7 +1168,7 @@ public List getPathRefs( final ViewParams params, final Graph final JungGraphPath gp = (JungGraphPath) path; final List refs = new ArrayList(); - for ( final ProjectRelationship rel : gp ) + for ( final ProjectRelationship rel : gp ) { if ( refs.isEmpty() ) { diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java index 94ce25b2..cd97e430 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java @@ -73,7 +73,7 @@ public Set getPaths() } @Override - public boolean preCheck( final ProjectRelationship relationship, final List> path ) + public boolean preCheck( final ProjectRelationship relationship, final List> path ) { JungGraphPath jpath; GraphPathInfo pathInfo; @@ -93,7 +93,7 @@ public boolean preCheck( final ProjectRelationship relationship, final List

selected = pathInfo.selectRelationship( relationship, jpath ); + final ProjectRelationship selected = pathInfo.selectRelationship( relationship, jpath ); if ( selected == null ) { return false; diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/model/JungGraphPath.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/model/JungGraphPath.java index c1da9701..61f1da6d 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/model/JungGraphPath.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/model/JungGraphPath.java @@ -29,45 +29,45 @@ import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; public class JungGraphPath - implements GraphPath> + implements GraphPath> { - private final ProjectRelationship[] rels; + private final ProjectRelationship[] rels; private final ProjectVersionRef root; public JungGraphPath( final ProjectVersionRef root ) { this.root = root; - this.rels = new ProjectRelationship[] {}; + this.rels = new ProjectRelationship[] {}; } - public JungGraphPath( final ProjectRelationship... rels ) + public JungGraphPath( final ProjectRelationship... rels ) { this.root = null; this.rels = rels; } - public JungGraphPath( final JungGraphPath parent, final ProjectRelationship child ) + public JungGraphPath( final JungGraphPath parent, final ProjectRelationship child ) { this.root = null; if ( parent == null ) { - rels = new ProjectRelationship[] { child }; + rels = new ProjectRelationship[] { child }; } else { final int parentLen = parent.rels.length; - this.rels = new ProjectRelationship[parentLen + 1]; + this.rels = new ProjectRelationship[parentLen + 1]; System.arraycopy( parent.rels, 0, this.rels, 0, parentLen ); this.rels[parentLen] = child; } } - public JungGraphPath( final List> path ) + public JungGraphPath( final List> path ) { this.root = null; - this.rels = path.toArray( new ProjectRelationship[path.size()] ); + this.rels = path.toArray( new ProjectRelationship[path.size()] ); } public ProjectVersionRef getTargetGAV() @@ -114,9 +114,9 @@ public boolean equals( final Object obj ) } @Override - public Iterator> iterator() + public Iterator> iterator() { - return new Iterator>() + return new Iterator>() { private int next = 0; @@ -127,7 +127,7 @@ public boolean hasNext() } @Override - public ProjectRelationship next() + public ProjectRelationship next() { return rels[next++]; } @@ -140,9 +140,9 @@ public void remove() }; } - public List> getPathElements() + public List> getPathElements() { - return rels.length == 0 ? Collections.> emptyList() : Arrays.asList( rels ); + return rels.length == 0 ? Collections.> emptyList() : Arrays.asList( rels ); } public boolean hasCycle() @@ -153,7 +153,7 @@ public boolean hasCycle() } final Set declared = new HashSet( rels.length ); - for ( final ProjectRelationship item : rels ) + for ( final ProjectRelationship item : rels ) { // NOTE: order is important here, in case it's a terminal parent relationship. if ( declared.contains( item.getTarget() diff --git a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTest.java b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTest.java deleted file mode 100644 index 4f43ed8e..00000000 --- a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.jung; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.tck.graph.CycleDetectionTCK; - -public class CycleDetectionTest - extends CycleDetectionTCK -{ - private final JungGraphConnectionFactory connFac = new JungGraphConnectionFactory(); - - @Override - protected RelationshipGraphConnectionFactory connectionFactory() - throws Exception - { - return connFac; - } - -} diff --git a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/RelationshipGraphConnectionTest.java b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/RelationshipGraphConnectionTest.java deleted file mode 100644 index 2c4d28e6..00000000 --- a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/RelationshipGraphConnectionTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.jung; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.tck.graph.RelationshipGraphConnection_TCK; - -public class RelationshipGraphConnectionTest - extends RelationshipGraphConnection_TCK -{ - private final JungGraphConnectionFactory connFac = new JungGraphConnectionFactory(); - - @Override - protected RelationshipGraphConnectionFactory connectionFactory() - throws Exception - { - return connFac; - } - -} diff --git a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/RelationshipGraphTest.java b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/RelationshipGraphTest.java deleted file mode 100644 index 271aaa40..00000000 --- a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/RelationshipGraphTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.jung; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.tck.graph.RelationshipGraphTCK; - -public class RelationshipGraphTest - extends RelationshipGraphTCK -{ - - private final JungGraphConnectionFactory connFac = new JungGraphConnectionFactory(); - - @Override - protected RelationshipGraphConnectionFactory connectionFactory() - throws Exception - { - return connFac; - } - -} diff --git a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/SubGraphSelectionTest.java b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/SubGraphSelectionTest.java deleted file mode 100644 index 1114ea7f..00000000 --- a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/SubGraphSelectionTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.jung; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.tck.graph.RelationshipGraphTCK; - -public class SubGraphSelectionTest - extends RelationshipGraphTCK -{ - private final JungGraphConnectionFactory connFac = new JungGraphConnectionFactory(); - - @Override - protected RelationshipGraphConnectionFactory connectionFactory() - throws Exception - { - return connFac; - } - -} diff --git a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/AncestryTraversalTest.java b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/AncestryTraversalTest.java deleted file mode 100644 index fb0c554f..00000000 --- a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/AncestryTraversalTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.jung.traverse; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.graph.spi.jung.JungGraphConnectionFactory; -import org.commonjava.maven.atlas.tck.graph.traverse.AncestryTraversalTCK; - -public class AncestryTraversalTest - extends AncestryTraversalTCK -{ - private final JungGraphConnectionFactory connFac = new JungGraphConnectionFactory(); - - @Override - protected RelationshipGraphConnectionFactory connectionFactory() - throws Exception - { - return connFac; - } - -} diff --git a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/BuildOrderTraversalTest.java b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/BuildOrderTraversalTest.java deleted file mode 100644 index 222b030f..00000000 --- a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/BuildOrderTraversalTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.jung.traverse; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.graph.spi.jung.JungGraphConnectionFactory; -import org.commonjava.maven.atlas.tck.graph.traverse.BuildOrderTraversalTCK; - -public class BuildOrderTraversalTest - extends BuildOrderTraversalTCK -{ - private final JungGraphConnectionFactory connFac = new JungGraphConnectionFactory(); - - @Override - protected RelationshipGraphConnectionFactory connectionFactory() - throws Exception - { - return connFac; - } - -} diff --git a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/TransitiveDependencyTraversalTest.java b/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/TransitiveDependencyTraversalTest.java deleted file mode 100644 index b7cd9f66..00000000 --- a/drivers/jung/src/test/java/org/commonjava/maven/atlas/graph/spi/jung/traverse/TransitiveDependencyTraversalTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.jung.traverse; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.graph.spi.jung.JungGraphConnectionFactory; -import org.commonjava.maven.atlas.tck.graph.traverse.TransitiveDependencyTraversalTCK; - -public class TransitiveDependencyTraversalTest - extends TransitiveDependencyTraversalTCK -{ - private final JungGraphConnectionFactory connFac = new JungGraphConnectionFactory(); - - @Override - protected RelationshipGraphConnectionFactory connectionFactory() - throws Exception - { - return connFac; - } - -} diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 863901cb..3e126874 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -28,6 +28,11 @@ atlas-driver-neo4j-embedded Atlas :: Maven Project-Graph :: Embedded Neo4J API + + + 1C + true + @@ -38,10 +43,6 @@ commons-codec commons-codec - - com.google.code.gson - gson - org.slf4j log4j-over-slf4j diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java index e6e0f81d..3301fe91 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java @@ -20,13 +20,12 @@ import org.commonjava.maven.atlas.graph.model.EProjectCycle; import org.commonjava.maven.atlas.graph.model.GraphPath; import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipComparator; +import org.commonjava.maven.atlas.graph.rel.*; import org.commonjava.maven.atlas.graph.rel.RelationshipType; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; import org.commonjava.maven.atlas.graph.spi.neo4j.io.ConversionCache; import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.AbstractNeoProjectRelationship; import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; import org.commonjava.maven.atlas.graph.spi.neo4j.traverse.*; @@ -219,7 +218,7 @@ public void printStats() } @Override - public Collection> getRelationshipsDeclaredBy( final ViewParams params, + public Collection> getRelationshipsDeclaredBy( final ViewParams params, final ProjectVersionRef ref ) { checkClosed(); @@ -253,7 +252,7 @@ private synchronized void checkClosed() } @Override - public Collection> getRelationshipsTargeting( final ViewParams params, + public Collection> getRelationshipsTargeting( final ViewParams params, final ProjectVersionRef ref ) { checkClosed(); @@ -278,12 +277,12 @@ public Collection> getRelationshipsTargeting( f final RelationshipIndex cachedRels = new ViewIndexes( graph.index(), params ).getCachedRelationships(); final IndexHits hits = cachedRels.query( RID, sb.toString() ); - final Set> result = new HashSet>(); + final Set> result = new HashSet>(); while ( hits.hasNext() ) { final Relationship r = hits.next(); - final ProjectRelationship rel = toProjectRelationship( r, cache ); + final ProjectRelationship rel = toProjectRelationship( r, cache ); result.add( rel ); } @@ -369,7 +368,7 @@ private void updateView( final ViewParams params, final ConversionCache cache ) } @Override - public Collection> getAllRelationships( final ViewParams params ) + public Collection> getAllRelationships( final ViewParams params ) { checkClosed(); @@ -379,7 +378,7 @@ public Collection> getAllRelationships( final ViewParams final RelationshipIndex cachedRels = new ViewIndexes( graph.index(), params ).getCachedRelationships(); final IndexHits relHits = cachedRels.query( RID, "*" ); - final Set> rels = new HashSet>(); + final Set> rels = new HashSet>(); while ( relHits.hasNext() ) { rels.add( toProjectRelationship( relHits.next(), cache ) ); @@ -458,7 +457,7 @@ public ProjectVersionRef getPathTargetRef( final GraphPath path ) } @Override - public Set>> getAllPathsTo( final ViewParams params, final ProjectVersionRef... refs ) + public Set>> getAllPathsTo( final ViewParams params, final ProjectVersionRef... refs ) { checkClosed(); if ( !registerView( params ) ) @@ -473,7 +472,7 @@ public Set>> getAllPathsTo( final ViewParams params, final PathCollectingVisitor visitor = new PathCollectingVisitor( endNodes, cache ); collectAtlasRelationships( params, visitor, getRoots( params ), false, Uniqueness.RELATIONSHIP_GLOBAL ); - final Set>> result = new HashSet>>(); + final Set>> result = new HashSet>>(); for ( final Neo4jGraphPath path : visitor ) { result.add( convertToRelationships( path, adminAccess, cache ) ); @@ -483,15 +482,15 @@ public Set>> getAllPathsTo( final ViewParams params, } @Override - public synchronized Set> addRelationships( final ProjectRelationship... rels ) + public synchronized Set> addRelationships( final ProjectRelationship... rels ) { - final Map> createdRelationshipsMap = addRelationshipsInternal( rels ); + final Map> createdRelationshipsMap = addRelationshipsInternal( rels ); logger.info( "Updating all-projects caches with {} new entries", createdRelationshipsMap.size() ); updateCaches( createdRelationshipsMap ); // FIXME: We're delaying cycle detection, so there will NEVER be rejected relationships... - final Set> skipped = Collections.emptySet(); + final Set> skipped = Collections.emptySet(); logger.debug( "Cycle injection detected for: {}", skipped ); logger.info( "Returning {} rejected relationships.", skipped.size() ); @@ -500,22 +499,28 @@ public synchronized Set> addRelationships( final ProjectR return skipped; } - private Map> addRelationshipsInternal( final ProjectRelationship... rels ) + private Map> addRelationshipsInternal( final ProjectRelationship... rels ) { checkClosed(); final ConversionCache cache = new ConversionCache(); - final Map> createdRelationshipsMap = new HashMap>(); + final Map> createdRelationshipsMap = new HashMap>(); - final List> sorted = new ArrayList>( Arrays.asList( rels ) ); + final List> sorted = new ArrayList>( Arrays.asList( rels ) ); Collections.sort( sorted, RelationshipComparator.INSTANCE ); final Transaction tx = graph.beginTx(); try { // int txBatchCount = 0; - nextRel: for ( final ProjectRelationship rel : sorted ) + nextRel: for ( final ProjectRelationship rel : sorted ) { + if ( (rel instanceof AbstractNeoProjectRelationship ) && !( (AbstractNeoProjectRelationship) rel ).isDirty()) + { + logger.debug("Clean Neo4j-backed relationship: {} NOT being added.", rel ); + continue; + } + logger.debug( "Checking relationship: {}", rel ); final Index index = graph.index() @@ -621,7 +626,7 @@ private Map> addRelationshipsInternal( final Projec continue; } - if ( !( rel instanceof ParentRelationship ) || !( (ParentRelationship) rel ).isTerminus() ) + if ( !( rel instanceof SimpleParentRelationship ) || !( (ParentRelationship) rel ).isTerminus() ) { createdRelationshipsMap.put( relationship.getId(), rel ); } @@ -659,7 +664,7 @@ private Map> addRelationshipsInternal( final Projec } @Override - public boolean introducesCycle( final ViewParams params, final ProjectRelationship rel ) + public boolean introducesCycle( final ViewParams params, final ProjectRelationship rel ) { checkClosed(); @@ -728,14 +733,14 @@ private Relationship select( final Relationship old, final ViewParams params, fi return graph.getRelationshipById( targetRid ); } - final ProjectRelationship oldRel = toProjectRelationship( old, null ); + final ProjectRelationship oldRel = toProjectRelationship( old, null ); if ( oldRel == null ) { return null; } logger.debug( "Selecting mutated relationship for: {} with pathInfo: {}", oldRel, pathInfo ); - final ProjectRelationship selected = pathInfo == null ? oldRel : pathInfo.selectRelationship( oldRel, path ); + final ProjectRelationship selected = pathInfo == null ? oldRel : pathInfo.selectRelationship( oldRel, path ); if ( selected == null ) { @@ -752,12 +757,12 @@ private Relationship select( final Relationship old, final ViewParams params, fi return result; } - logger.info( "Creating ad-hoc db relationship for selection: {} (replacing: {})", selected, oldRel ); + logger.debug( "Creating ad-hoc db relationship for selection: {} (replacing: {})", selected, oldRel ); @SuppressWarnings( "unused" ) - final Map> added = addRelationshipsInternal( selected ); + final Map> added = addRelationshipsInternal( selected ); - final Transaction tx = graph.beginTx(); +// final Transaction tx = graph.beginTx(); try { result = getRelationship( selId ); @@ -775,13 +780,13 @@ private Relationship select( final Relationship old, final ViewParams params, fi .getId() ); } - tx.success(); +// tx.success(); return result; } finally { - tx.finish(); +// tx.finish(); } } @@ -860,25 +865,35 @@ public void traverse( final RelationshipGraphTraversal traversal, final ProjectV description = description.expand( checker ) .evaluator( checker ); - final Traverser traverser = description.traverse( rootNode ); - for ( final Path path : traverser ) + Transaction tx = this.graph.beginTx(); + try { - if ( path.lastRelationship() == null ) + final Traverser traverser = description.traverse( rootNode ); + for ( final Path path : traverser ) { - continue; - } + if ( path.lastRelationship() == null ) + { + continue; + } - final List> rels = convertToRelationships( path.relationships(), cache ); - logger.debug( "traversing path: {}", rels ); - for ( final ProjectRelationship rel : rels ) - { - logger.debug( "traverse: {}", rel ); - if ( traversal.traverseEdge( rel, rels ) ) + final List> rels = convertToRelationships( path.relationships(), cache ); + logger.debug( "traversing path: {}", rels ); + for ( final ProjectRelationship rel : rels ) { - logger.debug( "traversed: {}", rel ); - traversal.edgeTraversed( rel, rels ); + logger.debug( "traverse: {}", rel ); + if ( traversal.traverseEdge( rel, rels ) ) + { + logger.debug( "traversed: {}", rel ); + traversal.edgeTraversed( rel, rels ); + } } } + + tx.success(); + } + finally + { + tx.finish(); } traversal.endTraverse( graph ); @@ -918,7 +933,7 @@ public boolean containsProject( final ViewParams params, final ProjectVersionRef } @Override - public boolean containsRelationship( final ViewParams params, final ProjectRelationship rel ) + public boolean containsRelationship( final ViewParams params, final ProjectRelationship rel ) { checkClosed(); @@ -990,7 +1005,7 @@ protected Node getNode( final ProjectVersionRef ref ) return node; } - protected Relationship getRelationship( final ProjectRelationship rel ) + protected Relationship getRelationship( final ProjectRelationship rel ) { return getRelationship( id( rel ) ); } @@ -1246,6 +1261,7 @@ private void collectAtlasRelationships( final ViewParams params, final TraverseV description = description.expand( checker ) .evaluator( checker ); + Transaction tx = graph.beginTx(); try { final Traverser traverser = description.traverse( start.toArray( new Node[start.size()] ) ); @@ -1255,10 +1271,12 @@ private void collectAtlasRelationships( final ViewParams params, final TraverseV // logger.info( "Aggregating path: {}", path ); // Don't need this, but we need to iterate the traverser. } + tx.success(); } finally { visitor.traverseComplete( checker ); + tx.finish(); } } @@ -1359,10 +1377,10 @@ public Set getCycles( final ViewParams params ) final Set cycles = new HashSet(); for ( final CyclePath cyclicPath : cyclePaths ) { - final List> cycle = new ArrayList>( cyclicPath.length() + 1 ); + final List> cycle = new ArrayList>( cyclicPath.length() + 1 ); for ( final long id : cyclicPath.getRelationshipIds() ) { - ProjectRelationship rel = cache.getRelationship( id ); + ProjectRelationship rel = cache.getRelationship( id ); if ( rel == null ) { final Relationship r = graph.getRelationshipById( id ); @@ -1379,7 +1397,7 @@ public Set getCycles( final ViewParams params ) } @Override - public boolean isCycleParticipant( final ViewParams params, final ProjectRelationship rel ) + public boolean isCycleParticipant( final ViewParams params, final ProjectRelationship rel ) { for ( final EProjectCycle cycle : getCycles( params ) ) { @@ -1522,7 +1540,7 @@ public ExecutionResult executeFrom( final String cypher, final Map rootRel ) + public ExecutionResult executeFrom( final String cypher, final ProjectRelationship rootRel ) throws RelationshipGraphConnectionException { return executeFrom( cypher, null, rootRel ); @@ -1530,7 +1548,7 @@ public ExecutionResult executeFrom( final String cypher, final ProjectRelationsh @Override public ExecutionResult executeFrom( final String cypher, final Map params, - final ProjectRelationship rootRel ) + final ProjectRelationship rootRel ) throws RelationshipGraphConnectionException { if ( cypher.startsWith( "START" ) ) @@ -1704,7 +1722,7 @@ public void addDisconnectedProject( final ProjectVersionRef ref ) @Deprecated @Override - public Set> getDirectRelationshipsFrom( final ViewParams params, + public Set> getDirectRelationshipsFrom( final ViewParams params, final ProjectVersionRef from, final boolean includeManagedInfo, final RelationshipType... types ) @@ -1713,7 +1731,7 @@ public Set> getDirectRelationshipsFrom( final ViewParams } @Override - public Set> getDirectRelationshipsFrom( final ViewParams params, + public Set> getDirectRelationshipsFrom( final ViewParams params, final ProjectVersionRef from, final boolean includeManagedInfo, final boolean includeConcreteInfo, @@ -1744,14 +1762,14 @@ public Set> getDirectRelationshipsFrom( final ViewParams if ( relationships != null ) { - final Set> result = new HashSet>(); + final Set> result = new HashSet>(); final ConversionCache cache = new ConversionCache(); for ( final Relationship r : relationships ) { if ( TraversalUtils.acceptedInView( r, params, cache ) ) { - final ProjectRelationship rel = toProjectRelationship( r, cache ); + final ProjectRelationship rel = toProjectRelationship( r, cache ); if ( rel != null ) { result.add( rel ); @@ -1766,7 +1784,7 @@ public Set> getDirectRelationshipsFrom( final ViewParams } @Override - public Set> getDirectRelationshipsTo( final ViewParams params, final ProjectVersionRef to, + public Set> getDirectRelationshipsTo( final ViewParams params, final ProjectVersionRef to, final boolean includeManagedInfo, final boolean includeConcreteInfo, final RelationshipType... types ) @@ -1809,13 +1827,13 @@ public Set> getDirectRelationshipsTo( final ViewParams pa final ConversionCache cache = new ConversionCache(); if ( relationships != null ) { - final Set> result = new HashSet>(); + final Set> result = new HashSet>(); for ( final Relationship r : relationships ) { logger.debug( "Examining relationship: {}", r ); if ( TraversalUtils.acceptedInView( r, params, cache ) ) { - final ProjectRelationship rel = toProjectRelationship( r, cache ); + final ProjectRelationship rel = toProjectRelationship( r, cache ); if ( rel != null ) { result.add( rel ); @@ -1962,9 +1980,9 @@ public List getPathRefs( final ViewParams params, final Graph final ConversionCache cache = new ConversionCache(); final Neo4jGraphPath gp = (Neo4jGraphPath) path; - final List> rels = convertToRelationships( gp, adminAccess, cache ); + final List> rels = convertToRelationships( gp, adminAccess, cache ); final List refs = new ArrayList( rels.size() + 2 ); - for ( final ProjectRelationship rel : rels ) + for ( final ProjectRelationship rel : rels ) { if ( refs.isEmpty() ) { @@ -1989,7 +2007,7 @@ public List getPathRefs( final ViewParams params, final Graph } @Override - public GraphPath createPath( final ProjectRelationship... rels ) + public GraphPath createPath( final ProjectRelationship... rels ) { if ( rels.length < 1 ) { @@ -2012,7 +2030,7 @@ public GraphPath createPath( final ProjectRelationship... rels ) } @Override - public GraphPath createPath( final GraphPath parent, final ProjectRelationship rel ) + public GraphPath createPath( final GraphPath parent, final ProjectRelationship rel ) { if ( parent != null && !( parent instanceof Neo4jGraphPath ) ) { @@ -2237,7 +2255,7 @@ public void registerViewSelection( final ViewParams params, final ProjectRef ref } } - private void updateCaches( final Map> newRelationships ) + private void updateCaches( final Map> newRelationships ) { if ( newRelationships.isEmpty() ) { @@ -2433,7 +2451,7 @@ public void clearProjectError( final ProjectVersionRef ref ) } @Override - public Set> getDirectRelationshipsTo( final ViewParams params, final ProjectVersionRef to, + public Set> getDirectRelationshipsTo( final ViewParams params, final ProjectVersionRef to, final boolean includeManagedInfo, final RelationshipType... types ) { diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/Neo4JGraphConnection.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/Neo4JGraphConnection.java index 78723d81..9e269954 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/Neo4JGraphConnection.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/Neo4JGraphConnection.java @@ -30,7 +30,7 @@ public interface Neo4JGraphConnection ExecutionResult executeFrom( String cypher, ProjectVersionRef... roots ) throws RelationshipGraphConnectionException; - ExecutionResult executeFrom( String cypher, ProjectRelationship rootRel ) + ExecutionResult executeFrom( String cypher, ProjectRelationship rootRel ) throws RelationshipGraphConnectionException; ExecutionResult execute( String cypher ) @@ -39,7 +39,7 @@ ExecutionResult execute( String cypher ) ExecutionResult executeFrom( String cypher, Map params, ProjectVersionRef... roots ) throws RelationshipGraphConnectionException; - ExecutionResult executeFrom( String cypher, Map params, ProjectRelationship rootRel ) + ExecutionResult executeFrom( String cypher, Map params, ProjectRelationship rootRel ) throws RelationshipGraphConnectionException; ExecutionResult execute( String cypher, Map params ) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/ConversionCache.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/ConversionCache.java index 12ddc29c..0e1c1729 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/ConversionCache.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/ConversionCache.java @@ -28,25 +28,25 @@ public class ConversionCache { - private Map>> relationships; + private Map>> relationships; private Map> gavs; private Map> serializedObjects; - public ProjectRelationship getRelationship( final Relationship rel ) + public ProjectRelationship getRelationship( final Relationship rel ) { return getRelationship( rel.getId() ); } - public ProjectRelationship getRelationship( final long rid ) + public ProjectRelationship getRelationship( final long rid ) { if ( relationships == null ) { return null; } - final WeakReference> reference = relationships.get( rid ); + final WeakReference> reference = relationships.get( rid ); if ( reference == null ) { return null; @@ -55,14 +55,14 @@ public ProjectRelationship getRelationship( final long rid ) return reference.get(); } - public void cache( final Relationship rel, final ProjectRelationship r ) + public void cache( final Relationship rel, final ProjectRelationship r ) { if ( relationships == null ) { - relationships = new HashMap>>(); + relationships = new HashMap>>(); } - relationships.put( rel.getId(), new WeakReference>( r ) ); + relationships.put( rel.getId(), new WeakReference>( r ) ); } public ProjectVersionRef getProjectVersionRef( final Node node ) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java index 23440b59..6fb5fb91 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java @@ -26,34 +26,28 @@ import java.io.ObjectOutputStream; import java.net.URI; import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.IOUtils; import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.rel.BomRelationship; import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; import org.commonjava.maven.atlas.graph.rel.PluginRelationship; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.graph.spi.neo4j.GraphAdmin; import org.commonjava.maven.atlas.graph.spi.neo4j.GraphRelType; import org.commonjava.maven.atlas.graph.spi.neo4j.NodeType; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.*; import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.*; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; import org.neo4j.graphdb.Node; import org.neo4j.graphdb.PropertyContainer; import org.neo4j.graphdb.Relationship; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public final class Conversions { @@ -193,13 +187,13 @@ public static List convertToProjects( final Iterable no return refs; } - public static List> convertToRelationships( final Iterable relationships, + public static List> convertToRelationships( final Iterable relationships, final ConversionCache cache ) { - final List> rels = new ArrayList>(); + final List> rels = new ArrayList>(); for ( final Relationship relationship : relationships ) { - final ProjectRelationship rel = Conversions.toProjectRelationship( relationship, cache ); + final ProjectRelationship rel = Conversions.toProjectRelationship( relationship, cache ); if ( rel != null ) { rels.add( rel ); @@ -209,15 +203,15 @@ public static List> convertToRelationships( final Iterabl return rels; } - public static List> convertToRelationships( final Iterable relationships, + public static List> convertToRelationships( final Iterable relationships, final GraphAdmin admin, final ConversionCache cache ) { - final List> rels = new ArrayList>(); + final List> rels = new ArrayList>(); for ( final Long rid : relationships ) { final Relationship relationship = admin.getRelationship( rid ); - final ProjectRelationship rel = Conversions.toProjectRelationship( relationship, cache ); + final ProjectRelationship rel = Conversions.toProjectRelationship( relationship, cache ); if ( rel != null ) { rels.add( rel ); @@ -229,20 +223,30 @@ public static List> convertToRelationships( final Iterabl public static void toNodeProperties( final ProjectVersionRef ref, final Node node, final boolean connected ) { - final String g = ref.getGroupId(); - final String a = ref.getArtifactId(); - final String v = ref.getVersionString(); + Logger logger = LoggerFactory.getLogger( Conversions.class ); - if ( empty( g ) || empty( a ) || empty( v ) ) + logger.debug( "Adding {} (type: {}) to node: {}", ref, ref.getClass().getSimpleName(), node ); + if ( !( ref instanceof NeoProjectVersionRef ) || ((NeoProjectVersionRef)ref).isDirty() ) { - throw new IllegalArgumentException( String.format( "GAV cannot contain nulls: %s:%s:%s", g, a, v ) ); + final String g = ref.getGroupId(); + final String a = ref.getArtifactId(); + final String v = ref.getVersionString(); + + if ( empty( g ) || empty( a ) || empty( v ) ) + { + throw new IllegalArgumentException( String.format( "GAV cannot contain nulls: %s:%s:%s", g, a, v ) ); + } + + node.setProperty( ARTIFACT_ID, a ); + node.setProperty( GROUP_ID, g ); + + logger.debug( "Setting property: {} with value: {} for node: {}", VERSION, v, node.getId() ); + node.setProperty( VERSION, v ); + + node.setProperty( GAV, ref.toString() ); } node.setProperty( NODE_TYPE, NodeType.PROJECT.name() ); - node.setProperty( ARTIFACT_ID, a ); - node.setProperty( GROUP_ID, g ); - node.setProperty( VERSION, v ); - node.setProperty( GAV, ref.toString() ); if ( ref.isVariableVersion() ) { @@ -250,6 +254,10 @@ public static void toNodeProperties( final ProjectVersionRef ref, final Node nod } markConnected( node, connected ); +// +// logger.debug( "groupId of {} is:\nNeoIdentityUtils: {}\nConversions: {}\nDirect access: {}", node, +// NeoIdentityUtils.getStringProperty( node, GROUP_ID, null, null ), +// getStringProperty( GROUP_ID, node ), node.hasProperty( GROUP_ID ) ? node.getProperty( GROUP_ID ) : null ); } public static boolean isAtlasType( final Relationship rel ) @@ -291,16 +299,7 @@ public static ProjectVersionRef toProjectVersionRef( final Node node, final Conv throw new IllegalArgumentException( "Node " + node.getId() + " is not a project reference." ); } - final String g = getStringProperty( GROUP_ID, node ); - final String a = getStringProperty( ARTIFACT_ID, node ); - final String v = getStringProperty( VERSION, node ); - - if ( empty( g ) || empty( a ) || empty( v ) ) - { - throw new IllegalArgumentException( String.format( "GAV cannot contain nulls: %s:%s:%s", g, a, v ) ); - } - - final ProjectVersionRef result = new SimpleProjectVersionRef( g, a, v ); + final ProjectVersionRef result = new NeoProjectVersionRef( node ); if ( cache != null ) { cache.cache( node, result ); @@ -316,10 +315,13 @@ private static boolean empty( final String val ) } @SuppressWarnings( "incomplete-switch" ) - public static void toRelationshipProperties( final ProjectRelationship rel, final Relationship relationship ) + public static void toRelationshipProperties( final ProjectRelationship rel, final Relationship relationship ) { relationship.setProperty( INDEX, rel.getIndex() ); - relationship.setProperty( SOURCE_URI, toStringArray( rel.getSources() ) ); + String[] srcs = toStringArray( rel.getSources() ); + Logger logger = LoggerFactory.getLogger( Conversions.class ); + logger.debug( "Storing rel: {}\nwith sources: {}\n in property: {}\nRelationship: {}", rel, Arrays.toString(srcs), SOURCE_URI, relationship ); + relationship.setProperty( SOURCE_URI, srcs ); relationship.setProperty( POM_LOCATION_URI, rel.getPomLocation() .toString() ); @@ -399,7 +401,7 @@ public static String[] toStringArray( final Collection sources ) // return toProjectRelationship( rel, null ); // } - public static ProjectRelationship toProjectRelationship( final Relationship rel, final ConversionCache cache ) + public static ProjectRelationship toProjectRelationship( final Relationship rel, final ConversionCache cache ) { if ( rel == null ) { @@ -408,7 +410,7 @@ public static ProjectRelationship toProjectRelationship( final Relationship r if ( cache != null ) { - final ProjectRelationship r = cache.getRelationship( rel ); + final ProjectRelationship r = cache.getRelationship( rel ); if ( r != null ) { return r; @@ -432,79 +434,39 @@ public static ProjectRelationship toProjectRelationship( final Relationship r return null; } - final ProjectVersionRef from = toProjectVersionRef( rel.getStartNode(), cache ); - final ProjectVersionRef to = toProjectVersionRef( rel.getEndNode(), cache ); - final int index = getIntegerProperty( INDEX, rel ); - final Set source = getURISetProperty( SOURCE_URI, rel, UNKNOWN_SOURCE_URI ); - final URI pomLocation = getURIProperty( POM_LOCATION_URI, rel, POM_ROOT_URI ); - - ProjectRelationship result = null; + ProjectRelationship result = null; switch ( mapper.atlasType() ) { case DEPENDENCY: { - final ArtifactRef artifact = toArtifactRef( to, rel ); - final boolean managed = getBooleanProperty( IS_MANAGED, rel ); - final String scopeStr = getStringProperty( SCOPE, rel ); - final DependencyScope scope = DependencyScope.getScope( scopeStr ); - - final String excludeStr = getStringProperty( EXCLUDES, rel ); - final Set excludes = new HashSet(); - if ( excludeStr != null ) - { - final String[] e = excludeStr.split( "\\s*,\\s*" ); - for ( final String ex : e ) - { - final String[] parts = ex.split( ":" ); - if ( parts.length != 2 ) - { - // LOGGER.error( "In: {} -> {} skipping invalid exclude specification: '{}'", from, artifact, ex ); - } - else - { - excludes.add( new SimpleProjectRef( parts[0], parts[1] ) ); - } - } - } - result = - new DependencyRelationship( source, pomLocation, from, artifact, scope, index, managed, - excludes.toArray( new ProjectRef[excludes.size()] ) ); + new NeoDependencyRelationship( rel ); break; } case PLUGIN_DEP: { - final ArtifactRef artifact = toArtifactRef( to, rel ); - final String pa = getStringProperty( PLUGIN_ARTIFACT_ID, rel ); - final String pg = getStringProperty( PLUGIN_GROUP_ID, rel ); - final boolean managed = getBooleanProperty( IS_MANAGED, rel ); - result = - new PluginDependencyRelationship( source, pomLocation, from, new SimpleProjectRef( pg, pa ), artifact, - index, managed ); + new NeoPluginDependencyRelationship( rel ); break; } case PLUGIN: { - final boolean managed = getBooleanProperty( IS_MANAGED, rel ); - final boolean reporting = getBooleanProperty( IS_REPORTING_PLUGIN, rel ); - - result = new PluginRelationship( source, pomLocation, from, to, index, managed, reporting ); + result = new NeoPluginRelationship( rel ); break; } case EXTENSION: { - result = new ExtensionRelationship( source, from, to, index ); + result = new NeoExtensionRelationship( rel ); break; } case BOM: { - result = new BomRelationship( source, from, to, index ); + result = new NeoBomRelationship( rel ); break; } case PARENT: { - result = new ParentRelationship( source, from, to ); + result = new NeoParentRelationship( rel ); break; } default: @@ -523,7 +485,7 @@ public static ProjectRelationship toProjectRelationship( final Relationship r return result; } - public static String id( final ProjectRelationship rel ) + public static String id( final ProjectRelationship rel ) { return DigestUtils.shaHex( rel.toString() ); } @@ -539,13 +501,18 @@ private static ArtifactRef toArtifactRef( final ProjectVersionRef ref, final Rel final String classifier = getStringProperty( CLASSIFIER, rel ); final boolean optional = getBooleanProperty( OPTIONAL, rel ); - return new SimpleArtifactRef( ref, type, classifier, optional ); + return new NeoArtifactRef( ref, new NeoTypeAndClassifier( rel ), optional ); } private static void toRelationshipProperties( final ArtifactRef target, final Relationship relationship ) { relationship.setProperty( OPTIONAL, target.isOptional() ); + + Logger logger = LoggerFactory.getLogger( Conversions.class ); + logger.debug( "Type of artifact: {} (type: {}) is: {}", target, target.getClass().getSimpleName(), + target.getType() ); relationship.setProperty( TYPE, target.getType() ); + if ( target.getClassifier() != null ) { relationship.setProperty( CLASSIFIER, target.getClassifier() ); diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java new file mode 100644 index 00000000..53bf94cf --- /dev/null +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java @@ -0,0 +1,122 @@ +package org.commonjava.maven.atlas.graph.spi.neo4j.model; + +import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; +import org.commonjava.maven.atlas.graph.util.RelationshipUtils; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.neo4j.graphdb.Relationship; + +import java.net.URI; +import java.util.Collection; +import java.util.Set; + +/** + * Created by jdcasey on 8/24/15. + */ +public abstract class AbstractNeoProjectRelationship, I extends ProjectRelationship, T extends ProjectVersionRef> + implements ProjectRelationship +{ + protected Relationship rel; + + private RelationshipType type; + + protected ProjectVersionRef declaring; + + private boolean dirty; + + protected T target; + + protected Set sources; + + protected AbstractNeoProjectRelationship( Relationship rel, RelationshipType type ) + { + this.rel = rel; + this.type = type; + } + + protected R cloneDirtyState( R old ) + { + this.dirty = old.isDirty(); + this.declaring = old.declaring; + this.target = old.target; + this.sources = old.sources; + return (R) this; + } + + protected R withDeclaring( ProjectVersionRef declaring ) + { + this.declaring = declaring; + this.dirty = true; + return (R) this; + } + + protected R withTarget( T target ) + { + this.target = target; + this.dirty = true; + return (R) this; + } + + protected R withSources( Set sources ) + { + this.sources = sources; + this.dirty = true; + return (R) this; + } + + public boolean isDirty() + { + return dirty; + } + + @Override + public synchronized I cloneFor( final ProjectVersionRef projectRef ) + { + return selectDeclaring( projectRef ); + } + + @Override + public int getIndex() + { + return Conversions.getIntegerProperty(Conversions.INDEX, rel); + } + + @Override + public RelationshipType getType() + { + return type; + } + + @Override + public ProjectVersionRef getDeclaring() + { + return declaring == null ? new NeoProjectVersionRef( rel.getStartNode() ) : declaring; + } + + @Override + public ArtifactRef getTargetArtifact() + { + return getTarget().asPomArtifact(); + } + + @Override + public boolean isManaged() + { + return Conversions.getBooleanProperty( Conversions.IS_MANAGED, rel ); + } + + @Override + public Set getSources() + { + return sources == null ? Conversions.getURISetProperty( Conversions.SOURCE_URI, rel, RelationshipUtils.UNKNOWN_SOURCE_URI ) : sources; + } + + @Override + public URI getPomLocation() + { + return Conversions.getURIProperty( Conversions.POM_LOCATION_URI, rel, RelationshipUtils.POM_ROOT_URI ); + } +} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java new file mode 100644 index 00000000..087ddb4e --- /dev/null +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java @@ -0,0 +1,253 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.spi.neo4j.model; + +import static org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoIdentityUtils.getBooleanProperty; +import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.InvalidRefException; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.TypeAndClassifier; +import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; +import org.commonjava.maven.atlas.ident.version.SingleVersion; +import org.commonjava.maven.atlas.ident.version.VersionSpec; +import org.neo4j.graphdb.Node; + +import java.io.Serializable; + +import static org.apache.commons.lang.StringUtils.isEmpty; + +/** + * Represents an artifact, in Maven parlance. A tangible result of a build, which is typically made available in a Maven repository for others + * to consume. NOTE: a POM file is both a piece of metadata AND an artifact in the Maven world! + * + * Artifacts are based on the GAV coordinate for the project release, but also contain a type and optionally, a classifier. Type defaults to 'jar'. + * + * @see {@link NeoProjectRef} + * @see {@link NeoProjectVersionRef} + * + * @author jdcasey + */ +public class NeoArtifactRef + extends NeoProjectVersionRef + implements Serializable, ArtifactRef +{ + + private static final long serialVersionUID = 1L; + + private final NeoTypeAndClassifier tc; + + private Boolean optional; + + public NeoArtifactRef( final String groupId, final String artifactId, final VersionSpec version, final String type, + final String classifier, final boolean optional ) + { + super( groupId, artifactId, version ); + this.optional = optional; + this.tc = new NeoTypeAndClassifier( type, classifier ); + } + + public NeoArtifactRef( final NeoProjectVersionRef ref, final String type, final String classifier, + final boolean optional ) + { + this( ref, new NeoTypeAndClassifier( type, classifier ), optional ); + } + + public NeoArtifactRef( final NeoProjectVersionRef ref ) + { + this( ref, new NeoTypeAndClassifier( "pom", null ), false ); + } + + public NeoArtifactRef( final ProjectVersionRef ref, final NeoTypeAndClassifier tc, final Boolean optional ) + { + super( ref ); + this.tc = tc; + this.optional = optional; + } + + public NeoArtifactRef( final Node node ) + { + super( node ); + this.tc = new NeoTypeAndClassifier( node ); + } + + public NeoArtifactRef( final String groupId, final String artifactId, final String versionSpec, final String type, + final String classifier, final boolean optional ) + throws InvalidVersionSpecificationException + { + super( groupId, artifactId, versionSpec ); + this.tc = new NeoTypeAndClassifier( type, classifier ); + this.optional = optional; + } + + @Override + public String toString() + { + return String.format( "%s:%s:%s:%s%s", getGroupId(), getArtifactId(), getType(), getVersionString(), + ( getClassifier() == null ? "" : ":" + getClassifier() ) ); + } + + public static NeoArtifactRef parse( final String spec ) + { + final String[] parts = spec.split( ":" ); + + if ( parts.length < 3 || isEmpty( parts[0] ) || isEmpty( parts[1] ) || isEmpty( parts[2] ) ) + { + throw new InvalidRefException( + "SimpleArtifactRef must contain AT LEAST non-empty groupId, artifactId, AND version. (Given: '" + + spec + "')" ); + } + + final String g = parts[0]; + final String a = parts[1]; + + // assume we're actually parsing a GAV into a POM artifact... + String v = parts[2]; + String t = "pom"; + String c = null; + + if ( parts.length > 3 ) + { + // oops, it's a type, not a version...see toString() for the specification. + t = v; + v = parts[3]; + + if ( parts.length > 4 ) + { + c = parts[4]; + } + } + + // assume non-optional, because it might not matter if you're parsing a string like this...you'd be more careful if you were reading something + // that had an optional field, because it's not in the normal GATV[C] spec. + return new NeoArtifactRef( g, a, v, t, c, false ); + } + + @Override + public NeoArtifactRef newRef( final String groupId, final String artifactId, final SingleVersion version ) + { + return new NeoArtifactRef( groupId, artifactId, version, tc.getType(), tc.getClassifier(), isOptional() ); + } + + @Override + public String getType() + { + return tc.getType(); + } + + @Override + public String getClassifier() + { + return tc.getClassifier(); + } + + @Override + public TypeAndClassifier getTypeAndClassifier() + { + return tc; + } + + public NeoArtifactRef setOptional( final boolean optional ) + { + if ( isOptional() == optional ) + { + return this; + } + + return new NeoArtifactRef( this, getType(), getClassifier(), optional ); + } + + @Override + public boolean isOptional() + { + return getBooleanProperty( container, Conversions.OPTIONAL, optional, false ); + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ( ( tc == null ) ? 0 : tc.hashCode() ); + result = prime * result + Boolean.valueOf( isOptional() ) + .hashCode(); + return result; + } + + @Override + public boolean equals( final Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( !super.equals( obj ) ) + { + return false; + } + if ( !(obj instanceof ArtifactRef) ) + { + return false; + } + final ArtifactRef other = (ArtifactRef) obj; + + return artifactFieldsEqual( other ); + } + + private boolean artifactFieldsEqual( final ArtifactRef other ) + { + if ( tc == null ) + { + if ( other.getTypeAndClassifier() != null ) + { + return false; + } + } + else if ( !tc.equals( other.getTypeAndClassifier() ) ) + { + return false; + } + return true; + } + + @Override + public boolean versionlessEquals( final ProjectVersionRef other ) + { + if ( !super.versionlessEquals( other ) ) + { + return false; + } + + if ( !( other instanceof ArtifactRef ) ) + { + // compare vs. POM reference. + return "pom".equals(tc.getType()) && null == tc.getClassifier(); + } + + return artifactFieldsEqual( (ArtifactRef) other ); + } + + public Boolean getDirtyOptionalFlag() + { + return optional; + } + + @Override + public boolean isDirty() + { + return super.isDirty() || optional != null || tc.isDirty(); + } +} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoBomRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoBomRelationship.java new file mode 100644 index 00000000..66b8ba8a --- /dev/null +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoBomRelationship.java @@ -0,0 +1,98 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.spi.neo4j.model; + +import org.commonjava.maven.atlas.graph.rel.AbstractSimpleProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.BomRelationship; +import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.neo4j.graphdb.Relationship; + +import java.net.URI; +import java.util.Collection; +import java.util.Set; + +/** NOTE: BOM relationships are actually marked as concrete. + * This may be somewhat counter-intuitive, but they are structural (like a parent POM). + * Therefore, managed isn't correct (despite Maven's unfortunate choice for location). + */ +public class NeoBomRelationship + extends AbstractNeoProjectRelationship + implements BomRelationship +{ + + private static final long serialVersionUID = 1L; + + public NeoBomRelationship( final Relationship rel ) + { + super( rel, RelationshipType.BOM ); + } + + @Override + public BomRelationship selectDeclaring( final ProjectVersionRef ref ) + { + return new NeoBomRelationship( rel ).cloneDirtyState( this ).withDeclaring( ref ); + } + + @Override + public BomRelationship selectTarget( final ProjectVersionRef ref ) + { + return new NeoBomRelationship( rel ).cloneDirtyState( this ).withTarget( ref ); + } + + @Override + public BomRelationship addSource( URI source ) + { + Set sources = getSources(); + if ( sources.add( source ) ) + { + return new NeoBomRelationship( rel ).cloneDirtyState( this ).withSources( sources ); + } + + return this; + } + + @Override + public BomRelationship addSources( Collection sources ) + { + Set srcs = getSources(); + boolean changed = false; + for ( URI src : sources ) + { + changed = srcs.add( src ) || changed; + } + + if ( changed ) + { + return new NeoBomRelationship( rel ).cloneDirtyState( this ).withSources( srcs ); + } + + return this; + } + + @Override + public ProjectVersionRef getTarget() + { + return target == null ? new NeoProjectVersionRef( rel.getEndNode() ) : target; + } + + @Override + public String toString() + { + return String.format( "BomRelationship [%s => %s, rel=%d]", getDeclaring(), getTarget(), rel.getId() ); + } +} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java new file mode 100644 index 00000000..d4377ccf --- /dev/null +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java @@ -0,0 +1,179 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.spi.neo4j.model; + +import org.commonjava.maven.atlas.graph.rel.AbstractSimpleProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.BomRelationship; +import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.neo4j.graphdb.Relationship; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.Serializable; +import java.net.URI; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +public final class NeoDependencyRelationship + extends AbstractNeoProjectRelationship + implements Serializable, DependencyRelationship +{ + + private static final long serialVersionUID = 1L; + + public NeoDependencyRelationship( Relationship rel ) + { + super(rel, RelationshipType.DEPENDENCY); + } + + @Override + public final DependencyScope getScope() + { + final String scopeStr = Conversions.getStringProperty( Conversions.SCOPE, rel ); + return DependencyScope.getScope( scopeStr ); + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ( isManaged() ? 1231 : 1237 ); + return result; + } + + @Override + public boolean equals( final Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( !super.equals( obj ) ) + { + return false; + } + if ( getClass() != obj.getClass() ) + { + return false; + } + final DependencyRelationship other = (DependencyRelationship) obj; + return isManaged() == other.isManaged(); + } + + @Override + public String toString() + { + return String.format( "DependencyRelationship [%s => %s (managed=%s, scope=%s, index=%s, rel=%d)]", getDeclaring(), + getTarget(), isManaged(), getScope(), getIndex(), rel.getId() ); + } + + @Override + public ArtifactRef getTarget() + { + return target == null ? new NeoArtifactRef( rel.getEndNode() ) : target; + } + + @Override + public ArtifactRef getTargetArtifact() + { + return getTarget(); + } + + @Override + public Set getExcludes() + { + final String excludeStr = Conversions.getStringProperty( Conversions.EXCLUDES, rel ); + final Set excludes = new HashSet(); + if ( excludeStr != null ) + { + final String[] e = excludeStr.split( "\\s*,\\s*" ); + for ( final String ex : e ) + { + final String[] parts = ex.split( ":" ); + if ( parts.length != 2 ) + { + // LOGGER.error( "In: {} -> {} skipping invalid exclude specification: '{}'", from, artifact, ex ); + } + else + { + excludes.add( new NeoProjectRef( parts[0], parts[1] ) ); + } + } + } + + return excludes; + } + + @Override + public DependencyRelationship selectDeclaring( final ProjectVersionRef ref ) + { + return new NeoDependencyRelationship( rel ).cloneDirtyState( this ).withDeclaring( ref ); + } + + @Override + public DependencyRelationship selectTarget( final ProjectVersionRef ref ) + { + return new NeoDependencyRelationship( rel ).cloneDirtyState( this ).withTarget( NeoIdentityUtils.newNeoArtifactRef( + ref, getTarget() ) ); + } + + @Override + public DependencyRelationship addSource( URI source ) + { + Set sources = getSources(); + if ( sources.add( source ) ) + { + return new NeoDependencyRelationship( rel ).cloneDirtyState( this ).withSources( sources ); + } + + return this; + } + + @Override + public DependencyRelationship addSources( Collection sources ) + { + Set srcs = getSources(); + boolean changed = false; + for ( URI src: sources ) + { + changed = srcs.add( src ) || changed; + } + + if ( changed ) + { + return new NeoDependencyRelationship( rel ).cloneDirtyState( this ).withSources( srcs ); + } + + return this; + } + + @Override + public boolean isBOM() + { + return DependencyScope._import == getScope() && "pom".equals( getTargetArtifact().getType() ); + } + +} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoExtensionRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoExtensionRelationship.java new file mode 100644 index 00000000..4afc51dd --- /dev/null +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoExtensionRelationship.java @@ -0,0 +1,105 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.spi.neo4j.model; + +import org.commonjava.maven.atlas.graph.rel.AbstractSimpleProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; +import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.graph.util.RelationshipUtils; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.neo4j.graphdb.Relationship; + +import java.io.Serializable; +import java.net.URI; +import java.util.Collection; +import java.util.Set; + +public final class NeoExtensionRelationship + extends AbstractNeoProjectRelationship + implements Serializable, ExtensionRelationship +{ + + private static final long serialVersionUID = 1L; + + public NeoExtensionRelationship( final Relationship rel ) + { + super( rel, RelationshipType.EXTENSION ); + } + + @Override + public String toString() + { + return String.format( "ExtensionRelationship [%s => %s (index=%s)]", getDeclaring(), getTarget(), getIndex() ); + } + + @Override + public ProjectVersionRef getTarget() + { + return target == null ? new NeoProjectVersionRef( rel.getEndNode() ) : target; + } + + @Override + public ArtifactRef getTargetArtifact() + { + return getTarget().asJarArtifact(); + } + + @Override + public ExtensionRelationship selectDeclaring( final ProjectVersionRef ref ) + { + return new NeoExtensionRelationship( rel ).cloneDirtyState( this ).withDeclaring( ref ); + } + + @Override + public ExtensionRelationship selectTarget( final ProjectVersionRef ref ) + { + return new NeoExtensionRelationship( rel ).cloneDirtyState( this ).withTarget( ref ); + } + + @Override + public ExtensionRelationship addSource( URI source ) + { + Set sources = getSources(); + if ( sources.add( source ) ) + { + return new NeoExtensionRelationship( rel ).cloneDirtyState( this ).withSources( sources ); + } + + return this; + } + + @Override + public ExtensionRelationship addSources( Collection sources ) + { + Set srcs = getSources(); + boolean changed = false; + for ( URI src: sources ) + { + changed = srcs.add( src ) || changed; + } + + if ( changed ) + { + return new NeoExtensionRelationship( rel ).cloneDirtyState( this ).withSources( srcs ); + } + + return this; + } + +} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentityUtils.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentityUtils.java new file mode 100644 index 00000000..8ce66960 --- /dev/null +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentityUtils.java @@ -0,0 +1,79 @@ +package org.commonjava.maven.atlas.graph.spi.neo4j.model; + +import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.InvalidRefException; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.neo4j.graphdb.Node; +import org.neo4j.graphdb.PropertyContainer; +import org.neo4j.graphdb.Relationship; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Created by jdcasey on 8/24/15. + */ +public final class NeoIdentityUtils +{ + + private NeoIdentityUtils(){} + + public static String getStringProperty( PropertyContainer container, String named, String memVal ) + { + if ( memVal != null ) + { + return memVal; + } + + String v = container == null ? null : Conversions.getStringProperty( named, container ); + if ( v == null ) + { + throw new InvalidRefException( named + " cannot both be null!" ); + } + + return v; + } + + public static String getStringProperty( PropertyContainer container, String named, String memVal, String defaultVal ) + { +// Logger logger = LoggerFactory.getLogger( NeoIdentityUtils.class ); +// logger.debug( "Looking for property: {} in: {}.\nMemory value: {}\nDefault value: {}", named, container, memVal, defaultVal); + if ( memVal == null ) + { + String v = container == null ? null : Conversions.getStringProperty(named, container); +// logger.debug( "From container: {}, value: {}", container, v ); + return v == null ? defaultVal : v; + } + +// logger.debug("Returning memVal: {}", memVal); + return memVal; + } + + public static boolean getBooleanProperty( PropertyContainer container, String named, Boolean memVal, boolean defaultVal ) + { + if ( memVal != null ) + { + return memVal; + } + + Boolean v = container == null ? null : Conversions.getBooleanProperty( named, container); + return v == null ? defaultVal : v; + } + + public static ArtifactRef newNeoArtifactRef( ProjectVersionRef ref, ArtifactRef target ) + { + NeoTypeAndClassifier tc; + Boolean optional; + if ( target instanceof NeoArtifactRef ) + { + tc = (NeoTypeAndClassifier) target.getTypeAndClassifier(); + optional = ( (NeoArtifactRef) target ).getDirtyOptionalFlag(); + } + else + { + tc = new NeoTypeAndClassifier( target.getType(), target.getClassifier() ); + optional = target.isOptional(); + } + return new NeoArtifactRef( ref, tc, optional ); + } +} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoParentRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoParentRelationship.java new file mode 100644 index 00000000..7118fc33 --- /dev/null +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoParentRelationship.java @@ -0,0 +1,120 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.spi.neo4j.model; + +import org.commonjava.maven.atlas.graph.rel.AbstractSimpleProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; +import org.commonjava.maven.atlas.graph.rel.ParentRelationship; +import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; +import org.commonjava.maven.atlas.graph.util.RelationshipUtils; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.neo4j.graphdb.Relationship; + +import java.io.Serializable; +import java.net.URI; +import java.util.Collection; +import java.util.Set; + +public final class NeoParentRelationship + extends AbstractNeoProjectRelationship + implements Serializable, ParentRelationship +{ + + private static final long serialVersionUID = 1L; + + /** + * Ancestry terminus. This is to signify that the declaring project has NO parent relationship. + */ + public NeoParentRelationship( final Relationship rel ) + { + super( rel, RelationshipType.PARENT ); + } + + @Override + public String toString() + { + return String.format( "ParentRelationship [%s => %s]", getDeclaring(), getTarget() ); + } + + @Override + public ProjectVersionRef getTarget() + { + return target == null ? new NeoProjectVersionRef( rel.getEndNode() ) : target; + } + + @Override + public ArtifactRef getTargetArtifact() + { + return getTarget().asPomArtifact(); + } + + @Override + public boolean isTerminus() + { + if ( declaring != null || target != null ) + { + return getDeclaring().equals( getTarget() ); + } + + return rel.getStartNode().getId() == rel.getEndNode().getId(); + } + + @Override + public ParentRelationship selectDeclaring( final ProjectVersionRef ref ) + { + return new NeoParentRelationship( rel ).cloneDirtyState( this ).withDeclaring( ref ); + } + + @Override + public ParentRelationship selectTarget( final ProjectVersionRef ref ) + { + return new NeoParentRelationship( rel ).cloneDirtyState( this ).withTarget( ref ); + } + + @Override + public ParentRelationship addSource( URI source ) + { + Set sources = getSources(); + if ( sources.add( source ) ) + { + return new NeoParentRelationship( rel ).cloneDirtyState( this ).withSources( sources ); + } + + return this; + } + + @Override + public ParentRelationship addSources( Collection sources ) + { + Set srcs = getSources(); + boolean changed = false; + for ( URI src: sources ) + { + changed = srcs.add( src ) || changed; + } + + if ( changed ) + { + return new NeoParentRelationship( rel ).cloneDirtyState( this ).withSources( srcs ); + } + + return this; + } + +} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java new file mode 100644 index 00000000..8c03f642 --- /dev/null +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java @@ -0,0 +1,161 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.spi.neo4j.model; + +import org.commonjava.maven.atlas.graph.rel.AbstractSimpleProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.ParentRelationship; +import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.neo4j.graphdb.Relationship; + +import java.io.Serializable; +import java.net.URI; +import java.util.Collection; +import java.util.Set; + +public final class NeoPluginDependencyRelationship + extends AbstractNeoProjectRelationship + implements Serializable, PluginDependencyRelationship +{ + + private static final long serialVersionUID = 1L; + + public NeoPluginDependencyRelationship( final Relationship rel ) + { + super( rel, RelationshipType.PLUGIN_DEP ); + } + + @Override + public final ProjectRef getPlugin() + { + return new NeoProjectRef( rel, Conversions.PLUGIN_GROUP_ID, Conversions.PLUGIN_ARTIFACT_ID ); + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ( isManaged() ? 1231 : 1237 ); + result = prime * result + ( ( getPlugin() == null ) ? 0 : getPlugin().hashCode() ); + return result; + } + + @Override + public boolean equals( final Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( !super.equals( obj ) ) + { + return false; + } + if ( getClass() != obj.getClass() ) + { + return false; + } + final NeoPluginDependencyRelationship other = (NeoPluginDependencyRelationship) obj; + if ( isManaged() != other.isManaged() ) + { + return false; + } + + ProjectRef plugin = getPlugin(); + ProjectRef otherPlugin = other.getPlugin(); + if ( plugin == null ) + { + if ( otherPlugin != null ) + { + return false; + } + } + else if ( !plugin.equals( otherPlugin ) ) + { + return false; + } + return true; + } + + @Override + public String toString() + { + return String.format( "PluginDependencyRelationship [%s -> (%s) => %s (managed=%s, index=%s)]", getDeclaring(), + getPlugin(), getTarget(), isManaged(), getIndex() ); + } + + @Override + public ArtifactRef getTarget() + { + return target == null ? new NeoArtifactRef( rel.getEndNode() ) : target; + } + + @Override + public ArtifactRef getTargetArtifact() + { + return getTarget(); + } + + @Override + public PluginDependencyRelationship selectDeclaring( final ProjectVersionRef ref ) + { + return new NeoPluginDependencyRelationship( rel ).cloneDirtyState( this ).withDeclaring( ref ); + } + + @Override + public PluginDependencyRelationship selectTarget( final ProjectVersionRef ref ) + { + ArtifactRef t = getTarget(); + return new NeoPluginDependencyRelationship( rel ).cloneDirtyState( this ).withTarget( NeoIdentityUtils.newNeoArtifactRef( ref, t ) ); + } + + @Override + public PluginDependencyRelationship addSource( URI source ) + { + Set sources = getSources(); + if ( sources.add( source ) ) + { + return new NeoPluginDependencyRelationship( rel ).cloneDirtyState( this ).withSources( sources ); + } + + return this; + } + + @Override + public PluginDependencyRelationship addSources( Collection sources ) + { + Set srcs = getSources(); + boolean changed = false; + for ( URI src: sources ) + { + changed = srcs.add( src ) || changed; + } + + if ( changed ) + { + return new NeoPluginDependencyRelationship( rel ).cloneDirtyState( this ).withSources( srcs ); + } + + return this; + } + +} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java new file mode 100644 index 00000000..04d3ab7e --- /dev/null +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java @@ -0,0 +1,140 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.spi.neo4j.model; + +import org.commonjava.maven.atlas.graph.rel.AbstractSimpleProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.ParentRelationship; +import org.commonjava.maven.atlas.graph.rel.PluginRelationship; +import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.neo4j.graphdb.Relationship; + +import java.io.Serializable; +import java.net.URI; +import java.util.Collection; +import java.util.Set; + +public final class NeoPluginRelationship + extends AbstractNeoProjectRelationship + implements Serializable, PluginRelationship +{ + + private static final long serialVersionUID = 1L; + + public NeoPluginRelationship( final Relationship rel ) + { + super( rel, RelationshipType.PLUGIN ); + } + + @Override + public final boolean isReporting() + { + return Conversions.getBooleanProperty( Conversions.IS_REPORTING_PLUGIN, rel ); + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ( isManaged() ? 1231 : 1237 ); + return result; + } + + @Override + public boolean equals( final Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( !super.equals( obj ) ) + { + return false; + } + if ( getClass() != obj.getClass() ) + { + return false; + } + final PluginRelationship other = (PluginRelationship) obj; + return isManaged() == other.isManaged(); + } + + @Override + public String toString() + { + return String.format( "PluginRelationship [%s => %s (managed=%s, index=%s)]", getDeclaring(), getTarget(), + isManaged(), getIndex() ); + } + + @Override + public ProjectVersionRef getTarget() + { + return target == null ? new NeoProjectVersionRef( rel.getEndNode() ) : target; + } + + @Override + public ArtifactRef getTargetArtifact() + { + return new SimpleArtifactRef( getTarget(), "maven-plugin", null, false ); + } + + @Override + public PluginRelationship selectDeclaring( final ProjectVersionRef ref ) + { + return new NeoPluginRelationship( rel ).cloneDirtyState( this ).withDeclaring( ref ); + } + + @Override + public PluginRelationship selectTarget( final ProjectVersionRef ref ) + { + return new NeoPluginRelationship( rel ).cloneDirtyState( this ).withTarget( ref ); + } + + @Override + public PluginRelationship addSource( URI source ) + { + Set sources = getSources(); + if ( sources.add( source ) ) + { + return new NeoPluginRelationship( rel ).cloneDirtyState( this ).withSources( sources ); + } + + return this; + } + + @Override + public PluginRelationship addSources( Collection sources ) + { + Set srcs = getSources(); + boolean changed = false; + for ( URI src: sources ) + { + changed = srcs.add( src ) || changed; + } + + if ( changed ) + { + return new NeoPluginRelationship( rel ).cloneDirtyState( this ).withSources( srcs ); + } + + return this; + } + +} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java new file mode 100644 index 00000000..855d1776 --- /dev/null +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java @@ -0,0 +1,247 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.spi.neo4j.model; + +import static org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoIdentityUtils.getStringProperty; +import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; +import org.commonjava.maven.atlas.ident.ref.InvalidRefException; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.TypeAndClassifier; +import org.commonjava.maven.atlas.ident.ref.VersionlessArtifactRef; +import org.neo4j.graphdb.Node; +import org.neo4j.graphdb.PropertyContainer; +import org.neo4j.graphdb.Relationship; + +import static org.apache.commons.lang.StringUtils.isEmpty; + +/** + * Reference to a whole project (or module, in terms of Maven builds). This reference is not specific to a release of the project (see {@link NeoProjectVersionRef}). + * + * @author jdcasey + */ +public class NeoProjectRef + implements ProjectRef +{ + + private static final long serialVersionUID = 1L; + + // NEVER null + private String groupId; + + // NEVER null + private String artifactId; + + protected PropertyContainer container; + + private String groupIdProperty = Conversions.GROUP_ID; + + private String artifactIdProperty = Conversions.ARTIFACT_ID; + + public NeoProjectRef(ProjectRef ref) + { + if ( ref instanceof NeoProjectRef) + { + container = ((NeoProjectRef)ref).container; + } + else + { + groupId = ref.getGroupId(); + artifactId = ref.getArtifactId(); + } + } + + public NeoProjectRef( final String groupId, final String artifactId ) + { + if ( isEmpty( groupId ) || isEmpty( artifactId ) ) + { + throw new InvalidRefException( "ProjectId must contain non-empty groupId AND artifactId. (Given: '" + + groupId + "':'" + artifactId + "')" ); + } + + this.groupId = groupId; + this.artifactId = artifactId; + } + + public NeoProjectRef( Node container ) + { + this.container = container; + if ( isEmpty( getGroupId() ) || isEmpty( getArtifactId() ) ) + { + throw new InvalidRefException( "ProjectId must contain non-empty groupId AND artifactId. (Given: '" + + getGroupId() + "':'" + getArtifactId() + "', db-node=" + container.getId() + ")" ); + } + } + + public NeoProjectRef( PropertyContainer container, String groupIdProperty, String artifactIdProperty ) + { + this.container = container; + this.groupIdProperty = groupIdProperty; + this.artifactIdProperty = artifactIdProperty; + } + + public static ProjectRef parse( final String ga ) + { + final String[] parts = ga.split( ":" ); + if ( parts.length < 2 || isEmpty( parts[0] ) || isEmpty( parts[1] ) ) + { + throw new InvalidRefException( "ProjectRef must contain non-empty groupId AND artifactId. (Given: '" + ga + + "')" ); + } + + return new NeoProjectRef( parts[0], parts[1] ); + } + + @Override + public final String getGroupId() + { + return getStringProperty( container, groupIdProperty, groupId, null ); + } + + @Override + public final String getArtifactId() + { + return getStringProperty( container, artifactIdProperty, artifactId, null ); + } + + @Override + public ProjectRef asProjectRef() + { + return NeoProjectRef.class.equals( getClass() ) ? this : new NeoProjectRef( getGroupId(), getArtifactId() ); + } + + @Override + public VersionlessArtifactRef asVersionlessPomArtifact() + { + return asVersionlessArtifactRef( "pom", null, false ); + } + + @Override + public VersionlessArtifactRef asVersionlessJarArtifact() + { + return asVersionlessArtifactRef( "jar", null, false ); + } + + @Override + public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier ) + { + return asVersionlessArtifactRef( type, classifier, false ); + } + + @Override + public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier, + final boolean optional ) + { + return new NeoVersionlessArtifactRef( this, type, classifier, optional ); + } + + @Override + public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc ) + { + return asVersionlessArtifactRef( tc, false ); + } + + @Override + public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc, final boolean optional ) + { + return new NeoVersionlessArtifactRef( this, tc, optional ); + } + + @Override + public String toString() + { + return String.format( "%s:%s", getArtifactId(), getGroupId() ); + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + getArtifactId().hashCode(); + result = prime * result + getGroupId().hashCode(); + return result; + } + + @Override + public boolean equals( final Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( obj == null ) + { + return false; + } + if ( !(obj instanceof ProjectRef) ) + { + return false; + } + final ProjectRef other = (ProjectRef) obj; + if ( !getArtifactId().equals( other.getArtifactId() ) ) + { + return false; + } + return getGroupId().equals( other.getGroupId() ); + } + + public int compareTo( final ProjectRef o ) + { + int comp = getGroupId().compareTo( o.getGroupId() ); + if ( comp == 0 ) + { + comp = getArtifactId().compareTo( o.getArtifactId() ); + } + + return comp; + } + + @Override + public boolean matches( final ProjectRef ref ) + { + if ( equals( ref ) ) + { + return true; + } + + final String gidPattern = toWildcard( getGroupId() ); + if ( !ref.getGroupId() + .matches( gidPattern ) ) + { + return false; + } + + final String aidPattern = toWildcard( getArtifactId() ); + return ref.getArtifactId().matches( aidPattern ); + + } + + private String toWildcard( final String val ) + { + return val.replaceAll( "\\.", "\\." ) + .replaceAll( "\\*", ".*" ); + } + + public PropertyContainer getContainer() + { + return container; + } + + public boolean isDirty() + { + return groupId != null || artifactId != null; + } +} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java new file mode 100644 index 00000000..df49089a --- /dev/null +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java @@ -0,0 +1,369 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.spi.neo4j.model; + +import static org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoIdentityUtils.getStringProperty; + +import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; +import org.commonjava.maven.atlas.ident.ref.*; +import org.commonjava.maven.atlas.ident.util.VersionUtils; +import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; +import org.commonjava.maven.atlas.ident.version.SingleVersion; +import org.commonjava.maven.atlas.ident.version.VersionSpec; +import org.neo4j.graphdb.Node; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.apache.commons.lang.StringUtils.isEmpty; + +/** + * Reference to a particular release of a project (or module, in terms of Maven builds). A release may contain many artifacts (see {@link NeoArtifactRef}). + * + * @see {@link NeoProjectRef} + * @see {@link NeoArtifactRef} + * + * @author jdcasey + */ +public class NeoProjectVersionRef + extends NeoProjectRef + implements ProjectVersionRef +{ + + private static final long serialVersionUID = 1L; + + // NEVER null + private VersionSpec versionSpec; + + private String versionString; + + public NeoProjectVersionRef( final Node node ) + { + super( node ); + } + + public NeoProjectVersionRef( final ProjectRef ref, final String versionSpec ) + throws InvalidVersionSpecificationException + { + this( ref.getGroupId(), ref.getArtifactId(), versionSpec ); + } + + NeoProjectVersionRef( final String groupId, final String artifactId, final VersionSpec versionSpec, + final String versionString ) + { + super( groupId, artifactId ); + if ( versionSpec == null && versionString == null ) + { + throw new InvalidRefException( + "Version spec AND string cannot both be null for '" + groupId + ":" + artifactId + "'" ); + } + + this.versionString = versionString; + this.versionSpec = versionSpec; + } + + public NeoProjectVersionRef( final String groupId, final String artifactId, final VersionSpec versionSpec ) + { + this( groupId, artifactId, versionSpec, null ); + } + + public NeoProjectVersionRef( final String groupId, final String artifactId, final String versionString ) + throws InvalidVersionSpecificationException + { + this( groupId, artifactId, null, versionString ); + } + + public NeoProjectVersionRef( ProjectVersionRef ref ) + { + super( ref ); + if ( container == null ) + { + this.versionString = ref.getVersionStringRaw(); + this.versionSpec = ref.getVersionSpecRaw(); + } + } + + public static ProjectVersionRef parse( final String gav ) + { + final String[] parts = gav.split( ":" ); + if ( parts.length < 3 || isEmpty( parts[0] ) || isEmpty( parts[1] ) || isEmpty( parts[2] ) ) + { + throw new InvalidRefException( + "ProjectVersionRef must contain non-empty groupId, artifactId, AND version. (Given: '" + gav + + "')" ); + } + + return new NeoProjectVersionRef( parts[0], parts[1], parts[2] ); + } + + @Override + public NeoProjectVersionRef asProjectVersionRef() + { + return NeoProjectVersionRef.class.equals( getClass() ) ? + this : + new NeoProjectVersionRef( getGroupId(), getArtifactId(), getVersionSpecRaw(), getVersionStringRaw() ); + } + + @Override + public ArtifactRef asPomArtifact() + { + return asArtifactRef( "pom", null, false ); + } + + @Override + public ArtifactRef asJarArtifact() + { + return asArtifactRef( "jar", null, false ); + } + + @Override + public ArtifactRef asArtifactRef( final String type, final String classifier ) + { + return asArtifactRef( type, classifier, false ); + } + + @Override + public ArtifactRef asArtifactRef( final String type, final String classifier, final boolean optional ) + { + return new NeoArtifactRef( this, type, classifier, optional ); + } + + @Override + public ArtifactRef asArtifactRef( final TypeAndClassifier tc ) + { + return asArtifactRef( tc, false ); + } + + @Override + public ArtifactRef asArtifactRef( final TypeAndClassifier tc, final boolean optional ) + { + NeoTypeAndClassifier ntc = ( tc instanceof NeoTypeAndClassifier ) ? + (NeoTypeAndClassifier) tc : + new NeoTypeAndClassifier( tc.getType(), tc.getClassifier() ); + + return new NeoArtifactRef( this, ntc, optional ); + } + + @Override + public VersionSpec getVersionSpecRaw() + { + return versionSpec; + } + + @Override + public String getVersionStringRaw() + { + String v = getStringProperty( container, Conversions.VERSION, versionString, null ); + return v; + } + + @Override + public boolean isRelease() + { + return getVersionSpec().isRelease(); + } + + @Override + public boolean isSpecificVersion() + { + return getVersionSpec().isSingle(); + } + + @Override + public boolean matchesVersion( final SingleVersion version ) + { + return getVersionSpec().contains( version ); + } + + @Override + public NeoProjectVersionRef selectVersion( final String version ) + { + final SingleVersion single = VersionUtils.createSingleVersion( version ); + return selectVersion( single, false ); + } + + @Override + public NeoProjectVersionRef selectVersion( final String version, final boolean force ) + { + final SingleVersion single = VersionUtils.createSingleVersion( version ); + return selectVersion( single, force ); + } + + @Override + public NeoProjectVersionRef selectVersion( final SingleVersion version ) + { + return selectVersion( version, false ); + } + + @Override + public NeoProjectVersionRef selectVersion( final SingleVersion version, final boolean force ) + { + final VersionSpec versionSpec = getVersionSpec(); + if ( versionSpec.equals( version ) ) + { + return this; + } + + if ( !force && !versionSpec.contains( version ) ) + { + throw new IllegalArgumentException( + "Specified version: " + version.renderStandard() + " is not contained in spec: " + + versionSpec.renderStandard() ); + } + + return newRef( getGroupId(), getArtifactId(), version ); + } + + @Override + public NeoProjectVersionRef newRef( final String groupId, final String artifactId, final SingleVersion version ) + { + return new NeoProjectVersionRef( groupId, artifactId, version ); + } + + @Override + public VersionSpec getVersionSpec() + { + if ( versionSpec == null ) + { + versionSpec = VersionUtils.createFromSpec( getVersionStringRaw() ); + } + return versionSpec; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ( ( getVersionString() == null ) ? 0 : getVersionString().hashCode() ); + return result; + } + + public boolean versionlessEquals( final ProjectVersionRef other ) + { + return this == other || super.equals( other ); + } + + @Override + public boolean equals( final Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( !super.equals( obj ) ) + { + return false; + } + if ( !( obj instanceof ProjectVersionRef ) ) + { + return false; + } + + final ProjectVersionRef other = (ProjectVersionRef) obj; + boolean result = true; + try + { + if ( getVersionSpec() == null ) + { + if ( other.getVersionSpec() != null ) + { + result = false; + } + } + else if ( !getVersionSpec().equals( other.getVersionSpec() ) ) + { + result = false; + } + } + catch ( final InvalidVersionSpecificationException e ) + { + if ( getVersionString() == null ) + { + if ( other.getVersionString() != null ) + { + result = false; + } + } + else if ( !getVersionString().equals( other.getVersionString() ) ) + { + result = false; + } + } + + return result; + } + + @Override + public String toString() + { + String msg = String.format( "%s:%s:%s", getGroupId(), getArtifactId(), getVersionString() ); + return msg; + } + + @Override + public boolean isCompound() + { + return !getVersionSpec().isSingle(); + } + + @Override + public boolean isSnapshot() + { + return getVersionSpec().isSnapshot(); + } + + @Override + public String getVersionString() + { + if ( versionString == null ) + { + String v = getVersionStringRaw(); + if ( v == null ) + { + return versionSpec.renderStandard(); + } + + return v; + } + + return versionString; + } + + @Override + public boolean isVariableVersion() + { + return isCompound() || ( isSpecificVersion() && ( (SingleVersion) getVersionSpec() ).isLocalSnapshot() ); + } + + @Override + public int compareTo( final ProjectRef o ) + { + int comp = super.compareTo( o ); + if ( comp == 0 && ( o instanceof ProjectVersionRef ) ) + { + final ProjectVersionRef or = (ProjectVersionRef) o; + comp = getVersionString().compareTo( or.getVersionString() ); + } + + return comp; + } + + @Override + public boolean isDirty() + { + return super.isDirty() || versionString != null; + } +} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoTypeAndClassifier.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoTypeAndClassifier.java new file mode 100644 index 00000000..0c6b1dc6 --- /dev/null +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoTypeAndClassifier.java @@ -0,0 +1,157 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.spi.neo4j.model; + +import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; +import org.commonjava.maven.atlas.ident.ref.TypeAndClassifier; +import org.neo4j.graphdb.Node; +import org.neo4j.graphdb.Relationship; + +import static org.apache.commons.lang.StringUtils.isEmpty; + +public class NeoTypeAndClassifier + implements TypeAndClassifier +{ + private static final long serialVersionUID = 1L; + + private String type; + + private String classifier; + + private Relationship rel; + + private Node node; + + public NeoTypeAndClassifier( final String type, final String classifier ) + { + this.type = type == null ? "jar" : type; + this.classifier = isEmpty( classifier ) ? null : classifier; + } + + public NeoTypeAndClassifier( final String type ) + { + this( type, null ); + } + + public NeoTypeAndClassifier() + { + this( null, null ); + } + + public NeoTypeAndClassifier( Relationship rel ) + { + this.rel = rel; + } + + public NeoTypeAndClassifier( Node node ) + { + this.node = node; + } + + @Override + public String getType() + { + String t; + if ( rel == null ) + { + t = type; + } + else + { + t = Conversions.getStringProperty( Conversions.TYPE, rel ); + } + + return t == null ? "jar" : t; + } + + @Override + public String getClassifier() + { + if ( rel == null ) + { + return classifier; + } + else + { + return Conversions.getStringProperty( Conversions.CLASSIFIER, rel ); + } + } + + @Override + public String toString() + { + return String.format( "%s%s", type, ( classifier == null ? "" : ":" + classifier ) ); + } + + @Override + // FIXME: Expensive!! + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ( ( getClassifier() == null ) ? 0 : getClassifier().hashCode() ); + result = prime * result + ( ( getType() == null ) ? 0 : getType().hashCode() ); + return result; + } + + @Override + // FIXME: Expensive!! + public boolean equals( final Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( obj == null ) + { + return false; + } + if ( !(obj instanceof TypeAndClassifier) ) + { + return false; + } + final TypeAndClassifier other = (TypeAndClassifier) obj; + if ( getClassifier() == null ) + { + if ( other.getClassifier() != null ) + { + return false; + } + } + else if ( !getClassifier().equals( other.getClassifier() ) ) + { + return false; + } + if ( getType() == null ) + { + if ( other.getType() != null ) + { + return false; + } + } + else if ( !getType().equals( other.getType() ) ) + { + return false; + } + return true; + } + + public boolean isDirty() + { + return type != null || classifier != null; + } + +} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java new file mode 100644 index 00000000..c81ce001 --- /dev/null +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java @@ -0,0 +1,233 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.spi.neo4j.model; + +import org.commonjava.maven.atlas.ident.ref.*; +import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; + +import static org.apache.commons.lang.StringUtils.isEmpty; + +/** + * Special implementation of {@link NeoArtifactRef} that forces all versions to ZERO, to allow calculation of transitive + * dependency graphs, where version collisions of the same project are likely. + * + * @author jdcasey + */ +public class NeoVersionlessArtifactRef + extends NeoProjectRef + implements VersionlessArtifactRef +{ + + private static final long serialVersionUID = 1L; + + private final TypeAndClassifier tc; + + private final boolean optional; + + public NeoVersionlessArtifactRef( final ArtifactRef ref ) + { + super( ref.getGroupId(), ref.getArtifactId() ); + this.optional = ref.isOptional(); + this.tc = ref.getTypeAndClassifier(); + } + + public NeoVersionlessArtifactRef( final ProjectRef ref, final String type, final String classifier, + final boolean optional ) + { + super( ref.getGroupId(), ref.getArtifactId() ); + this.optional = optional; + this.tc = new NeoTypeAndClassifier( type, classifier ); + } + + public NeoVersionlessArtifactRef( final ProjectRef ref, final TypeAndClassifier tc, final boolean optional ) + { + super( ref.getGroupId(), ref.getArtifactId() ); + this.tc = tc == null ? new NeoTypeAndClassifier() : tc; + this.optional = optional; + } + + public NeoVersionlessArtifactRef( final String groupId, final String artifactId, final String type, + final String classifier, final boolean optional ) + throws InvalidVersionSpecificationException + { + super( groupId, artifactId ); + this.tc = new NeoTypeAndClassifier( type, classifier ); + this.optional = optional; + } + + @Override + public String toString() + { + return String.format( "%s:%s:%s", getGroupId(), getArtifactId(), getTypeAndClassifier() ); + } + + public static VersionlessArtifactRef parse( final String spec ) + { + final String[] parts = spec.split( ":" ); + + if ( parts.length < 2 || isEmpty( parts[0] ) || isEmpty( parts[1] ) ) + { + throw new InvalidRefException( + "VersionlessArtifactRef must contain AT LEAST non-empty groupId and artifactId. (Given: '" + + spec + "')" ); + } + + final String g = parts[0]; + final String a = parts[1]; + + String t = "pom"; + String c = null; + + if ( parts.length > 2 ) + { + // we probably have a type in there. + t = parts[2]; + + if ( parts.length > 3 ) + { + // we have a classifier? What if it's GATV?? + // assume it's just a classifier... + c = parts[3]; + + if ( parts.length > 4 ) + { + // okay, wtf? It's a GATVC, and we need to shift to eliminate the V... + c = parts[4]; + } + } + } + + // assume non-optional, because it might not matter if you're parsing a string like this...you'd be more careful if you were reading something + // that had an optional field, because it's not in the normal GATV[C] spec. + return new NeoVersionlessArtifactRef( g, a, t, c, false ); + } + + @Override + public String getType() + { + return tc.getType(); + } + + @Override + public String getClassifier() + { + return tc.getClassifier(); + } + + @Override + public TypeAndClassifier getTypeAndClassifier() + { + return tc; + } + + @Override + public boolean isOptional() + { + return optional; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ( optional ? 1231 : 1237 ); + result = prime * result + ( ( tc == null ) ? 0 : tc.hashCode() ); + return result; + } + + @Override + public boolean equals( final Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( !super.equals( obj ) ) + { + return false; + } + if ( !(obj instanceof VersionlessArtifactRef) ) + { + return false; + } + final VersionlessArtifactRef other = (VersionlessArtifactRef) obj; + if ( optional != other.isOptional() ) + { + return false; + } + if ( tc == null ) + { + if ( other.getTypeAndClassifier() != null ) + { + return false; + } + } + else if ( !tc.equals( other.getTypeAndClassifier() ) ) + { + return false; + } + return true; + } + + @Override + public VersionlessArtifactRef asVersionlessPomArtifact() + { + return asVersionlessArtifactRef( "pom", null, false ); + } + + @Override + public VersionlessArtifactRef asVersionlessJarArtifact() + { + return asVersionlessArtifactRef( "jar", null, false ); + } + + @Override + public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier ) + { + return asVersionlessArtifactRef( type, classifier, false ); + } + + @Override + public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier, + final boolean optional ) + { + final TypeAndClassifier tc = new NeoTypeAndClassifier( type, classifier ); + if ( NeoVersionlessArtifactRef.class.equals( getClass() ) && this.tc.equals( tc ) && this.optional == optional ) + { + return this; + } + + return super.asVersionlessArtifactRef( type, classifier, optional ); + } + + @Override + public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc ) + { + return asVersionlessArtifactRef( tc, false ); + } + + @Override + public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc, final boolean optional ) + { + if ( NeoVersionlessArtifactRef.class.equals( getClass() ) && this.tc.equals( tc ) && this.optional == optional ) + { + return this; + } + + return super.asVersionlessArtifactRef( tc, optional ); + } +} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java index 0f0673e0..4624b9c3 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java @@ -33,6 +33,7 @@ import org.commonjava.maven.atlas.graph.spi.neo4j.io.ConversionCache; import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoProjectVersionRef; import org.commonjava.maven.atlas.graph.spi.neo4j.update.CycleCacheUpdater; import org.commonjava.maven.atlas.ident.util.JoinString; import org.neo4j.graphdb.Direction; @@ -186,9 +187,8 @@ public final Iterable expand( final Path path, final BranchState s childTypes = TraversalUtils.getGraphRelTypes( filter ); } - logger.debug( "Getting relationships from node: {} ({}) with type in [{}] and direction: {} (path: {})", - path.endNode(), path.endNode() - .getProperty( GAV ), new JoinString( ", ", childTypes ), direction, path ); + logger.debug( "Getting relationships from node: {} with type in [{}] and direction: {} (path: {})", + path.endNode(), new JoinString( ", ", childTypes ), direction, path ); final Iterable relationships = path.endNode() .getRelationships( direction, childTypes ); @@ -236,7 +236,7 @@ public final Iterable expand( final Path path, final BranchState s logger.debug( "After selection, using child relationship: {}", r ); } - final ProjectRelationship rel = toProjectRelationship( r, cache ); + final ProjectRelationship rel = toProjectRelationship( r, cache ); final Neo4jGraphPath nextPath = new Neo4jGraphPath( graphPath, r ); final GraphPathInfo nextPathInfo = pathInfo.getChildPathInfo( rel ); diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java index cb49b22e..efa14eec 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java @@ -113,9 +113,9 @@ public Evaluation evaluate( final Path path ) if ( roots == null || roots.isEmpty() || roots.contains( path.startNode() .getId() ) ) { - final ProjectRelationship lastRel = Conversions.toProjectRelationship( rel, cache ); + final ProjectRelationship lastRel = Conversions.toProjectRelationship( rel, cache ); - final List> relPath = Conversions.convertToRelationships( path.relationships(), cache ); + final List> relPath = Conversions.convertToRelationships( path.relationships(), cache ); if ( relPath.indexOf( lastRel ) == relPath.size() - 1 ) { // logger.warn( "\n\n\n\n\nREMOVING last-relationship: {} from path!\n\n\n\n\n" ); @@ -179,7 +179,7 @@ public Iterable expand( final Path path, final BranchState // sort the child relationships to make the traversal deterministic final Set result = new TreeSet( new AtlasRelIndexComparator() ); - final List> rels = getPathRelationships( path ); + final List> rels = getPathRelationships( path ); // logger.info( "For: {} Determining which of {} child relationships to expand traversal into for: {}\n{}", traversal.getClass() // .getName(), path.length(), @@ -209,7 +209,7 @@ public Iterable expand( final Path path, final BranchState } // logger.info( "Attempting to expand: {}", r ); - final ProjectRelationship projectRel = Conversions.toProjectRelationship( r, cache ); + final ProjectRelationship projectRel = Conversions.toProjectRelationship( r, cache ); logger.debug( "Pre-checking relationship {} for expansion using filter: {}", projectRel, traversal ); if ( traversal.preCheck( projectRel, rels ) ) @@ -227,9 +227,9 @@ public Iterable expand( final Path path, final BranchState return result; } - private List> getPathRelationships( final Path path ) + private List> getPathRelationships( final Path path ) { - List> rels; + List> rels; final Iterable rs = path.relationships(); if ( rs == null ) { diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/RootedRelationshipsVisitor.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/RootedRelationshipsVisitor.java index b9f23a76..17dba560 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/RootedRelationshipsVisitor.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/RootedRelationshipsVisitor.java @@ -31,20 +31,20 @@ public class RootedRelationshipsVisitor extends AbstractTraverseVisitor - implements Iterable> + implements Iterable> { private final Logger logger = LoggerFactory.getLogger( getClass() ); - private final Set> found = new HashSet>(); + private final Set> found = new HashSet>(); - public Set> getRelationships() + public Set> getRelationships() { return found; } @Override - public Iterator> iterator() + public Iterator> iterator() { return found.iterator(); } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java index 56405878..c032a498 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java @@ -77,7 +77,7 @@ public static boolean acceptedInView( final Relationship r, final ViewParams vie public static boolean accepted( final Relationship r, final ViewParams view, final ConversionCache cache ) { - final ProjectRelationship rel = toProjectRelationship( r, cache ); + final ProjectRelationship rel = toProjectRelationship( r, cache ); debug( "Checking relationship for acceptance: {} ({})", r, rel ); diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java index ffef3f59..bdb03e45 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java @@ -96,7 +96,7 @@ private void addCycleInternal( final CyclePath cyclicPath, final Relationship in logger.debug( "Adding cycle: {} (via: {})", cyclicPath, injector ); Conversions.storeCachedCyclePath( cyclicPath, viewNode ); - final List> cycle = Conversions.convertToRelationships( cyclicPath, admin, cache ); + final List> cycle = Conversions.convertToRelationships( cyclicPath, admin, cache ); logger.info( "CYCLES += {\n {}\n}", new JoinString( "\n ", cycle ) ); cycles.add( new EProjectCycle( cycle ) ); diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java index b93c0e3c..43eeffd7 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java @@ -102,9 +102,9 @@ public void cacheRoots( final Set roots ) } } - public boolean processAddedRelationships( final Map> createdRelationshipsMap ) + public boolean processAddedRelationships( final Map> createdRelationshipsMap ) { - for ( final Entry> entry : createdRelationshipsMap.entrySet() ) + for ( final Entry> entry : createdRelationshipsMap.entrySet() ) { final Long rid = entry.getKey(); final Relationship add = admin.getRelationship( rid ); diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/CypherQueriesTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/CypherQueriesTest.java deleted file mode 100644 index eaf6563c..00000000 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/CypherQueriesTest.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j; - -import java.net.URI; -import java.util.Map; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.graph.spi.neo4j.fixture.FileConnectionFixture; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; -import org.neo4j.cypher.javacompat.ExecutionResult; - -public class CypherQueriesTest - extends AbstractSPI_TCK -{ - - @Rule - public FileConnectionFixture fixture = new FileConnectionFixture(); - - @Rule - public TestName naming = new TestName(); - - @Test - public void projectsWithVariableFlag_PartialQuery() - throws Exception - { - final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); - final ProjectVersionRef varDep = new SimpleProjectVersionRef( "org.other", "dep", "1.0-SNAPSHOT" ); - final ProjectVersionRef varD2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0-SNAPSHOT" ); - final ProjectVersionRef selected = new SimpleProjectVersionRef( varDep, "1.0-20130314.161200-1" ); - - final URI source = sourceURI(); - RelationshipGraph graph = simpleGraph( project ); - - /* @formatter:off */ - graph.storeRelationships( - new DependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false ), - new DependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false ) - ); - - graph = graphFactory().open( new ViewParams.Builder( graph.getParams() ).withSelection( varDep.asProjectRef(), selected ).build(), false ); - -// view.selectVersion( varDep, selected ); - - final String cypher = "START a=node(1) " - + "\nMATCH p=(a)-[:M_PLUGIN_DEP|C_PLUGIN|PARENT|EXTENSION|M_DEPENDENCY|M_PLUGIN|C_PLUGIN_DEP|C_DEPENDENCY*]->(n) " - + "\nWHERE " - + "\n none( " - + "\n r in relationships(p) " - + "\n WHERE has(r._deselected_for) " - + "\n ) " - + "\nRETURN n as node, p as path"; - /* @formatter:on */ - - final FileNeo4JGraphConnection driver = (FileNeo4JGraphConnection) graph.getDatabase(); - - final ExecutionResult result = driver.execute( cypher ); - int i = 0; - for ( final Map record : result ) - { - System.out.printf( "%d: %s", i++, record ); - } - } - - @Test - // @Ignore - public void projectsWithVariableFlagQuery() - throws Exception - { - final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); - final ProjectVersionRef varDep = new SimpleProjectVersionRef( "org.other", "dep", "1.0-SNAPSHOT" ); - final ProjectVersionRef varD2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0-SNAPSHOT" ); - final ProjectVersionRef selected = new SimpleProjectVersionRef( varDep, "1.0-20130314.161200-1" ); - - final URI source = sourceURI(); - RelationshipGraph graph = simpleGraph( project ); - - /* @formatter:off */ - graph.storeRelationships( - new DependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false ), - new DependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false ) - ); - - graph = graphFactory().open( new ViewParams.Builder( graph.getParams()).withSelection( varDep.asProjectRef(), selected ).build(), false ); - - final String cypher = "START a=node(1) " - + "\nMATCH p=(a)-[:M_PLUGIN_DEP|C_PLUGIN|PARENT|EXTENSION|M_DEPENDENCY|M_PLUGIN|C_PLUGIN_DEP|C_DEPENDENCY*]->(n) " - + "\nWHERE " - + "\n none( " - + "\n r in relationships(p) " - + "\n WHERE has(r._deselected_for) " - + "\n ) " - + "\n AND has(n.gav) " - + "\n AND has(n.gav) " - + "\n AND n._variable! = true " - + "\nRETURN n as node, p as path"; - /* @formatter:on */ - - final FileNeo4JGraphConnection driver = (FileNeo4JGraphConnection) graph.getDatabase(); - - final ExecutionResult result = driver.execute( cypher ); - int i = 0; - for ( final Map record : result ) - { - System.out.printf( "%d: %s", i++, record ); - } - } - - @Override - protected RelationshipGraphConnectionFactory connectionFactory() - throws Exception - { - return fixture.connectionFactory(); - } - -} diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileCycleDetectionTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileCycleDetectionTest.java deleted file mode 100644 index dd4eb916..00000000 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileCycleDetectionTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.graph.spi.neo4j.fixture.FileConnectionFixture; -import org.commonjava.maven.atlas.tck.graph.CycleDetectionTCK; -import org.junit.Rule; - -public class FileCycleDetectionTest - extends CycleDetectionTCK -{ - @Rule - public FileConnectionFixture fixture = new FileConnectionFixture(); - - @Override - protected synchronized RelationshipGraphConnectionFactory connectionFactory() - throws Exception - { - return fixture.connectionFactory(); - } -} diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileGraphWorkspaceTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileGraphWorkspaceTest.java deleted file mode 100644 index d1d254e2..00000000 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileGraphWorkspaceTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.graph.spi.neo4j.fixture.FileConnectionFixture; -import org.commonjava.maven.atlas.tck.graph.RelationshipGraphConnection_TCK; -import org.junit.Rule; - -public class FileGraphWorkspaceTest - extends RelationshipGraphConnection_TCK -{ - - @Rule - public FileConnectionFixture fixture = new FileConnectionFixture(); - - @Override - protected synchronized RelationshipGraphConnectionFactory connectionFactory() - throws Exception - { - return fixture.connectionFactory(); - } -} diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileSubGraphSelectionTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileSubGraphSelectionTest.java deleted file mode 100644 index 9f9905df..00000000 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileSubGraphSelectionTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.graph.spi.neo4j.fixture.FileConnectionFixture; -import org.commonjava.maven.atlas.tck.graph.SubGraphSelectionTCK; -import org.junit.Rule; - -public class FileSubGraphSelectionTest - extends SubGraphSelectionTCK -{ - @Rule - public FileConnectionFixture fixture = new FileConnectionFixture(); - - @Override - protected synchronized RelationshipGraphConnectionFactory connectionFactory() - throws Exception - { - return fixture.connectionFactory(); - } -} diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphFactoryTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphFactoryTest.java deleted file mode 100644 index d741bad6..00000000 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphFactoryTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.graph.spi.neo4j.fixture.FileConnectionFixture; -import org.commonjava.maven.atlas.tck.graph.RelationshipGraphFactoryTCK; -import org.junit.Rule; - -public class RelationshipGraphFactoryTest - extends RelationshipGraphFactoryTCK -{ - @Rule - public FileConnectionFixture fixture = new FileConnectionFixture(); - - @Override - protected synchronized RelationshipGraphConnectionFactory connectionFactory() - throws Exception - { - return fixture.connectionFactory(); - } -} diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphTest.java deleted file mode 100644 index a7a59515..00000000 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelationshipGraphTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.graph.spi.neo4j.fixture.FileConnectionFixture; -import org.commonjava.maven.atlas.tck.graph.RelationshipGraphTCK; -import org.junit.Rule; - -public class RelationshipGraphTest - extends RelationshipGraphTCK -{ - @Rule - public FileConnectionFixture fixture = new FileConnectionFixture(); - - @Override - protected synchronized RelationshipGraphConnectionFactory connectionFactory() - throws Exception - { - return fixture.connectionFactory(); - } -} diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/FileConnectionFixture.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/FileConnectionFixture.java deleted file mode 100644 index 9cd12818..00000000 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/FileConnectionFixture.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.fixture; - -import java.io.File; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; -import org.commonjava.maven.atlas.graph.spi.neo4j.FileNeo4jConnectionFactory; -import org.junit.rules.ExternalResource; -import org.junit.rules.TemporaryFolder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class FileConnectionFixture - extends ExternalResource -{ - - private final Logger logger = LoggerFactory.getLogger( getClass() ); - - private final TemporaryFolder folder = new TemporaryFolder(); - - private FileNeo4jConnectionFactory factory; - - @Override - protected void after() - { - super.after(); - try - { - factory.close(); - } - catch ( final RelationshipGraphConnectionException e ) - { - e.printStackTrace(); - } - - folder.delete(); - } - - @Override - protected void before() - throws Throwable - { - folder.create(); - - final File dbDir = folder.newFolder(); - dbDir.delete(); - dbDir.mkdirs(); - - logger.info( "Initializing db in: {}", dbDir ); - factory = new FileNeo4jConnectionFactory( dbDir, false ); - } - - public FileNeo4jConnectionFactory connectionFactory() - { - return factory; - } -} diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileAncestryTraversalTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileAncestryTraversalTest.java deleted file mode 100644 index 7e221157..00000000 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileAncestryTraversalTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.graph.spi.neo4j.fixture.FileConnectionFixture; -import org.commonjava.maven.atlas.tck.graph.traverse.AncestryTraversalTCK; -import org.junit.Rule; - -public class FileAncestryTraversalTest - extends AncestryTraversalTCK -{ - @Rule - public FileConnectionFixture fixture = new FileConnectionFixture(); - - @Override - protected synchronized RelationshipGraphConnectionFactory connectionFactory() - throws Exception - { - return fixture.connectionFactory(); - } -} diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileBuildOrderTraversalTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileBuildOrderTraversalTest.java deleted file mode 100644 index e7117b6d..00000000 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileBuildOrderTraversalTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.graph.spi.neo4j.fixture.FileConnectionFixture; -import org.commonjava.maven.atlas.tck.graph.traverse.BuildOrderTraversalTCK; -import org.junit.Rule; - -public class FileBuildOrderTraversalTest - extends BuildOrderTraversalTCK -{ - @Rule - public FileConnectionFixture fixture = new FileConnectionFixture(); - - @Override - protected synchronized RelationshipGraphConnectionFactory connectionFactory() - throws Exception - { - return fixture.connectionFactory(); - } -} diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileTransitiveDependencyTraversalTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileTransitiveDependencyTraversalTest.java deleted file mode 100644 index a1d3e858..00000000 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/FileTransitiveDependencyTraversalTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.graph.spi.neo4j.fixture.FileConnectionFixture; -import org.commonjava.maven.atlas.tck.graph.traverse.TransitiveDependencyTraversalTCK; -import org.junit.Rule; - -public class FileTransitiveDependencyTraversalTest - extends TransitiveDependencyTraversalTCK -{ - @Rule - public FileConnectionFixture fixture = new FileConnectionFixture(); - - @Override - protected synchronized RelationshipGraphConnectionFactory connectionFactory() - throws Exception - { - return fixture.connectionFactory(); - } -} diff --git a/drivers/pom.xml b/drivers/pom.xml index c30d02e5..4d9a04b4 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -35,14 +35,10 @@ org.commonjava.maven.atlas atlas-relationships-api - - org.commonjava.maven.atlas - atlas-drivers-tck - - jung neo4j-embedded + jung diff --git a/ftests/jung/pom.xml b/ftests/jung/pom.xml new file mode 100644 index 00000000..982178c8 --- /dev/null +++ b/ftests/jung/pom.xml @@ -0,0 +1,43 @@ + + + + 4.0.0 + + + org.commonjava.maven.atlas + atlas-ftests-parent + 0.14.3-SNAPSHOT + + + atlas-ftests-jung + + Atlas :: Maven Project-Graph :: Jung Functional Tests + + + + org.commonjava.maven.atlas + atlas-driver-jung + + + net.sf.jung + jung-graph-impl + + + + diff --git a/ftests/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/fixture/JungTCKDriver.java b/ftests/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/fixture/JungTCKDriver.java new file mode 100644 index 00000000..167f9fba --- /dev/null +++ b/ftests/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/fixture/JungTCKDriver.java @@ -0,0 +1,56 @@ +package org.commonjava.maven.atlas.graph.spi.jung.fixture; + +import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; +import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; +import org.commonjava.maven.atlas.graph.spi.jung.JungGraphConnectionFactory; +import org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver; +import org.junit.rules.TemporaryFolder; + +import java.io.IOException; + +/** + * Created by jdcasey on 8/24/15. + */ +public class JungTCKDriver + implements TCKDriver +{ + private TemporaryFolder temp; + + private JungGraphConnectionFactory factory; + + @Override + public void setup( TemporaryFolder temp ) + throws Exception + { + this.temp = temp; + } + + @Override + public RelationshipGraphConnectionFactory getConnectionFactory() + throws Exception + { + if ( factory == null ) + { + factory = new JungGraphConnectionFactory(); + } + + return factory; + } + + @Override + public void close() + throws IOException + { + if ( factory != null ) + { + try + { + factory.close(); + } + catch ( RelationshipGraphConnectionException e ) + { + throw new IOException( "Failed to shutdown graph connection factory: " + e.getMessage(), e ); + } + } + } +} diff --git a/ftests/jung/src/main/resources/META-INF/services/org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver b/ftests/jung/src/main/resources/META-INF/services/org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver new file mode 100644 index 00000000..309992dd --- /dev/null +++ b/ftests/jung/src/main/resources/META-INF/services/org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver @@ -0,0 +1 @@ +org.commonjava.maven.atlas.graph.spi.jung.fixture.JungTCKDriver \ No newline at end of file diff --git a/drivers/jung/src/test/resources/logback-test.xml b/ftests/jung/src/main/resources/logback-test.xml similarity index 100% rename from drivers/jung/src/test/resources/logback-test.xml rename to ftests/jung/src/main/resources/logback-test.xml diff --git a/ftests/neo4j/pom.xml b/ftests/neo4j/pom.xml new file mode 100644 index 00000000..56131a05 --- /dev/null +++ b/ftests/neo4j/pom.xml @@ -0,0 +1,60 @@ + + + + 4.0.0 + + + org.commonjava.maven.atlas + atlas-ftests-parent + 0.14.3-SNAPSHOT + + + atlas-ftests-neo4j + + Atlas :: Maven Project-Graph :: Neo4J Functional Tests + + + 1C + true + + + + + org.commonjava.maven.atlas + atlas-driver-neo4j-embedded + + + org.neo4j + neo4j + + + commons-codec + commons-codec + + + org.slf4j + log4j-over-slf4j + + + commons-io + commons-io + + + + diff --git a/ftests/neo4j/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/NeoTCKDriver.java b/ftests/neo4j/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/NeoTCKDriver.java new file mode 100644 index 00000000..fcb2d05c --- /dev/null +++ b/ftests/neo4j/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/NeoTCKDriver.java @@ -0,0 +1,56 @@ +package org.commonjava.maven.atlas.graph.spi.neo4j.fixture; + +import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; +import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; +import org.commonjava.maven.atlas.graph.spi.neo4j.FileNeo4jConnectionFactory; +import org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver; +import org.junit.rules.TemporaryFolder; + +import java.io.IOException; + +/** + * Created by jdcasey on 8/24/15. + */ +public class NeoTCKDriver + implements TCKDriver +{ + private TemporaryFolder temp; + + private FileNeo4jConnectionFactory factory; + + @Override + public void setup( TemporaryFolder temp ) + throws Exception + { + this.temp = temp; + } + + @Override + public RelationshipGraphConnectionFactory getConnectionFactory() + throws Exception + { + if ( factory == null ) + { + factory = new FileNeo4jConnectionFactory( temp.newFolder( "db", ".dir" ), false ); + } + + return factory; + } + + @Override + public void close() + throws IOException + { + if ( factory != null ) + { + try + { + factory.close(); + } + catch ( RelationshipGraphConnectionException e ) + { + throw new IOException( "Failed to shutdown graph connection factory: " + e.getMessage(), e ); + } + } + } +} diff --git a/ftests/neo4j/src/main/resources/META-INF/services/org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver b/ftests/neo4j/src/main/resources/META-INF/services/org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver new file mode 100644 index 00000000..1d15b9b9 --- /dev/null +++ b/ftests/neo4j/src/main/resources/META-INF/services/org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver @@ -0,0 +1 @@ +org.commonjava.maven.atlas.graph.spi.neo4j.fixture.NeoTCKDriver \ No newline at end of file diff --git a/drivers/neo4j-embedded/src/test/resources/logback-test.xml b/ftests/neo4j/src/main/resources/logback-test.xml similarity index 100% rename from drivers/neo4j-embedded/src/test/resources/logback-test.xml rename to ftests/neo4j/src/main/resources/logback-test.xml diff --git a/ftests/pom.xml b/ftests/pom.xml new file mode 100644 index 00000000..37ffaef9 --- /dev/null +++ b/ftests/pom.xml @@ -0,0 +1,80 @@ + + + + 4.0.0 + + + org.commonjava.maven.atlas + atlas-parent + 0.14.3-SNAPSHOT + + + atlas-ftests-parent + pom + + Atlas :: Maven Project-Graph :: Functional Test Parent + + + + org.commonjava.maven.atlas + atlas-relationships-api + + + org.commonjava.maven.atlas + atlas-drivers-tck + compile + + + junit + junit + compile + + + org.hamcrest + hamcrest-core + compile + + + + + neo4j + jung + + + + + + + maven-surefire-plugin + + ${test-forkCount} + false + ${test-redirectOutput} + + **/*TCK.java + + + org.commonjava.maven.atlas:atlas-drivers-tck + + + + + + + diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleTypeAndClassifier.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleTypeAndClassifier.java index 41ee15b6..83c4289b 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleTypeAndClassifier.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleTypeAndClassifier.java @@ -45,7 +45,7 @@ public SimpleTypeAndClassifier() @Override public String getType() { - return type; + return type == null ? "jar" : type; } @Override diff --git a/pom.xml b/pom.xml index 1d6dbc21..8c2c35e1 100644 --- a/pom.xml +++ b/pom.xml @@ -65,6 +65,16 @@ atlas-bindings-jackson-relationships 0.14.3-SNAPSHOT + + org.commonjava.maven.atlas + atlas-driver-jung + 0.14.3-SNAPSHOT + + + org.commonjava.maven.atlas + atlas-driver-neo4j-embedded + 0.14.3-SNAPSHOT + org.commonjava.maven.atlas atlas-drivers-tck @@ -141,5 +151,6 @@ bindings tck drivers + ftests diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/AbstractRelationshipGraphListener.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/AbstractRelationshipGraphListener.java index 4d3aa2fd..53f7e7dd 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/AbstractRelationshipGraphListener.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/AbstractRelationshipGraphListener.java @@ -35,7 +35,7 @@ protected AbstractRelationshipGraphListener() public abstract boolean equals( Object other ); @Override - public void storing( final RelationshipGraph graph, final Collection> relationships ) + public void storing( final RelationshipGraph graph, final Collection> relationships ) throws RelationshipGraphException { // NOP @@ -43,8 +43,8 @@ public void storing( final RelationshipGraph graph, final Collection> relationships, - final Collection> rejected ) + final Collection> relationships, + final Collection> rejected ) throws RelationshipGraphException { // NOP diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java index b21afe74..ba7ca5bf 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java @@ -102,17 +102,17 @@ public void clearProjectError( final ProjectVersionRef ref ) getConnectionInternal().clearProjectError( ref ); } - public Set> storeRelationships( final ProjectRelationship... relationships ) + public Set> storeRelationships( final ProjectRelationship... relationships ) throws RelationshipGraphException { - final List> rels = Arrays.asList( relationships ); + final List> rels = Arrays.asList( relationships ); for ( final RelationshipGraphListener listener : listeners ) { listener.storing( this, rels ); } - final Set> rejected = getConnectionInternal().addRelationships( relationships ); + final Set> rejected = getConnectionInternal().addRelationships( relationships ); for ( final RelationshipGraphListener listener : listeners ) { @@ -122,8 +122,8 @@ public Set> storeRelationships( final ProjectRelationship return rejected; } - public Set> storeRelationships( - final Collection> relationships ) + public Set> storeRelationships( + final Collection> relationships ) throws RelationshipGraphException { for ( final RelationshipGraphListener listener : listeners ) @@ -131,8 +131,8 @@ public Set> storeRelationships( listener.storing( this, relationships ); } - final Set> rejected = getConnectionInternal().addRelationships( - relationships.toArray( new ProjectRelationship[relationships.size()] ) ); + final Set> rejected = getConnectionInternal().addRelationships( + relationships.toArray( new ProjectRelationship[relationships.size()] ) ); for ( final RelationshipGraphListener listener : listeners ) { @@ -216,9 +216,9 @@ public synchronized void close() // +++ IMPORTED FROM EProjectWeb... - public Set> getAllRelationships() + public Set> getAllRelationships() { - return new HashSet>( getConnectionInternal().getAllRelationships( params ) ); + return new HashSet>( getConnectionInternal().getAllRelationships( params ) ); } public boolean isComplete() @@ -241,13 +241,13 @@ public Set getVariableSubgraphs() return Collections.unmodifiableSet( getConnectionInternal().getVariableProjects( params ) ); } - public Set> add( final EProjectDirectRelationships rels ) + public Set> add( final EProjectDirectRelationships rels ) throws RelationshipGraphException { return addAll( rels.getAllRelationships() ); } - public boolean add( final ProjectRelationship rel ) + public boolean add( final ProjectRelationship rel ) throws RelationshipGraphException { if ( rel == null ) @@ -258,7 +258,7 @@ public boolean add( final ProjectRelationship rel ) return getConnectionInternal().addRelationships( rel ).isEmpty(); } - public > Set addAll( final Collection rels ) + public > Set addAll( final Collection rels ) throws RelationshipGraphException { if ( rels == null ) @@ -268,8 +268,8 @@ public > Set addAll( final Collection rel final Set result = new HashSet( rels ); - final Set> rejected = - getConnectionInternal().addRelationships( rels.toArray( new ProjectRelationship[rels.size()] ) ); + final Set> rejected = + getConnectionInternal().addRelationships( rels.toArray( new ProjectRelationship[rels.size()] ) ); result.removeAll( rejected ); if ( !result.isEmpty() ) @@ -280,7 +280,7 @@ public > Set addAll( final Collection rel return result; } - public > Set addAll( final T... rels ) + public > Set addAll( final T... rels ) throws RelationshipGraphException { if ( rels == null ) @@ -330,24 +330,24 @@ public void traverse( final RelationshipGraphTraversal traversal ) traverse( traversal, TraversalType.breadth_first ); } - public Set> getUserRelationships( final ProjectVersionRef ref ) + public Set> getUserRelationships( final ProjectVersionRef ref ) { if ( !getConnectionInternal().containsProject( params, ref ) ) { return Collections.emptySet(); } - return new HashSet>( getConnectionInternal().getRelationshipsTargeting( params, ref ) ); + return new HashSet>( getConnectionInternal().getRelationshipsTargeting( params, ref ) ); } - public Set> getDirectRelationships( final ProjectVersionRef ref ) + public Set> getDirectRelationships( final ProjectVersionRef ref ) { if ( !getConnectionInternal().containsProject( params, ref ) ) { return Collections.emptySet(); } - return new HashSet>( getConnectionInternal().getRelationshipsDeclaredBy( params, ref ) ); + return new HashSet>( getConnectionInternal().getRelationshipsDeclaredBy( params, ref ) ); } public Set getRoots() @@ -355,7 +355,7 @@ public Set getRoots() return params.getRoots(); } - public Set> getExactAllRelationships() + public Set> getExactAllRelationships() { return getAllRelationships(); } @@ -365,7 +365,7 @@ public boolean isCycleParticipant( final ProjectVersionRef ref ) return getConnectionInternal().isCycleParticipant( params, ref ); } - public boolean isCycleParticipant( final ProjectRelationship rel ) + public boolean isCycleParticipant( final ProjectRelationship rel ) { return getConnectionInternal().isCycleParticipant( params, rel ); } @@ -381,16 +381,16 @@ public Set getCycles() return getConnectionInternal().getCycles( params ); } - public Set> getRelationshipsTargeting( final ProjectVersionRef ref ) + public Set> getRelationshipsTargeting( final ProjectVersionRef ref ) { - final Collection> rels = + final Collection> rels = getConnectionInternal().getRelationshipsTargeting( params, ref.asProjectVersionRef() ); if ( rels == null ) { return Collections.emptySet(); } - return new HashSet>( rels ); + return new HashSet>( rels ); } public RelationshipGraphConnection getDatabase() @@ -432,12 +432,12 @@ public void reindex( final ProjectVersionRef ref ) getConnectionInternal().reindex( ref ); } - public Set>> getPathsTo( final ProjectVersionRef... projectVersionRefs ) + public Set>> getPathsTo( final ProjectVersionRef... projectVersionRefs ) { return getConnectionInternal().getAllPathsTo( params, projectVersionRefs ); } - public boolean introducesCycle( final ProjectRelationship rel ) + public boolean introducesCycle( final ProjectRelationship rel ) { return getConnectionInternal().introducesCycle( params, rel ); } @@ -554,14 +554,14 @@ public boolean containsGraph( final ProjectVersionRef ref ) return getConnectionInternal().containsProject( params, ref ); } - public Set> findDirectRelationshipsTo( final ProjectVersionRef to, + public Set> findDirectRelationshipsTo( final ProjectVersionRef to, final boolean includeManagedInfo, final RelationshipType... types ) { return getConnectionInternal().getDirectRelationshipsTo( params, to, includeManagedInfo, true, types ); } - public Set> findDirectRelationshipsTo( final ProjectVersionRef to, + public Set> findDirectRelationshipsTo( final ProjectVersionRef to, final boolean includeManagedInfo, final boolean includeConcreteInfo, final RelationshipType... types ) @@ -570,14 +570,14 @@ public Set> findDirectRelationshipsTo( final ProjectVersi types ); } - public Set> findDirectRelationshipsFrom( final ProjectVersionRef source, + public Set> findDirectRelationshipsFrom( final ProjectVersionRef source, final boolean managed, final RelationshipType... types ) { return getConnectionInternal().getDirectRelationshipsFrom( params, source, managed, true, types ); } - public Set> findDirectRelationshipsFrom( final ProjectVersionRef source, + public Set> findDirectRelationshipsFrom( final ProjectVersionRef source, final boolean managed, final boolean concrete, final RelationshipType... types ) { @@ -685,12 +685,12 @@ public ProjectVersionRef getPathTargetRef( final GraphPath path ) return getConnectionInternal().getPathTargetRef( path ); } - public GraphPath createPath( final GraphPath parentPath, final ProjectRelationship relationship ) + public GraphPath createPath( final GraphPath parentPath, final ProjectRelationship relationship ) { return getConnectionInternal().createPath( parentPath, relationship ); } - public GraphPath createPath( final ProjectRelationship... relationships ) + public GraphPath createPath( final ProjectRelationship... relationships ) { return getConnectionInternal().createPath( relationships ); } @@ -749,7 +749,7 @@ private synchronized RelationshipGraphConnection getConnectionInternal() return connection; } - public Collection> getRelationshipsDeclaring( final ProjectVersionRef root ) + public Collection> getRelationshipsDeclaring( final ProjectVersionRef root ) { return getConnectionInternal().getRelationshipsDeclaredBy( params, root ); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListener.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListener.java index d93914da..42bfdd09 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListener.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListener.java @@ -26,11 +26,11 @@ public interface RelationshipGraphListener void projectError( RelationshipGraph graph, ProjectVersionRef ref, Throwable error ) throws RelationshipGraphException; - void storing( RelationshipGraph graph, Collection> relationships ) + void storing( RelationshipGraph graph, Collection> relationships ) throws RelationshipGraphException; - void stored( RelationshipGraph graph, Collection> relationships, - Collection> rejected ) + void stored( RelationshipGraph graph, Collection> relationships, + Collection> rejected ) throws RelationshipGraphException; void closing( RelationshipGraph graph ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java index ffbf79f5..d9178866 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java @@ -369,6 +369,11 @@ public final Iterable activeSources() return activeSources; } + public final Map getSelections() + { + return selections == null ? Collections. emptyMap() : selections; + } + public final ProjectVersionRef getSelection( final ProjectRef ref ) { if ( selections == null ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java index 776c52f2..073b18e8 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java @@ -58,7 +58,7 @@ public final List getFilters() } @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) + public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) { final Set childFilters = new LinkedHashSet(); for ( final ProjectRelationshipFilter filter : getFilters() ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java index 2eb596da..a21b7bba 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java @@ -141,7 +141,7 @@ protected AbstractTypedFilter( final RelationshipType type, final boolean hasDes } @Override - public final boolean accept( final ProjectRelationship rel ) + public final boolean accept( final ProjectRelationship rel ) { if ( types.contains( rel.getType() ) ) { @@ -177,7 +177,7 @@ public Set getDescendantRelationshipTypes() return descendantTypes; } - protected boolean doAccept( final ProjectRelationship rel ) + protected boolean doAccept( final ProjectRelationship rel ) { // base functionality is only to check that the type is appropriate. return true; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java index 2b40b953..2ac134db 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java @@ -39,7 +39,7 @@ public AndFilter( final T... filters ) } @Override - public boolean accept( final ProjectRelationship rel ) + public boolean accept( final ProjectRelationship rel ) { boolean accepted = true; for ( final ProjectRelationshipFilter filter : getFilters() ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AnyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AnyFilter.java index 3452aea7..03be5eef 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AnyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AnyFilter.java @@ -38,13 +38,13 @@ private AnyFilter() } @Override - public boolean accept( final ProjectRelationship rel ) + public boolean accept( final ProjectRelationship rel ) { return true; } @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) + public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) { return this; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/BomFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/BomFilter.java index d08b7036..a2005664 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/BomFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/BomFilter.java @@ -35,13 +35,13 @@ private BomFilter() } @Override - public boolean doAccept( final ProjectRelationship rel ) + public boolean doAccept( final ProjectRelationship rel ) { return true; } @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) + public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) { return this; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java index 0f71677a..ac9bac6c 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java @@ -21,10 +21,13 @@ import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.DependencyScope; import org.commonjava.maven.atlas.ident.ScopeTransitivity; import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class DependencyFilter extends AbstractTypedFilter @@ -77,11 +80,14 @@ public DependencyFilter( final DependencyScope scope, final ScopeTransitivity sc } @Override - public boolean doAccept( final ProjectRelationship rel ) + public boolean doAccept( final ProjectRelationship rel ) { +// Logger logger = LoggerFactory.getLogger( getClass() ); +// logger.debug( "CHECK accept: {}", rel); final DependencyRelationship dr = (DependencyRelationship) rel; if ( RelationshipUtils.isExcluded( dr.getTarget(), excludes ) ) { +// logger.debug( "NO (excluded)" ); return false; } @@ -89,28 +95,33 @@ public boolean doAccept( final ProjectRelationship rel ) { if ( useImpliedScopes && !scope.implies( dr.getScope() ) ) { +// logger.debug( "NO (wrong implied scope)" ); return false; } else if ( !useImpliedScopes && scope != dr.getScope() ) { +// logger.debug( "NO (wrong direct scope)" ); return false; } } if ( !includeManagedRelationships() && dr.isManaged() ) { +// logger.debug( "NO (excluding managed)" ); return false; } else if ( !includeConcreteRelationships() && !dr.isManaged() ) { +// logger.debug( "NO (excluding concrete)" ); return false; } +// logger.debug( "YES" ); return true; } @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) + public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) { DependencyRelationship dr = null; if ( ( parent instanceof DependencyRelationship ) ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java index 5a4120fc..f35f63dd 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java @@ -58,7 +58,7 @@ public DependencyOnlyFilter( final boolean includeManaged, final boolean include } @Override - public boolean doAccept( final ProjectRelationship rel ) + public boolean doAccept( final ProjectRelationship rel ) { if ( this.scopes == null || this.scopes.length < 1 ) { @@ -83,7 +83,7 @@ public boolean doAccept( final ProjectRelationship rel ) } @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) + public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) { return NoneFilter.INSTANCE; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java index d48529d3..28d836f9 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java @@ -46,7 +46,7 @@ public ExcludingFilter( final List excludedSubgraphs, final P } @Override - public boolean accept( final ProjectRelationship rel ) + public boolean accept( final ProjectRelationship rel ) { final ProjectVersionRef target = rel.getTarget() .asProjectVersionRef(); @@ -54,7 +54,7 @@ public boolean accept( final ProjectRelationship rel ) } @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) + public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) { ProjectRelationshipFilter childfilter = filter.getChildFilter( parent ); if ( childfilter == filter ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionFilter.java index 9979bc31..120037a1 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionFilter.java @@ -15,9 +15,9 @@ */ package org.commonjava.maven.atlas.graph.filter; -import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.graph.rel.SimpleExtensionRelationship; import org.commonjava.maven.atlas.ident.DependencyScope; // TODO: Do we need to consider excludes in the extensions? @@ -36,9 +36,9 @@ public ExtensionFilter() } @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) + public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) { - if ( parent instanceof ExtensionRelationship ) + if ( parent instanceof SimpleExtensionRelationship ) { return new OrFilter( new DependencyFilter( DependencyScope.runtime ), ParentFilter.EXCLUDE_TERMINAL_PARENTS ); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionOnlyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionOnlyFilter.java index 8f018baf..fb71aa05 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionOnlyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionOnlyFilter.java @@ -33,7 +33,7 @@ public ExtensionOnlyFilter() } @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) + public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) { return NoneFilter.INSTANCE; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/NoneFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/NoneFilter.java index 772cfebe..77208254 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/NoneFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/NoneFilter.java @@ -37,13 +37,13 @@ private NoneFilter() } @Override - public boolean accept( final ProjectRelationship rel ) + public boolean accept( final ProjectRelationship rel ) { return false; } @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) + public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) { return this; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java index 8ddb3a88..9495f52d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java @@ -41,7 +41,7 @@ public OrFilter( final T... filters ) } @Override - public boolean accept( final ProjectRelationship rel ) + public boolean accept( final ProjectRelationship rel ) { boolean accepted = false; for ( final ProjectRelationshipFilter filter : getFilters() ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ParentFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ParentFilter.java index 75fc842d..d5f3ed55 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ParentFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ParentFilter.java @@ -41,14 +41,14 @@ private ParentFilter( final boolean allowTerminalParent ) } @Override - public boolean doAccept( final ProjectRelationship rel ) + public boolean doAccept( final ProjectRelationship rel ) { return allowTerminalParent || !( (ParentRelationship) rel ).isTerminus(); } @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) + public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) { return this; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyFilter.java index 5325396f..3803f584 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyFilter.java @@ -59,7 +59,7 @@ public PluginDependencyFilter( final boolean includeManaged, final boolean inclu } @Override - public boolean doAccept( final ProjectRelationship rel ) + public boolean doAccept( final ProjectRelationship rel ) { final PluginDependencyRelationship pdr = (PluginDependencyRelationship) rel; if ( plugin == null || plugin.equals( pdr.getPlugin() ) ) @@ -78,7 +78,7 @@ else if ( includeConcreteRelationships() && !pdr.isManaged() ) } @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) + public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) { return new DependencyFilter( DependencyScope.runtime ); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyOnlyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyOnlyFilter.java index 9c3e9010..227d1203 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyOnlyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyOnlyFilter.java @@ -47,7 +47,7 @@ public PluginDependencyOnlyFilter( final PluginRelationship plugin, final boolea } @Override - public boolean doAccept( final ProjectRelationship rel ) + public boolean doAccept( final ProjectRelationship rel ) { final PluginDependencyRelationship pdr = (PluginDependencyRelationship) rel; if ( plugin.equals( pdr.getPlugin() ) ) @@ -66,7 +66,7 @@ else if ( includeConcreteRelationships() && !pdr.isManaged() ) } @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) + public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) { return NoneFilter.INSTANCE; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginOnlyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginOnlyFilter.java index 92da59be..06dcbf8a 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginOnlyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginOnlyFilter.java @@ -39,7 +39,7 @@ public PluginOnlyFilter( final boolean includeManaged, final boolean includeConc } @Override - public boolean doAccept( final ProjectRelationship rel ) + public boolean doAccept( final ProjectRelationship rel ) { final PluginRelationship pr = (PluginRelationship) rel; if ( includeManagedRelationships() && pr.isManaged() ) @@ -55,7 +55,7 @@ else if ( includeConcreteRelationships() && !pr.isManaged() ) } @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) + public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) { return NoneFilter.INSTANCE; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java index 7632d160..e8a4ffd6 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java @@ -21,6 +21,7 @@ import org.commonjava.maven.atlas.graph.rel.PluginRelationship; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; import org.commonjava.maven.atlas.ident.DependencyScope; public class PluginRuntimeFilter @@ -37,17 +38,17 @@ public PluginRuntimeFilter() } @Override - public boolean accept( final ProjectRelationship rel ) + public boolean accept( final ProjectRelationship rel ) { - return ( rel instanceof PluginRelationship ) && !( (PluginRelationship) rel ).isManaged(); + return ( rel instanceof SimplePluginRelationship ) && !( (PluginRelationship) rel ).isManaged(); } // TODO: Optimize to minimize new instance creation... @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) + public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) { ProjectRelationshipFilter child; - if ( parent instanceof PluginRelationship ) + if ( parent instanceof SimplePluginRelationship ) { final PluginRelationship plugin = (PluginRelationship) parent; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ProjectRelationshipFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ProjectRelationshipFilter.java index f17617b6..86a5d568 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ProjectRelationshipFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ProjectRelationshipFilter.java @@ -38,7 +38,7 @@ public interface ProjectRelationshipFilter * @param rel The relationship in question * @return true to allow traversal, false otherwise. */ - boolean accept( ProjectRelationship rel ); + boolean accept( ProjectRelationship rel ); /** * Return the filter used to handle the next wave of relationships after the @@ -50,7 +50,7 @@ public interface ProjectRelationshipFilter * @return This instance WHENEVER POSSIBLE, but possibly a different filter * if the relationship demands a shift in logic. */ - ProjectRelationshipFilter getChildFilter( ProjectRelationship parent ); + ProjectRelationshipFilter getChildFilter( ProjectRelationship parent ); /** * Retrieve a human-readable string that uniquely identifies the logic in this filter, diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/RelationshipTypeFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/RelationshipTypeFilter.java index 26ded2b4..7270fe58 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/RelationshipTypeFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/RelationshipTypeFilter.java @@ -59,7 +59,7 @@ public RelationshipTypeFilter( final RelationshipType type, final RelationshipTy } @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) + public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) { final Set descendantTypes = getDescendantRelationshipTypes(); final Set allowedTypes = getAllowedTypes(); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/StructuralRelationshipsFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/StructuralRelationshipsFilter.java index 75c1d668..59e80b30 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/StructuralRelationshipsFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/StructuralRelationshipsFilter.java @@ -42,7 +42,7 @@ private StructuralRelationshipsFilter() } @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) + public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) { return this; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java index da14d50b..923511bf 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java @@ -32,42 +32,42 @@ import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; public class EProjectCycle - implements Iterable>, EProjectRelationshipCollection + implements Iterable>, EProjectRelationshipCollection { private static final long serialVersionUID = 1L; - private List> relationships = new ArrayList>(); + private List> relationships = new ArrayList>(); public static final class Builder { - private final List> participants; + private final List> participants; - public Builder( final ProjectRelationship... rels ) + public Builder( final ProjectRelationship... rels ) { - participants = new ArrayList>( Arrays.asList( rels ) ); + participants = new ArrayList>( Arrays.asList( rels ) ); } - public Builder( final List> rels ) + public Builder( final List> rels ) { - participants = new ArrayList>( rels ); + participants = new ArrayList>( rels ); } public Builder( final Builder builder ) { - participants = new ArrayList>( builder.participants ); + participants = new ArrayList>( builder.participants ); } public Builder( final Builder builder, final int start ) { - participants = new ArrayList>( builder.participants ); + participants = new ArrayList>( builder.participants ); for ( int i = 0; i < start; i++ ) { participants.remove( 0 ); } } - public Builder with( final ProjectRelationship rel ) + public Builder with( final ProjectRelationship rel ) { participants.add( rel ); return this; @@ -89,7 +89,7 @@ public int indexOf( final ProjectVersionRef ref ) return build().indexOf( ref ); } - public int indexOf( final ProjectRelationship rel ) + public int indexOf( final ProjectRelationship rel ) { return build().indexOf( rel ); } @@ -99,7 +99,7 @@ public boolean contains( final ProjectVersionRef ref ) return build().contains( ref ); } - public boolean contains( final ProjectRelationship rel ) + public boolean contains( final ProjectRelationship rel ) { return build().contains( rel ); } @@ -107,19 +107,19 @@ public boolean contains( final ProjectRelationship rel ) public EProjectCycle(){} - public EProjectCycle( final List> cycle ) + public EProjectCycle( final List> cycle ) { - this.relationships = new ArrayList>( cycle ); + this.relationships = new ArrayList>( cycle ); } - public boolean contains( final ProjectRelationship rel ) + public boolean contains( final ProjectRelationship rel ) { return relationships.contains( rel ); } public boolean contains( final ProjectVersionRef ref ) { - for ( final ProjectRelationship rel : relationships ) + for ( final ProjectRelationship rel : relationships ) { if ( rel.getDeclaring() .equals( ref ) ) @@ -131,7 +131,7 @@ public boolean contains( final ProjectVersionRef ref ) return false; } - public int indexOf( final ProjectRelationship rel ) + public int indexOf( final ProjectRelationship rel ) { return relationships.indexOf( rel ); } @@ -141,7 +141,7 @@ public int indexOf( final ProjectVersionRef ref ) int targetIdx = -1; for ( int i = 0; i < relationships.size(); i++ ) { - final ProjectRelationship rel = relationships.get( i ); + final ProjectRelationship rel = relationships.get( i ); if ( rel.getDeclaring() .equals( ref ) ) { @@ -163,30 +163,30 @@ public int indexOf( final ProjectVersionRef ref ) } @Override - public Iterator> iterator() + public Iterator> iterator() { return relationships.iterator(); } @Override - public Collection> getAllRelationships() + public Collection> getAllRelationships() { - final Collection> rels = getExactAllRelationships(); + final Collection> rels = getExactAllRelationships(); filterTerminalParents( rels ); return rels; } @Override - public Collection> getExactAllRelationships() + public Collection> getExactAllRelationships() { - return new ArrayList>( relationships ); + return new ArrayList>( relationships ); } public Set getAllParticipatingProjects() { final Set refs = new HashSet(); - for ( final ProjectRelationship rel : relationships ) + for ( final ProjectRelationship rel : relationships ) { refs.add( rel.getDeclaring() ); refs.add( rel.getTarget() @@ -196,12 +196,12 @@ public Set getAllParticipatingProjects() return refs; } - public List> getRelationships() + public List> getRelationships() { return relationships; } - public void setRelationships( final List> relationships ) + public void setRelationships( final List> relationships ) { this.relationships = relationships; } @@ -218,7 +218,7 @@ public int hashCode() final int prime = 31; int result = 1; - final List> sorted = new ArrayList>( relationships ); + final List> sorted = new ArrayList>( relationships ); Collections.sort( sorted, RelationshipComparator.INSTANCE ); result = prime * result + sorted.hashCode(); @@ -251,10 +251,10 @@ public boolean equals( final Object obj ) else { - final Set> cycle = new HashSet>( this.relationships ); - final Set> otherCycle = new HashSet>( other.relationships ); + final Set> cycle = new HashSet>( this.relationships ); + final Set> otherCycle = new HashSet>( other.relationships ); - for ( final ProjectRelationship rel : cycle ) + for ( final ProjectRelationship rel : cycle ) { if ( !otherCycle.contains( rel ) ) { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java index 9abae004..2f6b205d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java @@ -29,19 +29,12 @@ import java.util.Map; import java.util.Set; -import org.commonjava.maven.atlas.graph.rel.BomRelationship; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.*; import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.DependencyScope; import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; public class EProjectDirectRelationships implements EProjectRelationshipCollection, Serializable @@ -141,7 +134,7 @@ public final Map> getPlug public final List getPluginDependencies( final ProjectVersionRef plugin, final boolean managed ) { - final PluginRelationship pr = new PluginRelationship( source, getProjectRef(), plugin, 0, managed ); + final PluginRelationship pr = new SimplePluginRelationship( source, getProjectRef(), plugin, 0, managed ); return pluginDependencies.get( pr ); } @@ -151,18 +144,18 @@ public final List getBoms() } @Override - public Set> getAllRelationships() + public Set> getAllRelationships() { - final Set> rels = getExactAllRelationships(); + final Set> rels = getExactAllRelationships(); filterTerminalParents( rels ); return rels; } @Override - public Set> getExactAllRelationships() + public Set> getExactAllRelationships() { - final Set> result = new HashSet>(); + final Set> result = new HashSet>(); if ( parent != null ) { result.add( parent ); @@ -216,7 +209,7 @@ public EProjectDirectRelationships build() { if ( parent == null ) { - parent = new ParentRelationship( source, ref ); + parent = new SimpleParentRelationship( ref ); } return new EProjectDirectRelationships( source, ref, parent, boms, dependencies, plugins, @@ -226,7 +219,7 @@ public EProjectDirectRelationships build() public Builder withParent( final ProjectVersionRef parent ) { - this.parent = new ParentRelationship( source, ref, parent ); + this.parent = new SimpleParentRelationship( source, ref, parent ); return this; } @@ -238,7 +231,7 @@ public Builder withParent( final ParentRelationship parent ) } @SuppressWarnings( "unchecked" ) - private > C adjustDeclaring( final C rel ) + private > C adjustDeclaring( final C rel ) { if ( !ref .equals( rel.getDeclaring() ) ) @@ -399,10 +392,10 @@ public Builder withExtensions( final Collection exts ) return this; } - public Builder withRelationships( final Collection> relationships ) + public Builder withRelationships( final Collection> relationships ) { final Set pluginDepRels = new HashSet(); - for ( ProjectRelationship rel : relationships ) + for ( ProjectRelationship rel : relationships ) { rel = adjustDeclaring( rel ); switch ( rel.getType() ) @@ -456,7 +449,7 @@ public int getNextPluginIndex( final boolean managed ) public int getNextPluginDependencyIndex( final ProjectVersionRef plugin, final boolean managed ) { final List list = - pluginDependencies.get( new PluginRelationship( source, ref, plugin, 0, managed ) ); + pluginDependencies.get( new SimplePluginRelationship( source, ref, plugin, 0, managed ) ); return list == null ? 0 : list.size(); } @@ -473,7 +466,7 @@ public int getNextExtensionIndex() public Builder withDependency( final ProjectVersionRef ref, final String type, final String classifier, final DependencyScope scope, final boolean managed ) { - withDependencies( new DependencyRelationship( source, ref, new SimpleArtifactRef( ref, type, classifier, false ), + withDependencies( new SimpleDependencyRelationship( source, ref, new SimpleArtifactRef( ref, type, classifier, false ), scope, getNextDependencyIndex( managed ), managed ) ); @@ -482,14 +475,14 @@ public Builder withDependency( final ProjectVersionRef ref, final String type, f public Builder withPlugin( final ProjectVersionRef ref, final boolean managed ) { - withPlugins( new PluginRelationship( source, ref, ref, getNextPluginIndex( managed ), managed ) ); + withPlugins( new SimplePluginRelationship( source, ref, ref, getNextPluginIndex( managed ), managed ) ); return this; } public Builder withExtension( final ProjectVersionRef ref ) { - withExtensions( new ExtensionRelationship( source, RelationshipUtils.POM_ROOT_URI, ref, ref, + withExtensions( new SimpleExtensionRelationship( source, RelationshipUtils.POM_ROOT_URI, ref, ref, getNextExtensionIndex() ) ); return this; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectRelationshipCollection.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectRelationshipCollection.java index c216206a..c4f216ba 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectRelationshipCollection.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectRelationshipCollection.java @@ -24,8 +24,8 @@ public interface EProjectRelationshipCollection extends Serializable { - Collection> getAllRelationships(); + Collection> getAllRelationships(); - Collection> getExactAllRelationships(); + Collection> getExactAllRelationships(); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPathInfo.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPathInfo.java index 1e5dfce8..9f745340 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPathInfo.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPathInfo.java @@ -65,7 +65,7 @@ public GraphMutator getMutator() return mutator; } - public ProjectRelationship selectRelationship( ProjectRelationship next, final GraphPath path ) + public ProjectRelationship selectRelationship( ProjectRelationship next, final GraphPath path ) { if ( filter != null && !filter.accept( next ) ) { @@ -80,7 +80,7 @@ public ProjectRelationship selectRelationship( ProjectRelationship next, f return next; } - public GraphPathInfo getChildPathInfo( final ProjectRelationship rel ) + public GraphPathInfo getChildPathInfo( final ProjectRelationship rel ) { final ProjectRelationshipFilter nextFilter = filter == null ? null : filter.getChildFilter( rel ); final GraphMutator nextMutator = mutator == null ? null : mutator.getMutatorFor( rel, connection, params ); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/GraphMutator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/GraphMutator.java index bc11c4ef..f9ffa3ab 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/GraphMutator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/GraphMutator.java @@ -50,7 +50,7 @@ public interface GraphMutator * @return The alternative relationship, or the given one if no mutation * takes place. */ - ProjectRelationship selectFor( ProjectRelationship rel, GraphPath path, + ProjectRelationship selectFor( ProjectRelationship rel, GraphPath path, RelationshipGraphConnection connection, ViewParams params ); /** @@ -66,7 +66,7 @@ ProjectRelationship selectFor( ProjectRelationship rel, GraphPath path, * whether to proceed should be handled via {@link ProjectRelationshipFilter}, * not here. */ - GraphMutator getMutatorFor( ProjectRelationship rel, RelationshipGraphConnection connection, ViewParams params ); + GraphMutator getMutatorFor( ProjectRelationship rel, RelationshipGraphConnection connection, ViewParams params ); /** * Retrieve a human-readable string that uniquely identifies the logic in this mutator, diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java index 70c2dc94..4dffc1b1 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java @@ -30,7 +30,7 @@ public class ManagedDependencyMutator private static final long serialVersionUID = 1L; @Override - public ProjectRelationship selectFor( final ProjectRelationship rel, final GraphPath path, + public ProjectRelationship selectFor( final ProjectRelationship rel, final GraphPath path, final RelationshipGraphConnection connection, final ViewParams params ) { if ( rel.getType() != RelationshipType.DEPENDENCY ) // TODO: BOM types?? @@ -39,7 +39,7 @@ public ProjectRelationship selectFor( final ProjectRelationship rel, final return rel; } - ProjectRelationship mutated = super.selectFor( rel, path, connection, params ); + ProjectRelationship mutated = super.selectFor( rel, path, connection, params ); if ( mutated == null || mutated == rel ) { final ProjectVersionRef managed = diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java index 4b61cd7c..1b4b05d4 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java @@ -33,14 +33,14 @@ private NoOpGraphMutator() } @Override - public ProjectRelationship selectFor( final ProjectRelationship rel, final GraphPath path, + public ProjectRelationship selectFor( final ProjectRelationship rel, final GraphPath path, final RelationshipGraphConnection connection, final ViewParams params ) { return rel; } @Override - public GraphMutator getMutatorFor( final ProjectRelationship rel, final RelationshipGraphConnection connection, + public GraphMutator getMutatorFor( final ProjectRelationship rel, final RelationshipGraphConnection connection, final ViewParams params ) { return this; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java index 9798b3f5..783859be 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java @@ -34,7 +34,7 @@ public class VersionManagerMutator private transient String shortId; @Override - public ProjectRelationship selectFor( final ProjectRelationship rel, final GraphPath path, + public ProjectRelationship selectFor( final ProjectRelationship rel, final GraphPath path, final RelationshipGraphConnection connection, final ViewParams params ) { final ProjectRef target = rel.getTarget() @@ -53,7 +53,7 @@ public ProjectRelationship selectFor( final ProjectRelationship rel, final } @Override - public GraphMutator getMutatorFor( final ProjectRelationship rel, final RelationshipGraphConnection connection, + public GraphMutator getMutatorFor( final ProjectRelationship rel, final RelationshipGraphConnection connection, final ViewParams params ) { return this; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractProjectRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java similarity index 59% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractProjectRelationship.java rename to relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java index 4547b781..981d8081 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractProjectRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java @@ -17,7 +17,6 @@ import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import java.io.Serializable; import java.lang.reflect.Constructor; @@ -26,8 +25,8 @@ import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.POM_ROOT_URI; -public abstract class AbstractProjectRelationship - implements ProjectRelationship, Serializable +public abstract class AbstractSimpleProjectRelationship, T extends ProjectVersionRef> + implements ProjectRelationship, Serializable { private static final long serialVersionUID = 1L; @@ -45,70 +44,73 @@ public abstract class AbstractProjectRelationship private boolean managed = false; @SuppressWarnings( "rawtypes" ) - private transient Constructor cloneCtor; + private transient Constructor cloneCtor; private URI pomLocation; private final boolean cloneUsesLocation = true; - protected AbstractProjectRelationship( final URI source, final RelationshipType type, - final ProjectVersionRef declaring, final T target, final int index ) + protected AbstractSimpleProjectRelationship( final URI source, final RelationshipType type, + final ProjectVersionRef declaring, final T target, final int index ) { this( Collections.singleton( source ), POM_ROOT_URI, type, declaring, target, index, false ); } - protected AbstractProjectRelationship( final Collection sources, final RelationshipType type, - final ProjectVersionRef declaring, final T target, final int index ) + protected AbstractSimpleProjectRelationship( final Collection sources, final RelationshipType type, + final ProjectVersionRef declaring, final T target, final int index ) { this( sources, POM_ROOT_URI, type, declaring, target, index, false ); } - protected AbstractProjectRelationship( final URI source, final RelationshipType type, - final ProjectVersionRef declaring, final T target, final int index, - final boolean managed ) + protected AbstractSimpleProjectRelationship( final URI source, final RelationshipType type, + final ProjectVersionRef declaring, final T target, final int index, + final boolean managed ) { this( Collections.singleton( source ), POM_ROOT_URI, type, declaring, target, index, managed ); } - protected AbstractProjectRelationship( final Collection sources, final RelationshipType type, - final ProjectVersionRef declaring, final T target, final int index, - final boolean managed ) + protected AbstractSimpleProjectRelationship( final Collection sources, final RelationshipType type, + final ProjectVersionRef declaring, final T target, final int index, + final boolean managed ) { this( sources, POM_ROOT_URI, type, declaring, target, index, managed ); } - protected AbstractProjectRelationship( final URI source, final URI pomLocation, final RelationshipType type, - final ProjectVersionRef declaring, final T target, final int index ) + protected AbstractSimpleProjectRelationship( final URI source, final URI pomLocation, final RelationshipType type, + final ProjectVersionRef declaring, final T target, final int index ) { this( Collections.singleton( source ), pomLocation, type, declaring, target, index, false ); } - protected AbstractProjectRelationship( final Collection sources, final URI pomLocation, - final RelationshipType type, final ProjectVersionRef declaring, - final T target, final int index ) + protected AbstractSimpleProjectRelationship( final Collection sources, final URI pomLocation, + final RelationshipType type, final ProjectVersionRef declaring, + final T target, final int index ) { this( sources, pomLocation, type, declaring, target, index, false ); } - protected AbstractProjectRelationship( final URI source, final URI pomLocation, final RelationshipType type, - final ProjectVersionRef declaring, final T target, final int index, - final boolean managed ) + protected AbstractSimpleProjectRelationship( final URI source, final URI pomLocation, final RelationshipType type, + final ProjectVersionRef declaring, final T target, final int index, + final boolean managed ) { this( Collections.singleton( source ), pomLocation, type, declaring, target, index, managed ); } - protected AbstractProjectRelationship( final Collection sources, final URI pomLocation, - final RelationshipType type, final ProjectVersionRef declaring, - final T target, final int index, final boolean managed ) + protected AbstractSimpleProjectRelationship( final Collection sources, final URI pomLocation, + final RelationshipType type, final ProjectVersionRef declaring, + final T target, final int index, final boolean managed ) { if ( sources == null ) { throw new NullPointerException( "Source URIs cannot be null" ); } - for ( final URI source : sources ) + for ( URI u : sources ) { - addSource( source ); + if ( !this.sources.contains( u ) ) + { + this.sources.add( u ); + } } this.pomLocation = pomLocation; @@ -158,9 +160,6 @@ public final T getTarget() @Override public abstract ArtifactRef getTargetArtifact(); - @Override - public abstract ProjectRelationship cloneFor( final ProjectVersionRef declaring ); - @Override public int hashCode() { @@ -187,7 +186,7 @@ public boolean equals( final Object obj ) { return false; } - final AbstractProjectRelationship other = (AbstractProjectRelationship) obj; + final AbstractSimpleProjectRelationship other = (AbstractSimpleProjectRelationship) obj; if ( declaring == null ) { if ( other.declaring != null ) @@ -213,39 +212,6 @@ else if ( !target.equals( other.target ) ) return type == other.type; } - @Override - public final void addSource( final URI source ) - { - if ( source == null ) - { - return; - } - - if ( !sources.contains( source ) ) - { - this.sources.add( source ); - } - } - - @Override - public final void addSources( final Collection sources ) - { - if ( sources == null ) - { - return; - } - - for ( final URI source : sources ) - { - if ( source == null ) - { - continue; - } - - addSource( source ); - } - } - @Override public final Set getSources() { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java index e3b09d40..20a00a5d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java @@ -1,133 +1,25 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.commonjava.maven.atlas.graph.rel; -import java.net.URI; -import java.util.Collection; - import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.version.SingleVersion; -/** NOTE: BOM relationships are actually marked as concrete. - * This may be somewhat counter-intuitive, but they are structural (like a parent POM). - * Therefore, managed isn't correct (despite Maven's unfortunate choice for location). +import java.io.Serializable; + +/** + * Created by jdcasey on 8/24/15. */ -public class BomRelationship - extends AbstractProjectRelationship +public interface BomRelationship + extends ProjectRelationship,Serializable { - - private static final long serialVersionUID = 1L; - - public BomRelationship( final Collection sources, final ProjectVersionRef d, final ProjectVersionRef t, - final int index ) - { - // BOMs are actually marked as concrete...somewhat counter-intuitive, - // but they're structural, so managed isn't quite correct (despite - // Maven's unfortunate choice for location). - super( sources, RelationshipType.BOM, d, t, index, false ); - } - - public BomRelationship( final URI source, final ProjectVersionRef d, final ProjectVersionRef t, final int index ) - { - // BOMs are actually marked as concrete...somewhat counter-intuitive, - // but they're structural, so managed isn't quite correct (despite - // Maven's unfortunate choice for location). - super( source, RelationshipType.BOM, d, t, index, false ); - } - - public BomRelationship( final Collection sources, final URI pomLocation, final ProjectVersionRef d, - final ProjectVersionRef t, final int index ) - { - // BOMs are actually marked as concrete...somewhat counter-intuitive, - // but they're structural, so managed isn't quite correct (despite - // Maven's unfortunate choice for location). - super( sources, pomLocation, RelationshipType.BOM, d, t, index, false ); - } - - public BomRelationship( final URI source, final URI pomLocation, final ProjectVersionRef d, - final ProjectVersionRef t, final int index ) - { - // BOMs are actually marked as concrete...somewhat counter-intuitive, - // but they're structural, so managed isn't quite correct (despite - // Maven's unfortunate choice for location). - super( source, pomLocation, RelationshipType.BOM, d, t, index, false ); - } - - @Override - public ArtifactRef getTargetArtifact() - { - return getTarget().asPomArtifact(); - } - @Override - public ProjectRelationship selectDeclaring( final SingleVersion version ) - { - return selectDeclaring( version, false ); - } + ArtifactRef getTargetArtifact(); @Override - public ProjectRelationship selectDeclaring( final SingleVersion version, final boolean force ) - { - final ProjectVersionRef d = getDeclaring().selectVersion( version, force ); - final ProjectVersionRef t = getTarget(); - - return new BomRelationship( getSources(), d, t, getIndex() ); - } - - @Override - public ProjectRelationship selectTarget( final SingleVersion version ) - { - return selectTarget( version, false ); - } - - @Override - public ProjectRelationship selectTarget( final SingleVersion version, final boolean force ) - { - final ProjectVersionRef d = getDeclaring(); - final ProjectVersionRef t = getTarget().selectVersion( version, force ); - - return new BomRelationship( getSources(), d, t, getIndex() ); - } - - @Override - public ProjectRelationship selectDeclaring( final ProjectVersionRef ref ) - { - final ProjectVersionRef t = getTarget(); - - return new BomRelationship( getSources(), ref, t, getIndex() ); - } - - @Override - public ProjectRelationship selectTarget( final ProjectVersionRef ref ) - { - final ProjectVersionRef d = getDeclaring(); - - return new BomRelationship( getSources(), d, ref, getIndex() ); - } + BomRelationship selectDeclaring( ProjectVersionRef ref ); @Override - public ProjectRelationship cloneFor( final ProjectVersionRef declaring ) - { - return new BomRelationship( getSources(), getPomLocation(), declaring, getTarget(), getIndex() ); - } + BomRelationship selectTarget( ProjectVersionRef ref ); @Override - public String toString() - { - return String.format( "BomRelationship [%s => %s]", getDeclaring(), getTarget() ); - } + BomRelationship cloneFor( ProjectVersionRef declaring ); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java index 9da8b7dc..827be9cf 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java @@ -1,202 +1,34 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.commonjava.maven.atlas.graph.rel; import org.commonjava.maven.atlas.ident.DependencyScope; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.version.SingleVersion; import java.io.Serializable; -import java.net.URI; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; import java.util.Set; -public final class DependencyRelationship - extends AbstractProjectRelationship - implements Serializable +/** + * Created by jdcasey on 8/24/15. + */ +public interface DependencyRelationship + extends ProjectRelationship,Serializable { - - private static final long serialVersionUID = 1L; - - private final DependencyScope scope; - - private final Set excludes; - - public DependencyRelationship( final URI source, final ProjectVersionRef declaring, final ArtifactRef target, - final DependencyScope scope, final int index, final boolean managed, - final ProjectRef... excludes ) - { - super( source, RelationshipType.DEPENDENCY, declaring, target, index, managed ); - this.scope = scope == null ? DependencyScope.compile : scope; - this.excludes = new HashSet( Arrays.asList( excludes ) ); - } - - public DependencyRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, - final ArtifactRef target, final DependencyScope scope, final int index, - final boolean managed, final ProjectRef... excludes ) - { - super( source, pomLocation, RelationshipType.DEPENDENCY, declaring, target, index, managed ); - this.scope = scope == null ? DependencyScope.compile : scope; - this.excludes = new HashSet( Arrays.asList( excludes ) ); - } - - public DependencyRelationship( final Collection sources, final ProjectVersionRef declaring, - final ArtifactRef target, final DependencyScope scope, final int index, - final boolean managed, final ProjectRef... excludes ) - { - super( sources, RelationshipType.DEPENDENCY, declaring, target, index, managed ); - this.scope = scope == null ? DependencyScope.compile : scope; - this.excludes = new HashSet( Arrays.asList( excludes ) ); - } - - public DependencyRelationship( final Collection sources, final URI pomLocation, - final ProjectVersionRef declaring, final ArtifactRef target, - final DependencyScope scope, final int index, final boolean managed, - final ProjectRef... excludes ) - { - super( sources, pomLocation, RelationshipType.DEPENDENCY, declaring, target, index, managed ); - this.scope = scope == null ? DependencyScope.compile : scope; - this.excludes = new HashSet( Arrays.asList( excludes ) ); - } - - public final DependencyScope getScope() - { - return scope; - } + DependencyScope getScope(); @Override - public synchronized ProjectRelationship cloneFor( final ProjectVersionRef projectRef ) - { - return new DependencyRelationship( getSources(), getPomLocation(), projectRef, getTarget(), scope, getIndex(), - isManaged() ); - } + DependencyRelationship cloneFor( ProjectVersionRef projectRef ); @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ( isManaged() ? 1231 : 1237 ); - return result; - } + ArtifactRef getTargetArtifact(); - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( !super.equals( obj ) ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final DependencyRelationship other = (DependencyRelationship) obj; - return isManaged() == other.isManaged(); - } - - @Override - public String toString() - { - return String.format( "DependencyRelationship [%s => %s (managed=%s, scope=%s, index=%s)]", getDeclaring(), - getTarget(), isManaged(), scope, getIndex() ); - } + Set getExcludes(); @Override - public ArtifactRef getTargetArtifact() - { - return getTarget(); - } - - public Set getExcludes() - { - return excludes; - } + DependencyRelationship selectDeclaring( ProjectVersionRef ref ); @Override - public ProjectRelationship selectDeclaring( final SingleVersion version ) - { - return selectDeclaring( version, false ); - } - - @Override - public ProjectRelationship selectDeclaring( final SingleVersion version, final boolean force ) - { - final ProjectVersionRef d = getDeclaring().selectVersion( version, force ); - final ArtifactRef t = getTarget(); - - Set var = getExcludes(); - return new DependencyRelationship( getSources(), getPomLocation(), d, t, getScope(), getIndex(), isManaged(), - var.toArray( new ProjectRef[var.size()] ) ); - } - - @Override - public ProjectRelationship selectTarget( final SingleVersion version ) - { - return selectTarget( version, false ); - } - - @Override - public ProjectRelationship selectTarget( final SingleVersion version, final boolean force ) - { - final ProjectVersionRef d = getDeclaring(); - ArtifactRef t = getTarget(); - t = new SimpleArtifactRef( t.selectVersion( version, force ), t.getType(), t.getClassifier(), t.isOptional() ); - - Set var = getExcludes(); - return new DependencyRelationship( getSources(), getPomLocation(), d, t, getScope(), getIndex(), isManaged(), - var.toArray( new ProjectRef[var.size()] ) ); - } - - @Override - public ProjectRelationship selectDeclaring( final ProjectVersionRef ref ) - { - final ArtifactRef t = getTarget(); - - Set var = getExcludes(); - return new DependencyRelationship( getSources(), getPomLocation(), ref, t, getScope(), getIndex(), isManaged(), - var.toArray( new ProjectRef[var.size()] ) ); - } - - @Override - public ProjectRelationship selectTarget( final ProjectVersionRef ref ) - { - final ProjectVersionRef d = getDeclaring(); - ArtifactRef t = getTarget(); - t = - (ArtifactRef) ( ( ref instanceof ArtifactRef ) ? ref : new SimpleArtifactRef( ref, t.getType(), - t.getClassifier(), t.isOptional() ) ); - - Set var = getExcludes(); - return new DependencyRelationship( getSources(), getPomLocation(), d, t, getScope(), getIndex(), isManaged(), - var.toArray( new ProjectRef[var.size()] ) ); - } - - public boolean isBOM() - { - return DependencyScope._import == getScope() && "pom".equals( getTargetArtifact().getType() ); - } + DependencyRelationship selectTarget( ProjectVersionRef ref ); + boolean isBOM(); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java index e7e76ccd..ac5a8c08 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java @@ -1,123 +1,25 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.commonjava.maven.atlas.graph.rel; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.version.SingleVersion; import java.io.Serializable; -import java.net.URI; -import java.util.Collection; -public final class ExtensionRelationship - extends AbstractProjectRelationship - implements Serializable +/** + * Created by jdcasey on 8/24/15. + */ +public interface ExtensionRelationship + extends ProjectRelationship,Serializable { - - private static final long serialVersionUID = 1L; - - public ExtensionRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, - final ProjectVersionRef target, final int index ) - { - super( source, pomLocation, RelationshipType.EXTENSION, declaring, target, index ); - } - - public ExtensionRelationship( final Collection sources, final URI pomLocation, - final ProjectVersionRef declaring, final ProjectVersionRef target, final int index ) - { - super( sources, pomLocation, RelationshipType.EXTENSION, declaring, target, index ); - } - - public ExtensionRelationship( final URI source, final ProjectVersionRef declaring, final ProjectVersionRef target, - final int index ) - { - super( source, RelationshipUtils.POM_ROOT_URI, RelationshipType.EXTENSION, declaring, target, index ); - } - - public ExtensionRelationship( final Collection sources, final ProjectVersionRef declaring, - final ProjectVersionRef target, final int index ) - { - super( sources, RelationshipUtils.POM_ROOT_URI, RelationshipType.EXTENSION, declaring, target, index ); - } - @Override - public String toString() - { - return String.format( "ExtensionRelationship [%s => %s (index=%s)]", getDeclaring(), getTarget(), getIndex() ); - } + ArtifactRef getTargetArtifact(); @Override - public ArtifactRef getTargetArtifact() - { - return new SimpleArtifactRef( getTarget(), null, null, false ); - } + ExtensionRelationship selectDeclaring( ProjectVersionRef ref ); @Override - public ProjectRelationship selectDeclaring( final SingleVersion version ) - { - return selectDeclaring( version, false ); - } - - @Override - public ProjectRelationship selectDeclaring( final SingleVersion version, final boolean force ) - { - final ProjectVersionRef d = getDeclaring().selectVersion( version, force ); - final ProjectVersionRef t = getTarget(); - - return new ExtensionRelationship( getSources(), getPomLocation(), d, t, getIndex() ); - } + ExtensionRelationship selectTarget( ProjectVersionRef ref ); @Override - public ProjectRelationship selectTarget( final SingleVersion version ) - { - return selectTarget( version, false ); - } - - @Override - public ProjectRelationship selectTarget( final SingleVersion version, final boolean force ) - { - final ProjectVersionRef d = getDeclaring(); - final ProjectVersionRef t = getTarget().selectVersion( version, force ); - - return new ExtensionRelationship( getSources(), getPomLocation(), d, t, getIndex() ); - } - - @Override - public ProjectRelationship selectDeclaring( final ProjectVersionRef ref ) - { - final ProjectVersionRef t = getTarget(); - - return new ExtensionRelationship( getSources(), getPomLocation(), ref, t, getIndex() ); - } - - @Override - public ProjectRelationship selectTarget( final ProjectVersionRef ref ) - { - final ProjectVersionRef d = getDeclaring(); - - return new ExtensionRelationship( getSources(), getPomLocation(), d, ref, getIndex() ); - } - - @Override - public ProjectRelationship cloneFor( final ProjectVersionRef declaring ) - { - return new ExtensionRelationship( getSources(), getPomLocation(), declaring, getTarget(), getIndex() ); - } - + ExtensionRelationship cloneFor( ProjectVersionRef declaring ); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java index 84f4de83..1ba6655a 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java @@ -1,154 +1,28 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.commonjava.maven.atlas.graph.rel; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.version.SingleVersion; import java.io.Serializable; import java.net.URI; -import java.net.URISyntaxException; -import java.util.Collection; -public final class ParentRelationship - extends AbstractProjectRelationship - implements Serializable +/** + * Created by jdcasey on 8/24/15. + */ +public interface ParentRelationship + extends ProjectRelationship,Serializable { - - private static final long serialVersionUID = 1L; - - public static final URI TERMINAL_PARENT_SOURCE_URI; - static - { - final String uri = "atlas:terminal-parent"; - try - { - TERMINAL_PARENT_SOURCE_URI = new URI( uri ); - } - catch ( final URISyntaxException e ) - { - throw new IllegalStateException( "Terminal-parent source URI constant is invalid: " + uri, e ); - } - - } - - /** - * Ancestry terminus. This is to signify that the declaring project has NO parent relationship. - */ - public ParentRelationship( final ProjectVersionRef declaring ) - { - super( TERMINAL_PARENT_SOURCE_URI, RelationshipType.PARENT, declaring, declaring, 0 ); - } - - /** - * Ancestry terminus. This is to signify that the declaring project has NO parent relationship. - * This form is deprecated. - * @see ParentRelationship#ParentRelationship(ProjectVersionRef) - */ - @Deprecated - public ParentRelationship( final URI unused, final ProjectVersionRef declaring ) - { - super( TERMINAL_PARENT_SOURCE_URI, RelationshipType.PARENT, declaring, declaring, 0 ); - } - - public ParentRelationship( final URI source, final ProjectVersionRef declaring, final ProjectVersionRef target ) - { - super( source, RelationshipType.PARENT, declaring, target, 0 ); - } - - public ParentRelationship( final Collection sources, final ProjectVersionRef declaring, - final ProjectVersionRef target ) - { - super( sources, RelationshipType.PARENT, declaring, target, 0 ); - } - - @Override - public String toString() - { - return String.format( "ParentRelationship [%s => %s]", getDeclaring(), getTarget() ); - } - @Override - public ArtifactRef getTargetArtifact() - { - return new SimpleArtifactRef( getTarget(), "pom", null, false ); - } + ArtifactRef getTargetArtifact(); - public boolean isTerminus() - { - return getDeclaring().equals( getTarget() ); - } + boolean isTerminus(); @Override - public ProjectRelationship selectDeclaring( final SingleVersion version ) - { - return selectDeclaring( version, false ); - } + ParentRelationship selectDeclaring( ProjectVersionRef ref ); @Override - public ProjectRelationship selectDeclaring( final SingleVersion version, final boolean force ) - { - ProjectVersionRef d = getDeclaring(); - final ProjectVersionRef t = getTarget(); - final boolean self = d.equals( t ); - - d = d.selectVersion( version, force ); - - return new ParentRelationship( getSources(), d, self ? d : t ); - } - - @Override - public ProjectRelationship selectTarget( final SingleVersion version ) - { - return selectTarget( version, false ); - } - - @Override - public ProjectRelationship selectTarget( final SingleVersion version, final boolean force ) - { - final ProjectVersionRef d = getDeclaring(); - ProjectVersionRef t = getTarget(); - final boolean self = d.equals( t ); - - t = t.selectVersion( version, force ); - - return new ParentRelationship( getSources(), self ? t : d, t ); - } - - @Override - public ProjectRelationship selectDeclaring( final ProjectVersionRef ref ) - { - final ProjectVersionRef t = getTarget(); - - return new ParentRelationship( getSources(), ref, t ); - } + ParentRelationship selectTarget( ProjectVersionRef ref ); @Override - public ProjectRelationship selectTarget( final ProjectVersionRef ref ) - { - final ProjectVersionRef d = getDeclaring(); - return new ParentRelationship( getSources(), d, ref ); - } - - @Override - public ProjectRelationship cloneFor( final ProjectVersionRef declaring ) - { - return new ParentRelationship( getSources(), declaring, getTarget() ); - } - + ParentRelationship cloneFor( ProjectVersionRef declaring ); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java index 3f1a4206..c148830d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java @@ -1,184 +1,28 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.commonjava.maven.atlas.graph.rel; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.version.SingleVersion; import java.io.Serializable; -import java.net.URI; -import java.util.Collection; -public final class PluginDependencyRelationship - extends AbstractProjectRelationship - implements Serializable +/** + * Created by jdcasey on 8/24/15. + */ +public interface PluginDependencyRelationship + extends ProjectRelationship,Serializable { - - private static final long serialVersionUID = 1L; - - private final ProjectRef plugin; - - public PluginDependencyRelationship( final URI source, final ProjectVersionRef declaring, final ProjectRef plugin, - final ArtifactRef target, final int index, final boolean managed ) - { - super( source, RelationshipType.PLUGIN_DEP, declaring, target, index, managed ); - this.plugin = plugin; - } - - public PluginDependencyRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, - final ProjectRef plugin, final ArtifactRef target, final int index, - final boolean managed ) - { - super( source, pomLocation, RelationshipType.PLUGIN_DEP, declaring, target, index, managed ); - this.plugin = plugin; - } - - public PluginDependencyRelationship( final Collection sources, final URI pomLocation, - final ProjectVersionRef declaring, final ProjectRef plugin, - final ArtifactRef target, final int index, final boolean managed ) - { - super( sources, pomLocation, RelationshipType.PLUGIN_DEP, declaring, target, index, managed ); - this.plugin = plugin; - } - - public final ProjectRef getPlugin() - { - return plugin; - } - - @Override - public synchronized ProjectRelationship cloneFor( final ProjectVersionRef projectRef ) - { - return new PluginDependencyRelationship( getSources(), getPomLocation(), projectRef, plugin, getTarget(), - getIndex(), isManaged() ); - } + ProjectRef getPlugin(); @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ( isManaged() ? 1231 : 1237 ); - result = prime * result + ( ( plugin == null ) ? 0 : plugin.hashCode() ); - return result; - } + PluginDependencyRelationship cloneFor( ProjectVersionRef projectRef ); @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( !super.equals( obj ) ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final PluginDependencyRelationship other = (PluginDependencyRelationship) obj; - if ( isManaged() != other.isManaged() ) - { - return false; - } - if ( plugin == null ) - { - if ( other.plugin != null ) - { - return false; - } - } - else if ( !plugin.equals( other.plugin ) ) - { - return false; - } - return true; - } + ArtifactRef getTargetArtifact(); @Override - public String toString() - { - return String.format( "PluginDependencyRelationship [%s -> (%s) => %s (managed=%s, index=%s)]", getDeclaring(), - plugin, getTarget(), isManaged(), getIndex() ); - } + PluginDependencyRelationship selectDeclaring( ProjectVersionRef ref ); @Override - public ArtifactRef getTargetArtifact() - { - return getTarget(); - } - - @Override - public ProjectRelationship selectDeclaring( final SingleVersion version ) - { - return selectDeclaring( version, false ); - } - - @Override - public ProjectRelationship selectDeclaring( final SingleVersion version, final boolean force ) - { - final ProjectVersionRef d = getDeclaring().selectVersion( version, force ); - final ArtifactRef t = getTarget(); - - return new PluginDependencyRelationship( getSources(), getPomLocation(), d, getPlugin(), t, getIndex(), - isManaged() ); - } - - @Override - public ProjectRelationship selectTarget( final SingleVersion version ) - { - return selectTarget( version, false ); - } - - @Override - public ProjectRelationship selectTarget( final SingleVersion version, final boolean force ) - { - final ProjectVersionRef d = getDeclaring(); - ArtifactRef t = getTarget(); - t = new SimpleArtifactRef( t.selectVersion( version, force ), t.getType(), t.getClassifier(), t.isOptional() ); - - return new PluginDependencyRelationship( getSources(), getPomLocation(), d, getPlugin(), t, getIndex(), - isManaged() ); - } - - @Override - public ProjectRelationship selectDeclaring( final ProjectVersionRef ref ) - { - final ArtifactRef t = getTarget(); - - return new PluginDependencyRelationship( getSources(), getPomLocation(), ref, getPlugin(), t, getIndex(), - isManaged() ); - } - - @Override - public ProjectRelationship selectTarget( final ProjectVersionRef ref ) - { - final ProjectVersionRef d = getDeclaring(); - ArtifactRef t = getTarget(); - t = - (ArtifactRef) ( ( ref instanceof ArtifactRef ) ? ref : new SimpleArtifactRef( ref, t.getType(), - t.getClassifier(), t.isOptional() ) ); - - return new PluginDependencyRelationship( getSources(), getPomLocation(), d, getPlugin(), t, getIndex(), - isManaged() ); - } - + PluginDependencyRelationship selectTarget( ProjectVersionRef ref ); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java index 73367926..e844ff01 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java @@ -1,171 +1,27 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.commonjava.maven.atlas.graph.rel; -import java.io.Serializable; -import java.net.URI; -import java.util.Collection; - import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.ident.version.SingleVersion; - -public final class PluginRelationship - extends AbstractProjectRelationship - implements Serializable -{ - - private static final long serialVersionUID = 1L; - - private final boolean reporting; - - public PluginRelationship( final URI source, final ProjectVersionRef declaring, final ProjectVersionRef target, - final int index, final boolean managed ) - { - this( source, declaring, target, index, managed, false ); - } - - public PluginRelationship( final URI source, final ProjectVersionRef declaring, final ProjectVersionRef target, - final int index, final boolean managed, final boolean reporting ) - { - super( source, RelationshipType.PLUGIN, declaring, target, index, managed ); - this.reporting = reporting; - } - - public PluginRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, - final ProjectVersionRef target, final int index, final boolean managed ) - { - this( source, pomLocation, declaring, target, index, managed, false ); - } - - public PluginRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, - final ProjectVersionRef target, final int index, final boolean managed, - final boolean reporting ) - { - super( source, pomLocation, RelationshipType.PLUGIN, declaring, target, index, managed ); - this.reporting = reporting; - } - - public PluginRelationship( final Collection sources, final URI pomLocation, final ProjectVersionRef declaring, - final ProjectVersionRef target, final int index, final boolean managed, - final boolean reporting ) - { - super( sources, pomLocation, RelationshipType.PLUGIN, declaring, target, index, managed ); - this.reporting = reporting; - } - - public final boolean isReporting() - { - return reporting; - } - - @Override - public synchronized ProjectRelationship cloneFor( final ProjectVersionRef projectRef ) - { - return new PluginRelationship( getSources(), getPomLocation(), projectRef, getTarget(), getIndex(), - isManaged(), reporting ); - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ( isManaged() ? 1231 : 1237 ); - return result; - } - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( !super.equals( obj ) ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final PluginRelationship other = (PluginRelationship) obj; - return isManaged() == other.isManaged(); - } - - @Override - public String toString() - { - return String.format( "PluginRelationship [%s => %s (managed=%s, index=%s)]", getDeclaring(), getTarget(), - isManaged(), getIndex() ); - } - - @Override - public ArtifactRef getTargetArtifact() - { - return new SimpleArtifactRef( getTarget(), "maven-plugin", null, false ); - } - - @Override - public ProjectRelationship selectDeclaring( final SingleVersion version ) - { - return selectDeclaring( version, false ); - } - - @Override - public ProjectRelationship selectDeclaring( final SingleVersion version, final boolean force ) - { - final ProjectVersionRef d = getDeclaring().selectVersion( version, force ); - final ProjectVersionRef t = getTarget(); +import java.io.Serializable; - return new PluginRelationship( getSources(), getPomLocation(), d, t, getIndex(), isManaged(), isReporting() ); - } +/** + * Created by jdcasey on 8/24/15. + */ +public interface PluginRelationship + extends ProjectRelationship,Serializable +{ + boolean isReporting(); @Override - public ProjectRelationship selectTarget( final SingleVersion version ) - { - return selectTarget( version, false ); - } + PluginRelationship cloneFor( ProjectVersionRef projectRef ); @Override - public ProjectRelationship selectTarget( final SingleVersion version, final boolean force ) - { - final ProjectVersionRef d = getDeclaring(); - final ProjectVersionRef t = getTarget().selectVersion( version, force ); - - return new PluginRelationship( getSources(), getPomLocation(), d, t, getIndex(), isManaged(), isReporting() ); - } + ArtifactRef getTargetArtifact(); @Override - public ProjectRelationship selectDeclaring( final ProjectVersionRef ref ) - { - final ProjectVersionRef t = getTarget(); - - return new PluginRelationship( getSources(), getPomLocation(), ref, t, getIndex(), isManaged(), isReporting() ); - } + PluginRelationship selectDeclaring( ProjectVersionRef ref ); @Override - public ProjectRelationship selectTarget( final ProjectVersionRef ref ) - { - final ProjectVersionRef d = getDeclaring(); - - return new PluginRelationship( getSources(), getPomLocation(), d, ref, getIndex(), isManaged(), isReporting() ); - } - + PluginRelationship selectTarget( ProjectVersionRef ref ); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ProjectRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ProjectRelationship.java index 7a136273..ab697880 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ProjectRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ProjectRelationship.java @@ -26,7 +26,7 @@ import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.commonjava.maven.atlas.ident.version.SingleVersion; -public interface ProjectRelationship +public interface ProjectRelationship, T extends ProjectVersionRef> extends Serializable { @@ -40,31 +40,19 @@ public interface ProjectRelationship ArtifactRef getTargetArtifact(); - ProjectRelationship cloneFor( final ProjectVersionRef projectRef ); + R cloneFor( final ProjectVersionRef projectRef ); - @Deprecated - ProjectRelationship selectDeclaring( SingleVersion version ); + R selectDeclaring( ProjectVersionRef ref ); - @Deprecated - ProjectRelationship selectDeclaring( SingleVersion version, boolean force ); - - @Deprecated - ProjectRelationship selectTarget( SingleVersion version ); - - @Deprecated - ProjectRelationship selectTarget( SingleVersion version, boolean force ); - - ProjectRelationship selectDeclaring( ProjectVersionRef ref ); - - ProjectRelationship selectTarget( ProjectVersionRef ref ); + R selectTarget( ProjectVersionRef ref ); boolean isManaged(); Set getSources(); - void addSource( URI source ); + R addSource( URI source ); - void addSources( Collection sources ); + R addSources( Collection sources ); URI getPomLocation(); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparator.java index 0d52fa39..7c95cd24 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparator.java @@ -20,7 +20,7 @@ import java.util.Comparator; public final class RelationshipComparator - implements Comparator> + implements Comparator> { public static final RelationshipComparator INSTANCE = new RelationshipComparator(); @@ -30,7 +30,7 @@ private RelationshipComparator() } @Override - public int compare( final ProjectRelationship one, final ProjectRelationship two ) + public int compare( final ProjectRelationship one, final ProjectRelationship two ) { if ( one.getType() == two.getType() ) { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparator.java index 313fe520..5795144d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparator.java @@ -22,7 +22,7 @@ import java.util.List; public class RelationshipPathComparator - implements Comparator>> + implements Comparator>> { public static RelationshipPathComparator INSTANCE = new RelationshipPathComparator(); @@ -34,7 +34,7 @@ private RelationshipPathComparator() } @Override - public int compare( final List> one, final List> two ) + public int compare( final List> one, final List> two ) { Logger logger = LoggerFactory.getLogger( getClass() ); logger.debug("Comparing:\nOne: {}\nTwo: {}", one, two); @@ -71,12 +71,12 @@ else if ( two.size() > commonLen ) return 0; } - private int compareRels( final ProjectRelationship one, final ProjectRelationship two ) + private int compareRels( final ProjectRelationship one, final ProjectRelationship two ) { return comp.compare( one, two ); } - private int compareRelTypes( final ProjectRelationship one, final ProjectRelationship two ) + private int compareRelTypes( final ProjectRelationship one, final ProjectRelationship two ) { return one.getType() .ordinal() - two.getType() diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleBomRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleBomRelationship.java new file mode 100644 index 00000000..8b5b6375 --- /dev/null +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleBomRelationship.java @@ -0,0 +1,123 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.rel; + +import java.net.URI; +import java.util.Collection; +import java.util.Set; + +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; + +/** NOTE: BOM relationships are actually marked as concrete. + * This may be somewhat counter-intuitive, but they are structural (like a parent POM). + * Therefore, managed isn't correct (despite Maven's unfortunate choice for location). + */ +public class SimpleBomRelationship + extends AbstractSimpleProjectRelationship + implements BomRelationship +{ + + private static final long serialVersionUID = 1L; + + public SimpleBomRelationship( final Collection sources, final ProjectVersionRef d, final ProjectVersionRef t, + final int index ) + { + // BOMs are actually marked as concrete...somewhat counter-intuitive, + // but they're structural, so managed isn't quite correct (despite + // Maven's unfortunate choice for location). + super( sources, RelationshipType.BOM, d, t, index, false ); + } + + public SimpleBomRelationship( final URI source, final ProjectVersionRef d, final ProjectVersionRef t, + final int index ) + { + // BOMs are actually marked as concrete...somewhat counter-intuitive, + // but they're structural, so managed isn't quite correct (despite + // Maven's unfortunate choice for location). + super( source, RelationshipType.BOM, d, t, index, false ); + } + + public SimpleBomRelationship( final Collection sources, final URI pomLocation, final ProjectVersionRef d, + final ProjectVersionRef t, final int index ) + { + // BOMs are actually marked as concrete...somewhat counter-intuitive, + // but they're structural, so managed isn't quite correct (despite + // Maven's unfortunate choice for location). + super( sources, pomLocation, RelationshipType.BOM, d, t, index, false ); + } + + public SimpleBomRelationship( final URI source, final URI pomLocation, final ProjectVersionRef d, + final ProjectVersionRef t, final int index ) + { + // BOMs are actually marked as concrete...somewhat counter-intuitive, + // but they're structural, so managed isn't quite correct (despite + // Maven's unfortunate choice for location). + super( source, pomLocation, RelationshipType.BOM, d, t, index, false ); + } + + @Override + public ArtifactRef getTargetArtifact() + { + return getTarget().asPomArtifact(); + } + + @Override + public BomRelationship selectDeclaring( final ProjectVersionRef ref ) + { + final ProjectVersionRef t = getTarget(); + + return new SimpleBomRelationship( getSources(), ref, t, getIndex() ); + } + + @Override + public BomRelationship selectTarget( final ProjectVersionRef ref ) + { + final ProjectVersionRef d = getDeclaring(); + + return new SimpleBomRelationship( getSources(), d, ref, getIndex() ); + } + + @Override + public BomRelationship cloneFor( final ProjectVersionRef declaring ) + { + return new SimpleBomRelationship( getSources(), getPomLocation(), declaring, getTarget(), getIndex() ); + } + + @Override + public BomRelationship addSource( URI source ) + { + Set srcs = getSources(); + srcs.add( source ); + return new SimpleBomRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), + getIndex() ); + } + + @Override + public BomRelationship addSources( Collection sources ) + { + Set srcs = getSources(); + srcs.addAll( sources ); + return new SimpleBomRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), + getIndex() ); + } + + @Override + public String toString() + { + return String.format( "BomRelationship [%s => %s]", getDeclaring(), getTarget() ); + } +} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java new file mode 100644 index 00000000..bf174c0b --- /dev/null +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java @@ -0,0 +1,187 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.rel; + +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; + +import java.io.Serializable; +import java.net.URI; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +public final class SimpleDependencyRelationship + extends AbstractSimpleProjectRelationship + implements Serializable, DependencyRelationship +{ + + private static final long serialVersionUID = 1L; + + private final DependencyScope scope; + + private final Set excludes; + + public SimpleDependencyRelationship( final URI source, final ProjectVersionRef declaring, final ArtifactRef target, + final DependencyScope scope, final int index, final boolean managed, + final ProjectRef... excludes ) + { + super( source, RelationshipType.DEPENDENCY, declaring, target, index, managed ); + this.scope = scope == null ? DependencyScope.compile : scope; + this.excludes = new HashSet( Arrays.asList( excludes ) ); + } + + public SimpleDependencyRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, + final ArtifactRef target, final DependencyScope scope, final int index, + final boolean managed, final ProjectRef... excludes ) + { + super( source, pomLocation, RelationshipType.DEPENDENCY, declaring, target, index, managed ); + this.scope = scope == null ? DependencyScope.compile : scope; + this.excludes = new HashSet( Arrays.asList( excludes ) ); + } + + public SimpleDependencyRelationship( final Collection sources, final ProjectVersionRef declaring, + final ArtifactRef target, final DependencyScope scope, final int index, + final boolean managed, final ProjectRef... excludes ) + { + super( sources, RelationshipType.DEPENDENCY, declaring, target, index, managed ); + this.scope = scope == null ? DependencyScope.compile : scope; + this.excludes = new HashSet( Arrays.asList( excludes ) ); + } + + public SimpleDependencyRelationship( final Collection sources, final URI pomLocation, + final ProjectVersionRef declaring, final ArtifactRef target, + final DependencyScope scope, final int index, final boolean managed, + final ProjectRef... excludes ) + { + super( sources, pomLocation, RelationshipType.DEPENDENCY, declaring, target, index, managed ); + this.scope = scope == null ? DependencyScope.compile : scope; + this.excludes = new HashSet( Arrays.asList( excludes ) ); + } + + @Override + public final DependencyScope getScope() + { + return scope; + } + + @Override + public synchronized DependencyRelationship cloneFor( final ProjectVersionRef projectRef ) + { + return new SimpleDependencyRelationship( getSources(), getPomLocation(), projectRef, getTarget(), scope, getIndex(), + isManaged() ); + } + + @Override + public DependencyRelationship addSource( URI source ) + { + Set srcs = getSources(); + srcs.add( source ); + return new SimpleDependencyRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), scope, getIndex(), + isManaged() ); + } + + @Override + public DependencyRelationship addSources( Collection sources ) + { + Set srcs = getSources(); + srcs.addAll( sources ); + return new SimpleDependencyRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), scope, getIndex(), + isManaged() ); + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ( isManaged() ? 1231 : 1237 ); + return result; + } + + @Override + public boolean equals( final Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( !super.equals( obj ) ) + { + return false; + } + if ( getClass() != obj.getClass() ) + { + return false; + } + final DependencyRelationship other = (DependencyRelationship) obj; + return isManaged() == other.isManaged(); + } + + @Override + public String toString() + { + return String.format( "DependencyRelationship [%s => %s (managed=%s, scope=%s, index=%s)]", getDeclaring(), + getTarget(), isManaged(), scope, getIndex() ); + } + + @Override + public ArtifactRef getTargetArtifact() + { + return getTarget(); + } + + @Override + public Set getExcludes() + { + return excludes; + } + + @Override + public DependencyRelationship selectDeclaring( final ProjectVersionRef ref ) + { + final ArtifactRef t = getTarget(); + + Set var = getExcludes(); + return new SimpleDependencyRelationship( getSources(), getPomLocation(), ref, t, getScope(), getIndex(), isManaged(), + var.toArray( new ProjectRef[var.size()] ) ); + } + + @Override + public DependencyRelationship selectTarget( final ProjectVersionRef ref ) + { + final ProjectVersionRef d = getDeclaring(); + ArtifactRef t = getTarget(); + t = + (ArtifactRef) ( ( ref instanceof ArtifactRef ) ? ref : new SimpleArtifactRef( ref, t.getType(), + t.getClassifier(), t.isOptional() ) ); + + Set var = getExcludes(); + return new SimpleDependencyRelationship( getSources(), getPomLocation(), d, t, getScope(), getIndex(), isManaged(), + var.toArray( new ProjectRef[var.size()] ) ); + } + + @Override + public boolean isBOM() + { + return DependencyScope._import == getScope() && "pom".equals( getTargetArtifact().getType() ); + } + +} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java new file mode 100644 index 00000000..251910e6 --- /dev/null +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java @@ -0,0 +1,109 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.rel; + +import org.commonjava.maven.atlas.graph.util.RelationshipUtils; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; + +import java.io.Serializable; +import java.net.URI; +import java.util.Collection; +import java.util.Set; + +public final class SimpleExtensionRelationship + extends AbstractSimpleProjectRelationship + implements Serializable, ExtensionRelationship +{ + + private static final long serialVersionUID = 1L; + + public SimpleExtensionRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, + final ProjectVersionRef target, final int index ) + { + super( source, pomLocation, RelationshipType.EXTENSION, declaring, target, index ); + } + + public SimpleExtensionRelationship( final Collection sources, final URI pomLocation, + final ProjectVersionRef declaring, final ProjectVersionRef target, + final int index ) + { + super( sources, pomLocation, RelationshipType.EXTENSION, declaring, target, index ); + } + + public SimpleExtensionRelationship( final URI source, final ProjectVersionRef declaring, + final ProjectVersionRef target, final int index ) + { + super( source, RelationshipUtils.POM_ROOT_URI, RelationshipType.EXTENSION, declaring, target, index ); + } + + public SimpleExtensionRelationship( final Collection sources, final ProjectVersionRef declaring, + final ProjectVersionRef target, final int index ) + { + super( sources, RelationshipUtils.POM_ROOT_URI, RelationshipType.EXTENSION, declaring, target, index ); + } + + @Override + public String toString() + { + return String.format( "ExtensionRelationship [%s => %s (index=%s)]", getDeclaring(), getTarget(), getIndex() ); + } + + @Override + public ArtifactRef getTargetArtifact() + { + return new SimpleArtifactRef( getTarget(), null, null, false ); + } + + @Override + public ExtensionRelationship selectDeclaring( final ProjectVersionRef ref ) + { + final ProjectVersionRef t = getTarget(); + + return new SimpleExtensionRelationship( getSources(), getPomLocation(), ref, t, getIndex() ); + } + + @Override + public ExtensionRelationship selectTarget( final ProjectVersionRef ref ) + { + final ProjectVersionRef d = getDeclaring(); + + return new SimpleExtensionRelationship( getSources(), getPomLocation(), d, ref, getIndex() ); + } + + @Override + public ExtensionRelationship cloneFor( final ProjectVersionRef declaring ) + { + return new SimpleExtensionRelationship( getSources(), getPomLocation(), declaring, getTarget(), getIndex() ); + } + + @Override + public ExtensionRelationship addSource( URI source ) + { + Set srcs = getSources(); + srcs.add( source ); + return new SimpleExtensionRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), getIndex() ); + } + + @Override + public ExtensionRelationship addSources( Collection sources ) + { + Set srcs = getSources(); + srcs.addAll( sources ); + return new SimpleExtensionRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), getIndex() ); + } +} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java new file mode 100644 index 00000000..5d9ab264 --- /dev/null +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java @@ -0,0 +1,120 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.rel; + +import org.commonjava.maven.atlas.graph.util.RelationshipUtils; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; + +import java.io.Serializable; +import java.net.URI; +import java.util.Collection; +import java.util.Set; + +public final class SimpleParentRelationship + extends AbstractSimpleProjectRelationship + implements Serializable, ParentRelationship +{ + + private static final long serialVersionUID = 1L; + + /** + * Ancestry terminus. This is to signify that the declaring project has NO parent relationship. + */ + public SimpleParentRelationship( final ProjectVersionRef declaring ) + { + super( RelationshipUtils.TERMINAL_PARENT_SOURCE_URI, RelationshipType.PARENT, declaring, declaring, 0 ); + } + + /** + * Ancestry terminus. This is to signify that the declaring project has NO parent relationship. + * This form is deprecated. + * @see SimpleParentRelationship(ProjectVersionRef) + */ + @Deprecated + public SimpleParentRelationship( final URI unused, final ProjectVersionRef declaring ) + { + super( RelationshipUtils.TERMINAL_PARENT_SOURCE_URI, RelationshipType.PARENT, declaring, declaring, 0 ); + } + + public SimpleParentRelationship( final URI source, final ProjectVersionRef declaring, + final ProjectVersionRef target ) + { + super( source, RelationshipType.PARENT, declaring, target, 0 ); + } + + public SimpleParentRelationship( final Collection sources, final ProjectVersionRef declaring, + final ProjectVersionRef target ) + { + super( sources, RelationshipType.PARENT, declaring, target, 0 ); + } + + @Override + public String toString() + { + return String.format( "ParentRelationship [%s => %s]", getDeclaring(), getTarget() ); + } + + @Override + public ArtifactRef getTargetArtifact() + { + return new SimpleArtifactRef( getTarget(), "pom", null, false ); + } + + @Override + public boolean isTerminus() + { + return getDeclaring().equals( getTarget() ); + } + + @Override + public ParentRelationship selectDeclaring( final ProjectVersionRef ref ) + { + final ProjectVersionRef t = getTarget(); + + return new SimpleParentRelationship( getSources(), ref, t ); + } + + @Override + public ParentRelationship selectTarget( final ProjectVersionRef ref ) + { + final ProjectVersionRef d = getDeclaring(); + return new SimpleParentRelationship( getSources(), d, ref ); + } + + @Override + public ParentRelationship cloneFor( final ProjectVersionRef declaring ) + { + return new SimpleParentRelationship( getSources(), declaring, getTarget() ); + } + + @Override + public ParentRelationship addSource( URI source ) + { + Set srcs = getSources(); + srcs.add( source ); + return new SimpleParentRelationship( srcs, getDeclaring(), getTarget() ); + } + + @Override + public ParentRelationship addSources( Collection sources ) + { + Set srcs = getSources(); + srcs.addAll( sources ); + return new SimpleParentRelationship( srcs, getDeclaring(), getTarget() ); + } +} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java new file mode 100644 index 00000000..86cde7cd --- /dev/null +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java @@ -0,0 +1,170 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.rel; + +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; + +import java.io.Serializable; +import java.net.URI; +import java.util.Collection; +import java.util.Set; + +public final class SimplePluginDependencyRelationship + extends AbstractSimpleProjectRelationship + implements Serializable, PluginDependencyRelationship +{ + + private static final long serialVersionUID = 1L; + + private final ProjectRef plugin; + + public SimplePluginDependencyRelationship( final URI source, final ProjectVersionRef declaring, + final ProjectRef plugin, final ArtifactRef target, final int index, + final boolean managed ) + { + super( source, RelationshipType.PLUGIN_DEP, declaring, target, index, managed ); + this.plugin = plugin; + } + + public SimplePluginDependencyRelationship( final URI source, final URI pomLocation, + final ProjectVersionRef declaring, final ProjectRef plugin, + final ArtifactRef target, final int index, final boolean managed ) + { + super( source, pomLocation, RelationshipType.PLUGIN_DEP, declaring, target, index, managed ); + this.plugin = plugin; + } + + public SimplePluginDependencyRelationship( final Collection sources, final URI pomLocation, + final ProjectVersionRef declaring, final ProjectRef plugin, + final ArtifactRef target, final int index, final boolean managed ) + { + super( sources, pomLocation, RelationshipType.PLUGIN_DEP, declaring, target, index, managed ); + this.plugin = plugin; + } + + @Override + public final ProjectRef getPlugin() + { + return plugin; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ( isManaged() ? 1231 : 1237 ); + result = prime * result + ( ( plugin == null ) ? 0 : plugin.hashCode() ); + return result; + } + + @Override + public boolean equals( final Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( !super.equals( obj ) ) + { + return false; + } + if ( getClass() != obj.getClass() ) + { + return false; + } + final SimplePluginDependencyRelationship other = (SimplePluginDependencyRelationship) obj; + if ( isManaged() != other.isManaged() ) + { + return false; + } + if ( plugin == null ) + { + if ( other.plugin != null ) + { + return false; + } + } + else if ( !plugin.equals( other.plugin ) ) + { + return false; + } + return true; + } + + @Override + public String toString() + { + return String.format( "PluginDependencyRelationship [%s -> (%s) => %s (managed=%s, index=%s)]", getDeclaring(), + plugin, getTarget(), isManaged(), getIndex() ); + } + + @Override + public ArtifactRef getTargetArtifact() + { + return getTarget(); + } + + @Override + public PluginDependencyRelationship selectDeclaring( final ProjectVersionRef ref ) + { + final ArtifactRef t = getTarget(); + + return new SimplePluginDependencyRelationship( getSources(), getPomLocation(), ref, getPlugin(), t, getIndex(), + isManaged() ); + } + + @Override + public PluginDependencyRelationship selectTarget( final ProjectVersionRef ref ) + { + final ProjectVersionRef d = getDeclaring(); + ArtifactRef t = getTarget(); + t = + (ArtifactRef) ( ( ref instanceof ArtifactRef ) ? ref : new SimpleArtifactRef( ref, t.getType(), + t.getClassifier(), t.isOptional() ) ); + + return new SimplePluginDependencyRelationship( getSources(), getPomLocation(), d, getPlugin(), t, getIndex(), + isManaged() ); + } + + @Override + public synchronized PluginDependencyRelationship cloneFor( final ProjectVersionRef projectRef ) + { + return new SimplePluginDependencyRelationship( getSources(), getPomLocation(), projectRef, plugin, getTarget(), + getIndex(), isManaged() ); + } + + @Override + public PluginDependencyRelationship addSource( URI source ) + { + Set srcs = getSources(); + srcs.add( source ); + return new SimplePluginDependencyRelationship( srcs, getPomLocation(), getDeclaring(), plugin, getTarget(), + getIndex(), isManaged() ); + } + + @Override + public PluginDependencyRelationship addSources( Collection sources ) + { + Set srcs = getSources(); + srcs.addAll( sources ); + return new SimplePluginDependencyRelationship( srcs, getPomLocation(), getDeclaring(), plugin, getTarget(), + getIndex(), isManaged() ); + } +} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java new file mode 100644 index 00000000..577a44be --- /dev/null +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java @@ -0,0 +1,159 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.rel; + +import java.io.Serializable; +import java.net.URI; +import java.util.Collection; +import java.util.Set; + +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; + +public final class SimplePluginRelationship + extends AbstractSimpleProjectRelationship + implements Serializable, PluginRelationship +{ + + private static final long serialVersionUID = 1L; + + private final boolean reporting; + + public SimplePluginRelationship( final URI source, final ProjectVersionRef declaring, + final ProjectVersionRef target, final int index, final boolean managed ) + { + this( source, declaring, target, index, managed, false ); + } + + public SimplePluginRelationship( final URI source, final ProjectVersionRef declaring, + final ProjectVersionRef target, final int index, final boolean managed, + final boolean reporting ) + { + super( source, RelationshipType.PLUGIN, declaring, target, index, managed ); + this.reporting = reporting; + } + + public SimplePluginRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, + final ProjectVersionRef target, final int index, final boolean managed ) + { + this( source, pomLocation, declaring, target, index, managed, false ); + } + + public SimplePluginRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, + final ProjectVersionRef target, final int index, final boolean managed, + final boolean reporting ) + { + super( source, pomLocation, RelationshipType.PLUGIN, declaring, target, index, managed ); + this.reporting = reporting; + } + + public SimplePluginRelationship( final Collection sources, final URI pomLocation, + final ProjectVersionRef declaring, final ProjectVersionRef target, final int index, + final boolean managed, final boolean reporting ) + { + super( sources, pomLocation, RelationshipType.PLUGIN, declaring, target, index, managed ); + this.reporting = reporting; + } + + @Override + public final boolean isReporting() + { + return reporting; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ( isManaged() ? 1231 : 1237 ); + return result; + } + + @Override + public boolean equals( final Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( !super.equals( obj ) ) + { + return false; + } + if ( getClass() != obj.getClass() ) + { + return false; + } + final PluginRelationship other = (PluginRelationship) obj; + return isManaged() == other.isManaged(); + } + + @Override + public String toString() + { + return String.format( "PluginRelationship [%s => %s (managed=%s, index=%s)]", getDeclaring(), getTarget(), + isManaged(), getIndex() ); + } + + @Override + public ArtifactRef getTargetArtifact() + { + return new SimpleArtifactRef( getTarget(), "maven-plugin", null, false ); + } + + @Override + public PluginRelationship selectDeclaring( final ProjectVersionRef ref ) + { + final ProjectVersionRef t = getTarget(); + + return new SimplePluginRelationship( getSources(), getPomLocation(), ref, t, getIndex(), isManaged(), isReporting() ); + } + + @Override + public PluginRelationship selectTarget( final ProjectVersionRef ref ) + { + final ProjectVersionRef d = getDeclaring(); + + return new SimplePluginRelationship( getSources(), getPomLocation(), d, ref, getIndex(), isManaged(), isReporting() ); + } + + @Override + public synchronized PluginRelationship cloneFor( final ProjectVersionRef projectRef ) + { + return new SimplePluginRelationship( getSources(), getPomLocation(), projectRef, getTarget(), getIndex(), + isManaged(), reporting ); + } + + @Override + public PluginRelationship addSource( URI source ) + { + Set srcs = getSources(); + srcs.add( source ); + return new SimplePluginRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), getIndex(), + isManaged(), reporting ); + } + + @Override + public PluginRelationship addSources( Collection sources ) + { + Set srcs = getSources(); + srcs.addAll( sources ); + return new SimplePluginRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), getIndex(), + isManaged(), reporting ); + } +} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java index a8a07bae..ab4641e1 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java @@ -61,7 +61,7 @@ void deleteRelationshipsDeclaredBy( ProjectVersionRef root ) * * @return The set of relationships that were NOT added because they introduce cycles. NEVER null, but maybe empty. */ - Set> addRelationships( ProjectRelationship... rel ) + Set> addRelationships( ProjectRelationship... rel ) throws RelationshipGraphConnectionException; void addProjectError( ProjectVersionRef ref, String error ) @@ -89,15 +89,15 @@ void reindex( final ProjectVersionRef ref ) String getProjectError( ProjectVersionRef ref ); - Collection> getRelationshipsDeclaredBy( ViewParams params, ProjectVersionRef root ); + Collection> getRelationshipsDeclaredBy( ViewParams params, ProjectVersionRef root ); - Collection> getRelationshipsTargeting( ViewParams params, ProjectVersionRef root ); + Collection> getRelationshipsTargeting( ViewParams params, ProjectVersionRef root ); - Collection> getAllRelationships( ViewParams params ); + Collection> getAllRelationships( ViewParams params ); - Set>> getAllPathsTo( ViewParams params, ProjectVersionRef... projectVersionRefs ); + Set>> getAllPathsTo( ViewParams params, ProjectVersionRef... projectVersionRefs ); - boolean introducesCycle( ViewParams params, ProjectRelationship rel ); + boolean introducesCycle( ViewParams params, ProjectRelationship rel ); Set getAllProjects( ViewParams params ); @@ -107,7 +107,7 @@ void traverse( RelationshipGraphTraversal traversal, ProjectVersionRef root, Rel boolean containsProject( ViewParams params, ProjectVersionRef ref ); - boolean containsRelationship( ViewParams params, ProjectRelationship rel ); + boolean containsRelationship( ViewParams params, ProjectRelationship rel ); boolean isMissing( ViewParams params, ProjectVersionRef project ); @@ -123,7 +123,7 @@ void traverse( RelationshipGraphTraversal traversal, ProjectVersionRef root, Rel Set getCycles( ViewParams params ); - boolean isCycleParticipant( ViewParams params, ProjectRelationship rel ); + boolean isCycleParticipant( ViewParams params, ProjectRelationship rel ); boolean isCycleParticipant( ViewParams params, ProjectVersionRef ref ); @@ -134,18 +134,18 @@ void traverse( RelationshipGraphTraversal traversal, ProjectVersionRef root, Rel Set getProjectsWithMetadata( ViewParams params, String key ); @Deprecated - Set> getDirectRelationshipsFrom( ViewParams params, ProjectVersionRef from, + Set> getDirectRelationshipsFrom( ViewParams params, ProjectVersionRef from, boolean includeManagedInfo, RelationshipType... types ); @Deprecated - Set> getDirectRelationshipsTo( ViewParams params, ProjectVersionRef to, + Set> getDirectRelationshipsTo( ViewParams params, ProjectVersionRef to, boolean includeManagedInfo, RelationshipType... types ); - Set> getDirectRelationshipsFrom( ViewParams params, ProjectVersionRef from, + Set> getDirectRelationshipsFrom( ViewParams params, ProjectVersionRef from, boolean includeManagedInfo, boolean includeConcreteInfo, RelationshipType... types ); - Set> getDirectRelationshipsTo( ViewParams params, ProjectVersionRef to, + Set> getDirectRelationshipsTo( ViewParams params, ProjectVersionRef to, boolean includeManagedInfo, boolean includeConcreteInfo, RelationshipType... types ); @@ -155,9 +155,9 @@ Set> getDirectRelationshipsTo( ViewParams params, Project ProjectVersionRef getManagedTargetFor( ProjectVersionRef target, GraphPath path, RelationshipType type ); - GraphPath createPath( ProjectRelationship... relationships ); + GraphPath createPath( ProjectRelationship... relationships ); - GraphPath createPath( GraphPath parent, ProjectRelationship relationship ); + GraphPath createPath( GraphPath parent, ProjectRelationship relationship ); boolean registerView( ViewParams params ); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractFilteringTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractFilteringTraversal.java index 7ae027af..034f66bc 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractFilteringTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractFilteringTraversal.java @@ -21,6 +21,8 @@ import org.commonjava.maven.atlas.graph.filter.NoneFilter; import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class AbstractFilteringTraversal extends AbstractTraversal @@ -38,11 +40,11 @@ protected AbstractFilteringTraversal( final ProjectRelationshipFilter filter ) rootFilter = filter; } - protected abstract boolean shouldTraverseEdge( ProjectRelationship relationship, - List> path ); + protected abstract boolean shouldTraverseEdge( ProjectRelationship relationship, + List> path ); - protected void edgeTraversalFinished( final ProjectRelationship relationship, - final List> path ) + protected void edgeTraversalFinished( final ProjectRelationship relationship, + final List> path ) { } @@ -52,29 +54,32 @@ public final ProjectRelationshipFilter getRootFilter() } @Override - public final void edgeTraversed( final ProjectRelationship relationship, final List> path ) + public final void edgeTraversed( final ProjectRelationship relationship, final List> path ) { edgeTraversalFinished( relationship, path ); } @Override - public final boolean traverseEdge( final ProjectRelationship relationship, - final List> path ) + public final boolean traverseEdge( final ProjectRelationship relationship, + final List> path ) { + Logger logger = LoggerFactory.getLogger( getClass() ); if ( !preCheck( relationship, path ) ) { + logger.debug("DON'T traverse: {}", relationship ); return false; } // seen.add( relationship ); final boolean ok = shouldTraverseEdge( relationship, path ); + logger.debug( "Traverse: {}?\n{}", relationship, ok ); return ok; } @Override - public boolean preCheck( final ProjectRelationship relationship, final List> path ) + public boolean preCheck( final ProjectRelationship relationship, final List> path ) { boolean result = true; @@ -87,7 +92,7 @@ public boolean preCheck( final ProjectRelationship relationship, final List

> path ) + private ProjectRelationshipFilter constructFilter( final List> path ) { if ( rootFilter == null ) { @@ -95,7 +100,7 @@ private ProjectRelationshipFilter constructFilter( final List rel : path ) + for ( final ProjectRelationship rel : path ) { if ( !filter.accept( rel ) ) { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractTraversal.java index 2647fd9a..06bf2e0a 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractTraversal.java @@ -39,12 +39,12 @@ public void endTraverse( final RelationshipGraph graph ) } @Override - public void edgeTraversed( final ProjectRelationship relationship, final List> path ) + public void edgeTraversed( final ProjectRelationship relationship, final List> path ) { } @Override - public boolean traverseEdge( final ProjectRelationship relationship, final List> path ) + public boolean traverseEdge( final ProjectRelationship relationship, final List> path ) { return preCheck( relationship, path ); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java index 4b985308..1277ad45 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java @@ -61,8 +61,8 @@ public BuildOrder getBuildOrder() } @Override - protected boolean shouldTraverseEdge( final ProjectRelationship relationship, - final List> path ) + protected boolean shouldTraverseEdge( final ProjectRelationship relationship, + final List> path ) { if ( !verifyProjectsAllowed( relationship, path ) ) { @@ -96,8 +96,8 @@ protected boolean shouldTraverseEdge( final ProjectRelationship relationship, return true; } - private boolean verifyProjectsAllowed( final ProjectRelationship relationship, - final List> path ) + private boolean verifyProjectsAllowed( final ProjectRelationship relationship, + final List> path ) { if ( allowedProjects == null ) { @@ -113,7 +113,7 @@ else if ( allowedProjects.isEmpty() ) return false; } - for ( final ProjectRelationship rel : path ) + for ( final ProjectRelationship rel : path ) { if ( !verifyRelationshipProjectsAllowed( rel ) ) { @@ -124,7 +124,7 @@ else if ( allowedProjects.isEmpty() ) return true; } - private boolean verifyRelationshipProjectsAllowed( final ProjectRelationship relationship ) + private boolean verifyRelationshipProjectsAllowed( final ProjectRelationship relationship ) { return allowedProjects == null || ( allowedProjects.contains( relationship.getDeclaring() ) && allowedProjects.contains( relationship.getTarget() ) ); @@ -146,7 +146,7 @@ public void endTraverse( final RelationshipGraph graph ) ProjectRelationshipFilter filter = getRootFilter(); boolean include = true; - for ( final ProjectRelationship rel : eProjectCycle ) + for ( final ProjectRelationship rel : eProjectCycle ) { if ( !filter.accept( rel ) ) { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/FilteringTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/FilteringTraversal.java index 85aeb1be..c77ca52f 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/FilteringTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/FilteringTraversal.java @@ -26,7 +26,7 @@ public class FilteringTraversal extends AbstractFilteringTraversal { - private final List> captured = new ArrayList>(); + private final List> captured = new ArrayList>(); private final boolean doCapture; @@ -41,7 +41,7 @@ public FilteringTraversal( final ProjectRelationshipFilter filter, final boolean this.doCapture = doCapture; } - public List> getCapturedRelationships() + public List> getCapturedRelationships() { return captured; } @@ -49,7 +49,7 @@ public List> getCapturedRelationships() public List getCapturedProjects( final boolean unique ) { final List refs = new ArrayList(); - for ( final ProjectRelationship rel : captured ) + for ( final ProjectRelationship rel : captured ) { final ProjectVersionRef d = rel.getDeclaring(); final ProjectVersionRef t = rel.getTarget() @@ -70,8 +70,8 @@ public List getCapturedProjects( final boolean unique ) } @Override - protected boolean shouldTraverseEdge( final ProjectRelationship relationship, - final List> path ) + protected boolean shouldTraverseEdge( final ProjectRelationship relationship, + final List> path ) { if ( doCapture ) { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/ImpactTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/ImpactTraversal.java index 0308ae11..278337b9 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/ImpactTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/ImpactTraversal.java @@ -31,8 +31,8 @@ public class ImpactTraversal extends AbstractTraversal { - private final Map>>> impactedPaths = - new HashMap>>>(); + private final Map>>> impactedPaths = + new HashMap>>>(); private final boolean includeManagedInfo; @@ -46,7 +46,7 @@ public ImpactTraversal( final boolean includeManagedInfo, final ProjectVersionRe this.includeManagedInfo = includeManagedInfo; for ( final ProjectVersionRef target : targets ) { - impactedPaths.put( target, new HashSet>>() ); + impactedPaths.put( target, new HashSet>>() ); } } @@ -60,17 +60,17 @@ public ImpactTraversal( final boolean includeManagedInfo, final Set>>() ); + impactedPaths.put( target, new HashSet>>() ); } } - public Map>>> getImpactedPaths() + public Map>>> getImpactedPaths() { return impactedPaths; } @Override - public boolean traverseEdge( final ProjectRelationship relationship, final List> path ) + public boolean traverseEdge( final ProjectRelationship relationship, final List> path ) { if ( !preCheck( relationship, path ) ) { @@ -79,8 +79,8 @@ public boolean traverseEdge( final ProjectRelationship relationship, final Li final ProjectVersionRef target = relationship.getTarget() .asProjectVersionRef(); - final Set>> paths = impactedPaths.get( target ); - final ArrayList> p = new ArrayList>( path ); + final Set>> paths = impactedPaths.get( target ); + final ArrayList> p = new ArrayList>( path ); p.add( relationship ); paths.add( p ); @@ -90,7 +90,7 @@ public boolean traverseEdge( final ProjectRelationship relationship, final Li } @Override - public boolean preCheck( final ProjectRelationship relationship, final List> path ) + public boolean preCheck( final ProjectRelationship relationship, final List> path ) { if ( !includeManagedInfo ) { @@ -106,7 +106,7 @@ public boolean preCheck( final ProjectRelationship relationship, final List

>> paths = impactedPaths.get( relationship.getTarget() + final Set>> paths = impactedPaths.get( relationship.getTarget() .asProjectVersionRef() ); return !( paths != null && paths.isEmpty() ); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java index 6d715e89..c799fd81 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java @@ -45,7 +45,7 @@ public class PathsTraversal private final Map cache = new HashMap(); - private final Set>> paths = new HashSet>>(); + private final Set>> paths = new HashSet>>(); public PathsTraversal( final ProjectRelationshipFilter filter, final Set toGas ) { @@ -54,7 +54,7 @@ public PathsTraversal( final ProjectRelationshipFilter filter, final Set relationship, final List> path ) + public boolean preCheck( final ProjectRelationship relationship, final List> path ) { final ProjectVersionRef declaring = relationship.getDeclaring().asProjectVersionRef(); if ( path.isEmpty() || path.get( path.size() - 1 ).getTarget().asProjectVersionRef().equals( declaring ) ) @@ -111,7 +111,7 @@ public boolean preCheck( final ProjectRelationship relationship, final List

> realPath = new ArrayList>( path ); + final List> realPath = new ArrayList>( path ); realPath.add( relationship ); paths.add( realPath ); } @@ -123,7 +123,7 @@ public boolean preCheck( final ProjectRelationship relationship, final List

>> getDiscoveredPaths() + public Set>> getDiscoveredPaths() { return paths; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/RelationshipGraphTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/RelationshipGraphTraversal.java index bf07df06..454dcc59 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/RelationshipGraphTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/RelationshipGraphTraversal.java @@ -30,9 +30,9 @@ void startTraverse( RelationshipGraph graph ) void endTraverse( RelationshipGraph graph ) throws RelationshipGraphConnectionException; - boolean traverseEdge( ProjectRelationship relationship, List> path ); + boolean traverseEdge( ProjectRelationship relationship, List> path ); - void edgeTraversed( ProjectRelationship relationship, List> path ); + void edgeTraversed( ProjectRelationship relationship, List> path ); - boolean preCheck( ProjectRelationship relationship, List> path ); + boolean preCheck( ProjectRelationship relationship, List> path ); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java index 06447080..6fa6b0b1 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java @@ -19,9 +19,7 @@ import org.commonjava.maven.atlas.graph.filter.OrFilter; import org.commonjava.maven.atlas.graph.filter.ParentFilter; import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.*; import org.commonjava.maven.atlas.ident.DependencyScope; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.SimpleVersionlessArtifactRef; @@ -62,8 +60,8 @@ public List getArtifacts() } @Override - public boolean shouldTraverseEdge( final ProjectRelationship relationship, - final List> path ) + public boolean shouldTraverseEdge( final ProjectRelationship relationship, + final List> path ) { boolean result = false; if ( relationship instanceof DependencyRelationship ) @@ -71,8 +69,8 @@ public boolean shouldTraverseEdge( final ProjectRelationship relationship, final ArtifactRef target = (ArtifactRef) relationship.getTarget(); final VersionlessArtifactRef versionlessTarget = new SimpleVersionlessArtifactRef( target ); - logger.debug( "Checking for seen versionless GA[TC]: {}", versionlessTarget ); final Integer distance = seenArtifacts.get( versionlessTarget ); + logger.debug( "Checking for seen versionless GA[TC]: {}\nStored distance: {}\nPath distance: {}", versionlessTarget, distance, path.size() ); if ( distance == null || distance > path.size() ) { logger.debug( "Adding: {} ({})", target, versionlessTarget ); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/DependencyTreeRelationshipPrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/DependencyTreeRelationshipPrinter.java index 28e24835..dbd06f83 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/DependencyTreeRelationshipPrinter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/DependencyTreeRelationshipPrinter.java @@ -44,7 +44,7 @@ public DependencyTreeRelationshipPrinter( final Set missing ) } @Override - public void print( final ProjectRelationship relationship, final ProjectVersionRef selectedTarget, + public void print( final ProjectRelationship relationship, final ProjectVersionRef selectedTarget, final PrintWriter writer, final Map> labels, final int depth, final String indent ) { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java index 23b3acee..04740189 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java @@ -28,11 +28,10 @@ import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; public class ListPrinter { @@ -54,14 +53,14 @@ public ListPrinter( final StructureRelationshipPrinter relationshipPrinter ) } public void printStructure( final ProjectVersionRef from, - final Map>> links, + final Map>> links, final Map> labels, PrintWriter writer ) { printStructure( from, links, null, null, labels, writer ); } public void printStructure( final ProjectVersionRef from, - final Map>> links, final String header, + final Map>> links, final String header, final String footer, final Map> labels, PrintWriter writer ) { @@ -95,17 +94,17 @@ public void printStructure( final ProjectVersionRef from, } private void printLinks( final ProjectVersionRef from, final Set lines, - final Map>> links, + final Map>> links, final Map> labels, final Set excluded, final Stack inPath ) { inPath.push( from ); - final List> outbound = links.get( from ); + final List> outbound = links.get( from ); if ( outbound != null ) { StringWriter sw; - for ( final ProjectRelationship out : outbound ) + for ( final ProjectRelationship out : outbound ) { sw = new StringWriter(); @@ -134,7 +133,7 @@ private void printLinks( final ProjectVersionRef from, final Set lines, .asProjectRef() ) ) { Set newExcluded = null; - if ( out instanceof DependencyRelationship ) + if ( out instanceof SimpleDependencyRelationship ) { final Set excludes = ( (DependencyRelationship) out ).getExcludes(); if ( excludes != null && !excludes.isEmpty() ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructurePrintingTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructurePrintingTraversal.java index 391ee162..4069347a 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructurePrintingTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructurePrintingTraversal.java @@ -27,6 +27,7 @@ import org.commonjava.maven.atlas.graph.RelationshipGraph; import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; import org.commonjava.maven.atlas.graph.traverse.RelationshipGraphTraversal; import org.commonjava.maven.atlas.graph.util.RelationshipUtils; @@ -45,7 +46,7 @@ public class StructurePrintingTraversal private final StructureRelationshipPrinter relationshipPrinter; - private final Map>> outboundLinks = new HashMap>>(); + private final Map>> outboundLinks = new HashMap>>(); public StructurePrintingTraversal() { @@ -72,14 +73,14 @@ public StructurePrintingTraversal( final RelationshipGraphTraversal traversal, f } @Override - public boolean traverseEdge( final ProjectRelationship relationship, final List> path ) + public boolean traverseEdge( final ProjectRelationship relationship, final List> path ) { if ( traversal == null || traversal.traverseEdge( relationship, path ) ) { - List> outbound = outboundLinks.get( relationship.getDeclaring() ); + List> outbound = outboundLinks.get( relationship.getDeclaring() ); if ( outbound == null ) { - outbound = new ArrayList>(); + outbound = new ArrayList>(); outboundLinks.put( relationship.getDeclaring(), outbound ); } @@ -132,10 +133,10 @@ private void printLinks( final ProjectVersionRef from, final PrintWriter writer, final Set excluded, final Stack inPath ) { inPath.push( from ); - final List> outbound = outboundLinks.get( from ); + final List> outbound = outboundLinks.get( from ); if ( outbound != null ) { - for ( final ProjectRelationship out : outbound ) + for ( final ProjectRelationship out : outbound ) { final ProjectVersionRef outRef = out.getTarget() .asProjectVersionRef(); @@ -157,7 +158,7 @@ private void printLinks( final ProjectVersionRef from, final PrintWriter writer, .asProjectVersionRef() ) ) { Set newExcluded = null; - if ( out instanceof DependencyRelationship ) + if ( out instanceof SimpleDependencyRelationship ) { final Set excludes = ( (DependencyRelationship) out ).getExcludes(); if ( excludes != null && !excludes.isEmpty() ) @@ -188,7 +189,7 @@ private void printLinks( final ProjectVersionRef from, final PrintWriter writer, } @Override - public boolean preCheck( final ProjectRelationship relationship, final List> path ) + public boolean preCheck( final ProjectRelationship relationship, final List> path ) { return traversal == null || traversal.preCheck( relationship, path ); } @@ -214,7 +215,7 @@ public void endTraverse( final RelationshipGraph graph ) } @Override - public void edgeTraversed( final ProjectRelationship relationship, final List> path ) + public void edgeTraversed( final ProjectRelationship relationship, final List> path ) { if ( traversal != null ) { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructureRelationshipPrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructureRelationshipPrinter.java index 7ab655b0..0767d02d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructureRelationshipPrinter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructureRelationshipPrinter.java @@ -24,7 +24,7 @@ public interface StructureRelationshipPrinter { - void print( ProjectRelationship relationship, ProjectVersionRef targetOverride, PrintWriter writer, + void print( ProjectRelationship relationship, ProjectVersionRef targetOverride, PrintWriter writer, Map> labels, int depth, String indent ); void printProjectVersionRef( ProjectVersionRef targetArtifact, PrintWriter writer, String targetSuffix, diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TargetRefPrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TargetRefPrinter.java index eea08b0d..c4f890dc 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TargetRefPrinter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TargetRefPrinter.java @@ -28,7 +28,7 @@ public final class TargetRefPrinter { @Override - public void print( final ProjectRelationship relationship, final ProjectVersionRef selectedTarget, + public void print( final ProjectRelationship relationship, final ProjectVersionRef selectedTarget, final PrintWriter writer, final Map> labels, final int depth, final String indent ) { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java index fa677210..585f92dd 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java @@ -25,11 +25,10 @@ import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; public class TreePrinter { @@ -63,14 +62,14 @@ public TreePrinter( final StructureRelationshipPrinter relationshipPrinter ) // } public void printStructure( final ProjectVersionRef from, - final Map>> links, + final Map>> links, final Map> labels, final PrintWriter writer ) { printStructure( from, links, null, null, " ", labels, writer ); } public void printStructure( final ProjectVersionRef from, - final Map>> links, + final Map>> links, final String indent, final Map> labels, final PrintWriter writer ) { @@ -78,7 +77,7 @@ public void printStructure( final ProjectVersionRef from, } public void printStructure( final ProjectVersionRef from, - final Map>> links, + final Map>> links, final String header, final String footer, final String indent, final Map> labels, final PrintWriter writer ) { @@ -101,17 +100,17 @@ public void printStructure( final ProjectVersionRef from, } private void printLinks( final ProjectVersionRef from, final PrintWriter writer, final String indent, - final int depth, final Map>> links, + final int depth, final Map>> links, final Map> labels, final Set excluded, final Stack inPath ) { inPath.push( from ); selected.put( from.asProjectRef(), from ); - final List> outbound = links.get( from ); + final List> outbound = links.get( from ); if ( outbound != null ) { - for ( final ProjectRelationship out : outbound ) + for ( final ProjectRelationship out : outbound ) { final ProjectVersionRef outRef = out.getTarget() .asProjectVersionRef(); @@ -152,7 +151,7 @@ private void printLinks( final ProjectVersionRef from, final PrintWriter writer, .asProjectVersionRef() ) ) { Set newExcluded = null; - if ( out instanceof DependencyRelationship ) + if ( out instanceof SimpleDependencyRelationship ) { final Set excludes = ( (DependencyRelationship) out ).getExcludes(); if ( excludes != null && !excludes.isEmpty() ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java index efce2904..e25c3da5 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java @@ -34,17 +34,10 @@ import org.commonjava.maven.atlas.graph.filter.AbstractTypedFilter; import org.commonjava.maven.atlas.graph.filter.AnyFilter; import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.graph.rel.*; import org.commonjava.maven.atlas.ident.DependencyScope; import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.commonjava.maven.atlas.ident.util.JoinString; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; import org.slf4j.Logger; @@ -63,8 +56,20 @@ private RelationshipUtils() public static URI ANY_SOURCE_URI; + public static URI TERMINAL_PARENT_SOURCE_URI; + static { + final String uri = "atlas:terminal-parent"; + try + { + TERMINAL_PARENT_SOURCE_URI = new URI( uri ); + } + catch ( final URISyntaxException e ) + { + throw new IllegalStateException( "Terminal-parent source URI constant is invalid: " + uri, e ); + } + try { ANY_SOURCE_URI = new URI( "any:any" ); @@ -116,18 +121,18 @@ public static boolean isExcluded( final ProjectRef ref, final Collection>> mapByDeclaring( final Collection> relationships ) + public static Map>> mapByDeclaring( final Collection> relationships ) { final Logger logger = LoggerFactory.getLogger( RelationshipUtils.class ); logger.debug( "Mapping {} relationships by declaring GAV:\n\n {}\n\n", relationships.size(), new JoinString( "\n ", relationships ) ); - final Map>> result = new HashMap>>(); - for ( final ProjectRelationship rel : relationships ) + final Map>> result = new HashMap>>(); + for ( final ProjectRelationship rel : relationships ) { final ProjectVersionRef declaring = rel.getDeclaring(); - List> outbound = result.get( declaring ); + List> outbound = result.get( declaring ); if ( outbound == null ) { - outbound = new ArrayList>(); + outbound = new ArrayList>(); result.put( rel.getDeclaring(), outbound ); } @@ -159,19 +164,19 @@ public static URI profileLocation( final String profile ) } } - public static void filterTerminalParents( final Collection> rels ) + public static void filterTerminalParents( final Collection> rels ) { - for ( final Iterator> it = rels.iterator(); it.hasNext(); ) + for ( final Iterator> it = rels.iterator(); it.hasNext(); ) { - final ProjectRelationship rel = it.next(); - if ( ( rel instanceof ParentRelationship ) && ( (ParentRelationship) rel ).isTerminus() ) + final ProjectRelationship rel = it.next(); + if ( ( rel instanceof SimpleParentRelationship ) && ( (ParentRelationship) rel ).isTerminus() ) { it.remove(); } } } - public static void filter( final Set> rels, final RelationshipType... types ) + public static void filter( final Set> rels, final RelationshipType... types ) { if ( rels == null || rels.isEmpty() ) { @@ -184,9 +189,9 @@ public static void filter( final Set> rels, fin } Arrays.sort( types ); - for ( final Iterator> iterator = rels.iterator(); iterator.hasNext(); ) + for ( final Iterator> iterator = rels.iterator(); iterator.hasNext(); ) { - final ProjectRelationship rel = iterator.next(); + final ProjectRelationship rel = iterator.next(); if ( Arrays.binarySearch( types, rel.getType() ) < 0 ) { iterator.remove(); @@ -194,7 +199,7 @@ public static void filter( final Set> rels, fin } } - public static void filter( final Set> rels, final ProjectRelationshipFilter filter ) + public static void filter( final Set> rels, final ProjectRelationshipFilter filter ) { if ( filter == null || filter instanceof AnyFilter ) { @@ -206,9 +211,9 @@ public static void filter( final Set> rels, fin return; } - for ( final Iterator> iterator = rels.iterator(); iterator.hasNext(); ) + for ( final Iterator> iterator = rels.iterator(); iterator.hasNext(); ) { - final ProjectRelationship rel = iterator.next(); + final ProjectRelationship rel = iterator.next(); if ( !filter.accept( rel ) ) { iterator.remove(); @@ -216,15 +221,15 @@ public static void filter( final Set> rels, fin } } - public static Set declarers( final ProjectRelationship... relationships ) + public static Set declarers( final ProjectRelationship... relationships ) { return declarers( Arrays.asList( relationships ) ); } - public static Set declarers( final Collection> relationships ) + public static Set declarers( final Collection> relationships ) { final Set results = new HashSet(); - for ( final ProjectRelationship rel : relationships ) + for ( final ProjectRelationship rel : relationships ) { results.add( rel.getDeclaring() ); } @@ -232,12 +237,12 @@ public static Set declarers( final Collection targets( final ProjectRelationship... relationships ) + public static Set targets( final ProjectRelationship... relationships ) { return targets( Arrays.asList( relationships ) ); } - public static Set targets( final Collection> relationships ) + public static Set targets( final Collection> relationships ) { if ( relationships == null ) { @@ -245,7 +250,7 @@ public static Set targets( final Collection results = new HashSet(); - for ( final ProjectRelationship rel : relationships ) + for ( final ProjectRelationship rel : relationships ) { results.add( rel.getTarget() ); } @@ -253,15 +258,15 @@ public static Set targets( final Collection gavs( final ProjectRelationship... relationships ) + public static Set gavs( final ProjectRelationship... relationships ) { return gavs( Arrays.asList( relationships ) ); } - public static Set gavs( final Collection> relationships ) + public static Set gavs( final Collection> relationships ) { final Set results = new HashSet(); - for ( final ProjectRelationship rel : relationships ) + for ( final ProjectRelationship rel : relationships ) { results.add( rel.getDeclaring() .asProjectVersionRef() ); @@ -279,7 +284,7 @@ public static ExtensionRelationship extension( final URI source, final URI pomLo final String version, final int index ) throws InvalidVersionSpecificationException { - return new ExtensionRelationship( source, pomLocation, owner, projectVersion( groupId, artifactId, version ), + return new SimpleExtensionRelationship( source, pomLocation, owner, projectVersion( groupId, artifactId, version ), index ); } @@ -294,14 +299,14 @@ public static PluginRelationship plugin( final URI source, final URI pomLocation final String artifactId, final String version, final int index, final boolean managed ) throws InvalidVersionSpecificationException { - return new PluginRelationship( source, pomLocation, owner, projectVersion( groupId, artifactId, version ), index, managed ); + return new SimplePluginRelationship( source, pomLocation, owner, projectVersion( groupId, artifactId, version ), index, managed ); } public static PluginRelationship plugin( final URI source, final URI pomLocation, final ProjectVersionRef owner, final ProjectVersionRef plugin, final int index, final boolean managed ) throws InvalidVersionSpecificationException { - return new PluginRelationship( source, pomLocation, owner, plugin, index, managed ); + return new SimplePluginRelationship( source, pomLocation, owner, plugin, index, managed ); } public static PluginRelationship plugin( final URI source, final ProjectVersionRef owner, final String groupId, final String artifactId, @@ -315,14 +320,14 @@ public static PluginRelationship plugin( final URI source, final ProjectVersionR final String version, final int index, final boolean managed ) throws InvalidVersionSpecificationException { - return new PluginRelationship( source, owner, projectVersion( groupId, artifactId, version ), index, managed ); + return new SimplePluginRelationship( source, owner, projectVersion( groupId, artifactId, version ), index, managed ); } public static PluginRelationship plugin( final URI source, final ProjectVersionRef owner, final ProjectVersionRef plugin, final int index, final boolean managed ) throws InvalidVersionSpecificationException { - return new PluginRelationship( source, owner, plugin, index, managed ); + return new SimplePluginRelationship( source, owner, plugin, index, managed ); } public static PluginDependencyRelationship pluginDependency( final URI source, final ProjectVersionRef owner, final ProjectRef plugin, @@ -345,7 +350,7 @@ public static PluginDependencyRelationship pluginDependency( final URI source, f final String type, final String classifier, final int index, final boolean managed ) throws InvalidVersionSpecificationException { - return new PluginDependencyRelationship( source, owner, plugin, artifact( groupId, artifactId, version, type, classifier, false ), index, + return new SimplePluginDependencyRelationship( source, owner, plugin, artifact( groupId, artifactId, version, type, classifier, false ), index, managed ); } @@ -354,7 +359,7 @@ public static PluginDependencyRelationship pluginDependency( final URI source, f final int index, final boolean managed ) throws InvalidVersionSpecificationException { - return new PluginDependencyRelationship( source, owner, plugin, artifact( dep, type, classifier, false ), index, managed ); + return new SimplePluginDependencyRelationship( source, owner, plugin, artifact( dep, type, classifier, false ), index, managed ); } public static PluginDependencyRelationship pluginDependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, @@ -379,7 +384,7 @@ public static PluginDependencyRelationship pluginDependency( final URI source, f final boolean managed ) throws InvalidVersionSpecificationException { - return new PluginDependencyRelationship( source, pomLocation, owner, plugin, + return new SimplePluginDependencyRelationship( source, pomLocation, owner, plugin, artifact( groupId, artifactId, version, type, classifier, false ), index, managed ); } @@ -388,7 +393,7 @@ public static PluginDependencyRelationship pluginDependency( final URI source, f final String classifier, final int index, final boolean managed ) throws InvalidVersionSpecificationException { - return new PluginDependencyRelationship( source, pomLocation, owner, plugin, artifact( dep, type, classifier, false ), index, managed ); + return new SimplePluginDependencyRelationship( source, pomLocation, owner, plugin, artifact( dep, type, classifier, false ), index, managed ); } public static DependencyRelationship dependency( final URI source, final ProjectVersionRef owner, final String groupId, final String artifactId, @@ -415,7 +420,7 @@ public static DependencyRelationship dependency( final URI source, final Project final DependencyScope scope, final int index, final boolean managed ) throws InvalidVersionSpecificationException { - return new DependencyRelationship( source, owner, artifact( dep, null, null, false ), scope, index, managed ); + return new SimpleDependencyRelationship( source, owner, artifact( dep, null, null, false ), scope, index, managed ); } public static DependencyRelationship dependency( final URI source, final ProjectVersionRef owner, final String groupId, final String artifactId, @@ -423,7 +428,7 @@ public static DependencyRelationship dependency( final URI source, final Project final DependencyScope scope, final int index, final boolean managed ) throws InvalidVersionSpecificationException { - return new DependencyRelationship( source, owner, artifact( groupId, artifactId, version, type, classifier, optional ), null, index, false ); + return new SimpleDependencyRelationship( source, owner, artifact( groupId, artifactId, version, type, classifier, optional ), null, index, false ); } public static DependencyRelationship dependency( final URI source, final ProjectVersionRef owner, final ProjectVersionRef dep, final String type, @@ -431,7 +436,7 @@ public static DependencyRelationship dependency( final URI source, final Project final boolean managed ) throws InvalidVersionSpecificationException { - return new DependencyRelationship( source, owner, artifact( dep, type, classifier, optional ), null, index, false ); + return new SimpleDependencyRelationship( source, owner, artifact( dep, type, classifier, optional ), null, index, false ); } public static DependencyRelationship dependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, final String groupId, @@ -460,7 +465,7 @@ public static DependencyRelationship dependency( final URI source, final URI pom final ProjectVersionRef dep, final DependencyScope scope, final int index, final boolean managed ) throws InvalidVersionSpecificationException { - return new DependencyRelationship( source, pomLocation, owner, artifact( dep, null, null, false ), scope, index, managed ); + return new SimpleDependencyRelationship( source, pomLocation, owner, artifact( dep, null, null, false ), scope, index, managed ); } public static DependencyRelationship dependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, final String groupId, @@ -468,7 +473,7 @@ public static DependencyRelationship dependency( final URI source, final URI pom final boolean optional, final DependencyScope scope, final int index, final boolean managed ) throws InvalidVersionSpecificationException { - return new DependencyRelationship( source, pomLocation, owner, artifact( groupId, artifactId, version, type, classifier, optional ), null, + return new SimpleDependencyRelationship( source, pomLocation, owner, artifact( groupId, artifactId, version, type, classifier, optional ), null, index, false ); } @@ -477,7 +482,7 @@ public static DependencyRelationship dependency( final URI source, final URI pom final DependencyScope scope, final int index, final boolean managed ) throws InvalidVersionSpecificationException { - return new DependencyRelationship( source, pomLocation, owner, artifact( dep, type, classifier, optional ), null, index, false ); + return new SimpleDependencyRelationship( source, pomLocation, owner, artifact( dep, type, classifier, optional ), null, index, false ); } public static Set getRelationshipTypes( final ProjectRelationshipFilter filter ) diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java index 1461f001..81355a60 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java @@ -23,11 +23,7 @@ import java.util.Set; import org.commonjava.maven.atlas.graph.model.EProjectDirectRelationships; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.*; import org.commonjava.maven.atlas.ident.DependencyScope; import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; @@ -59,26 +55,26 @@ public void builderWith2Dependencies2PluginsAParentAndAnExtension() final EProjectDirectRelationships.Builder prb = new EProjectDirectRelationships.Builder( source, p ); final ProjectVersionRef parent = new SimpleProjectVersionRef( "org.apache.maven", "maven", "3.0.3" ); - final ParentRelationship parentRel = new ParentRelationship( source, p, parent ); + final ParentRelationship parentRel = new SimpleParentRelationship( source, p, parent ); int idx = 0; int pidx = 0; final DependencyRelationship papi = - new DependencyRelationship( source, p, new SimpleArtifactRef( "org.apache.maven", "maven-plugin-api", "3.0.3", + new SimpleDependencyRelationship( source, p, new SimpleArtifactRef( "org.apache.maven", "maven-plugin-api", "3.0.3", null, null, false ), DependencyScope.compile, idx++, false ); final DependencyRelationship art = - new DependencyRelationship( source, p, new SimpleArtifactRef( "org.apache.maven", "maven-artifact", "3.0.3", + new SimpleDependencyRelationship( source, p, new SimpleArtifactRef( "org.apache.maven", "maven-artifact", "3.0.3", null, null, false ), DependencyScope.compile, idx++, false ); final PluginRelationship jarp = - new PluginRelationship( source, p, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-jar-plugin", + new SimplePluginRelationship( source, p, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-jar-plugin", "2.2" ), pidx++, false ); final PluginRelationship comp = - new PluginRelationship( source, p, new SimpleProjectVersionRef( "org.apache.maven.plugins", + new SimplePluginRelationship( source, p, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.3.2" ), pidx++, false ); final ExtensionRelationship wag = - new ExtensionRelationship( source, p, new SimpleProjectVersionRef( "org.apache.maven.wagon", + new SimpleExtensionRelationship( source, p, new SimpleProjectVersionRef( "org.apache.maven.wagon", "wagon-provider-webdav", "1.0" ), 0 ); prb.withParent( parentRel ); @@ -88,7 +84,7 @@ public void builderWith2Dependencies2PluginsAParentAndAnExtension() final EProjectDirectRelationships rels = prb.build(); - final Set> all = rels.getAllRelationships(); + final Set> all = rels.getAllRelationships(); assertThat( all.size(), equalTo( 6 ) ); diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java index 9272fbe0..3283378f 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java @@ -22,6 +22,7 @@ import java.net.URISyntaxException; import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; import org.commonjava.maven.atlas.ident.DependencyScope; import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; @@ -47,7 +48,7 @@ public void rejectTestScopeForRuntimeFilter() { final DependencyFilter filter = new DependencyFilter( DependencyScope.runtime ); final DependencyRelationship rel = - new DependencyRelationship( testURI(), new SimpleProjectVersionRef( "g", "a", "1" ), + new SimpleDependencyRelationship( testURI(), new SimpleProjectVersionRef( "g", "a", "1" ), new SimpleArtifactRef( "g", "b", "2", "jar", null, false ), DependencyScope.test, 0, false ); diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/ParentRelationshipTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/ParentRelationshipTest.java index dc28a7b6..ef72863c 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/ParentRelationshipTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/ParentRelationshipTest.java @@ -55,7 +55,7 @@ public void cloneToDifferentProject() new SimpleProjectVersionRef( "org.foo", "foobar-parent", VersionUtils.createSingleVersion( "1" ) ); final URI source = testURI(); - final ParentRelationship pr = new ParentRelationship( source, projectRef, parentRef ); + final ParentRelationship pr = new SimpleParentRelationship( source, projectRef, parentRef ); final ParentRelationship pr2 = (ParentRelationship) pr.cloneFor( project2Ref ); assertThat( pr.getDeclaring(), equalTo( projectRef ) ); diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparatorTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparatorTest.java index bcfe5f32..f560131b 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparatorTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparatorTest.java @@ -27,7 +27,6 @@ import java.util.List; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; import org.junit.Rule; import org.junit.Test; @@ -49,9 +48,9 @@ private URI testURI() public void sortParentDependencyPathAheadOfDirectDependency() throws InvalidVersionSpecificationException, URISyntaxException { - final List>> paths = new ArrayList>>(); + final List>> paths = new ArrayList>>(); - List> rels = new ArrayList>(); + List> rels = new ArrayList>(); final ProjectVersionRef root = projectVersion( "group.id", "my-artifact", "1.0" ); @@ -63,21 +62,21 @@ public void sortParentDependencyPathAheadOfDirectDependency() paths.add( rels ); - rels = new ArrayList>(); + rels = new ArrayList>(); final ProjectVersionRef parent = projectVersion( "group.id", "parent", "1" ); - rels.add( new ParentRelationship( source, root, parent ) ); + rels.add( new SimpleParentRelationship( source, root, parent ) ); rels.add( dependency( source, parent, "org.foo", "bar", "1.1.1", 0 ) ); paths.add( rels ); Collections.sort( paths, RelationshipPathComparator.INSTANCE ); - final List> result = paths.get( 0 ); - final ProjectRelationship firstResult = result.get( 0 ); + final List> result = paths.get( 0 ); + final ProjectRelationship firstResult = result.get( 0 ); - assertThat( ( firstResult instanceof ParentRelationship ), equalTo( true ) ); + assertThat( ( firstResult instanceof SimpleParentRelationship ), equalTo( true ) ); } } diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java index 244b2c46..25eb7977 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java @@ -15,10 +15,12 @@ */ package org.commonjava.maven.atlas.tck.graph; +import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.Collections; import java.util.Date; +import java.util.ServiceLoader; import org.commonjava.maven.atlas.graph.RelationshipGraph; import org.commonjava.maven.atlas.graph.RelationshipGraphFactory; @@ -26,9 +28,11 @@ import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver; import org.junit.After; import org.junit.Before; import org.junit.Rule; +import org.junit.rules.TemporaryFolder; import org.junit.rules.TestName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,6 +43,29 @@ public abstract class AbstractSPI_TCK @Rule public TestName naming = new TestName(); + @Rule + public TemporaryFolder temp = new TemporaryFolder(); + + private TCKDriver driver; + + @Before + public void before() + throws Exception + { + driver = ServiceLoader.load( TCKDriver.class ).iterator().next(); + driver.setup( temp ); + } + + @After + public void after() + throws IOException + { + if ( driver != null ) + { + driver.close(); + } + } + protected URI sourceURI() throws URISyntaxException { @@ -61,17 +88,20 @@ protected String newWorkspaceId() protected final Logger logger = LoggerFactory.getLogger( getClass() ); - protected abstract RelationshipGraphConnectionFactory connectionFactory() - throws Exception; - private RelationshipGraphFactory graphFactory; + protected final RelationshipGraphConnectionFactory connectionFactory() + throws Exception + { + return driver.getConnectionFactory(); + } + protected final RelationshipGraphFactory graphFactory() throws Exception { if ( graphFactory == null ) { - graphFactory = new RelationshipGraphFactory( connectionFactory() ); + graphFactory = new RelationshipGraphFactory( driver.getConnectionFactory() ); } return graphFactory; diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/CycleDetectionTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/CycleDetectionTCK.java deleted file mode 100644 index 4c78c5bc..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/CycleDetectionTCK.java +++ /dev/null @@ -1,263 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph; - -import static org.apache.commons.lang.StringUtils.join; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - -import java.net.URI; -import java.util.HashSet; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.filter.DependencyFilter; -import org.commonjava.maven.atlas.graph.model.EProjectCycle; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.junit.Test; - -public abstract class CycleDetectionTCK - extends AbstractSPI_TCK -{ - - @Test - // @Ignore - public void introducesCycleCheckWithExistingGraph() - throws Exception - { - final URI source = sourceURI(); - - final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); - final ProjectVersionRef dep = new SimpleProjectVersionRef( "org.other", "dep", "1.0" ); - final ProjectVersionRef dep2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0" ); - - final RelationshipGraph graph = simpleGraph( project ); - - /* @formatter:off */ - graph.storeRelationships( new DependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null, false ), null, 0, false ), - new DependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null, false ), null, 0, false ) ); - - final boolean introduces = graph.introducesCycle( new DependencyRelationship( source, dep, new SimpleArtifactRef( project, null, null, false ), null, 0, false ) ); - /* @formatter:on */ - - assertThat( introduces, equalTo( true ) ); - } - - @Test - // @Ignore - public void buildGraphWithCycleBackToRootAndRetrieveCycle() - throws Exception - { - final URI source = sourceURI(); - - final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); - final ProjectVersionRef dep = new SimpleProjectVersionRef( "org.other", "dep", "1.0" ); - final ProjectVersionRef dep2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0" ); - - final RelationshipGraph graph = simpleGraph( project ); - - /* @formatter:off */ - graph.storeRelationships( new DependencyRelationship( source, project, dep.asJarArtifact(), null, 0, false ), - new DependencyRelationship( source, dep, dep2.asJarArtifact(), null, 0, false ), - new DependencyRelationship( source, dep2, project.asJarArtifact(), null, 0, false ) ); - /* @formatter:on */ - - // final EProjectGraph graph = getManager().getGraph( session, project ); - - final Set cycles = graph.getCycles(); - System.out.println( "Cycles:\n\n" + join( cycles, "\n" ) ); - assertThat( cycles.size(), equalTo( 1 ) ); - - for ( final EProjectCycle cycle : cycles ) - { - final Set projects = cycle.getAllParticipatingProjects(); - assertThat( projects.contains( project ), equalTo( true ) ); - assertThat( projects.contains( dep ), equalTo( true ) ); - assertThat( projects.contains( dep2 ), equalTo( true ) ); - } - } - - @Test - // @Ignore - public void buildGraphWithCycleBetweenDepLevelsAndRetrieveCycle() - throws Exception - { - final URI source = sourceURI(); - - final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); - final ProjectVersionRef dep = new SimpleProjectVersionRef( "org.other", "dep", "1.0" ); - final ProjectVersionRef dep2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0" ); - - final RelationshipGraph graph = simpleGraph( project ); - - /* @formatter:off */ - final Set> rejected = graph.storeRelationships( - new DependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null, false ), null, 0, false ), - new DependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null, false ), null, 0, false ), - new DependencyRelationship( source, dep2, new SimpleArtifactRef( dep, null, null, false ), null, 0, false ) ); - /* @formatter:on */ - - assertThat( rejected, notNullValue() ); - - // System.out.println( "Rejects: " + rejected ); - // - // assertThat( rejected.size(), equalTo( 2 ) ); - // final ProjectRelationship reject = rejected.iterator() - // .next(); - // assertThat( reject.getDeclaring(), equalTo( dep2 ) ); - // assertThat( reject.getTarget() - // .asProjectVersionRef(), equalTo( dep ) ); - - final Set cycles = graph.getCycles(); - System.out.println( "Cycles:\n\n" + join( cycles, "\n" ) ); - assertThat( cycles.size(), equalTo( 1 ) ); - - for ( final EProjectCycle cycle : cycles ) - { - final Set projects = cycle.getAllParticipatingProjects(); - assertThat( projects.contains( project ), equalTo( false ) ); - assertThat( projects.contains( dep ), equalTo( true ) ); - assertThat( projects.contains( dep2 ), equalTo( true ) ); - } - } - - @Test - // @Ignore - public void GB_cycleFromGraph1PresentInGraph2WhenNodeIsCrossReferenced() - throws Exception - { - final URI source = sourceURI(); - - final ProjectVersionRef a = new SimpleProjectVersionRef( "project", "A", "1.0" ); - final ProjectVersionRef b = new SimpleProjectVersionRef( "project", "B", "1.0" ); - final ProjectVersionRef c = new SimpleProjectVersionRef( "project", "C", "1.0" ); - - final ProjectVersionRef d = new SimpleProjectVersionRef( "project", "D", "1.0" ); - final ProjectVersionRef e = new SimpleProjectVersionRef( "project", "E", "1.0" ); - - final RelationshipGraph graph = simpleGraph( a ); - - /* @formatter:off */ - // a --> b --> c --> a - // d --> e --> c --> a --> b --> c - graph.storeRelationships( new DependencyRelationship( source, a, new SimpleArtifactRef( b, null, null, false ), null, 0, false ), - new DependencyRelationship( source, b, new SimpleArtifactRef( c, null, null, false ), null, 0, false ), - new DependencyRelationship( source, c, new SimpleArtifactRef( a, null, null, false ), null, 0, false ), - new DependencyRelationship( source, d, new SimpleArtifactRef( e, null, null, false ), null, 0, false ), - new DependencyRelationship( source, e, new SimpleArtifactRef( c, null, null, false ), null, 0, false ) ); - /* @formatter:on */ - - final RelationshipGraph graph2 = - graphFactory().open( new ViewParams.Builder( graph.getParams() ).withRoots( d ) - .build(), false ); - - final Set cycles1 = graph.getCycles(); - System.out.println( "Graph 1 Cycles:\n\n" + join( cycles1, "\n" ) ); - - final Set cycles2 = graph2.getCycles(); - System.out.println( "Graph 2 Cycles:\n\n" + join( cycles2, "\n" ) ); - - assertThat( cycles1.size(), equalTo( 1 ) ); - assertThat( cycles2.size(), equalTo( 1 ) ); - - final Set> cycleSets = new HashSet>(); - cycleSets.add( cycles1 ); - cycleSets.add( cycles2 ); - - int i = 0; - for ( final Set cycles : cycleSets ) - { - int j = 0; - for ( final EProjectCycle cycle : cycles ) - { - final Set refs = cycle.getAllParticipatingProjects(); - assertThat( i + ", " + j + " missing A", refs.contains( a ), equalTo( true ) ); - assertThat( i + ", " + j + " missing B", refs.contains( b ), equalTo( true ) ); - assertThat( i + ", " + j + " missing C", refs.contains( c ), equalTo( true ) ); - j++; - } - i++; - } - } - - @Test - // @Ignore - public void cycleFromGraph1MissingInFilteredGraph2WhenOneRelationshipInCycleFilteredOut() - throws Exception - { - final URI source = sourceURI(); - - final ProjectVersionRef a = new SimpleProjectVersionRef( "project", "A", "1.0" ); - final ProjectVersionRef b = new SimpleProjectVersionRef( "project", "B", "1.0" ); - final ProjectVersionRef c = new SimpleProjectVersionRef( "project", "C", "1.0" ); - - final ProjectVersionRef d = new SimpleProjectVersionRef( "project", "D", "1.0" ); - final ProjectVersionRef e = new SimpleProjectVersionRef( "project", "E", "1.0" ); - - final RelationshipGraph graph = simpleGraph( a ); - - /* @formatter:off */ - // a --> b --> c --> a - // d --> e --> c --> a --> b --> c - graph.storeRelationships( new DependencyRelationship( source, a, new SimpleArtifactRef( b, null, null, false ), null, 0, false ), - new DependencyRelationship( source, c, new SimpleArtifactRef( a, null, null, false ), null, 0, false ), - new PluginRelationship( source, b, c, 0, false ), - new DependencyRelationship( source, d, new SimpleArtifactRef( e, null, null, false ), null, 0, false ), - new DependencyRelationship( source, e, new SimpleArtifactRef( c, null, null, false ), null, 0, false ) ); - /* @formatter:on */ - - final RelationshipGraph graph2 = - graphFactory().open( new ViewParams.Builder( graph.getParams() ).withFilter( new DependencyFilter() ) - .withRoots( d ) - .build(), false ); - - final Set cycles1 = graph.getCycles(); - System.out.println( "Graph 1 Cycles:\n\n" + join( cycles1, "\n" ) ); - - final Set cycles2 = graph2.getCycles(); - System.out.println( "Graph 2 Cycles:\n\n" + join( cycles2, "\n" ) ); - - assertThat( cycles1.size(), equalTo( 1 ) ); - assertThat( cycles2.size(), equalTo( 0 ) ); - - final Set> cycleSets = new HashSet>(); - cycleSets.add( cycles1 ); - // cycleSets.add( cycles2 ); - - int i = 0; - for ( final Set cycles : cycleSets ) - { - int j = 0; - for ( final EProjectCycle cycle : cycles ) - { - final Set refs = cycle.getAllParticipatingProjects(); - assertThat( i + ", " + j + " missing A", refs.contains( a ), equalTo( true ) ); - assertThat( i + ", " + j + " missing B", refs.contains( b ), equalTo( true ) ); - assertThat( i + ", " + j + " missing C", refs.contains( c ), equalTo( true ) ); - j++; - } - i++; - } - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphTCK.java deleted file mode 100644 index fab9bbb5..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphTCK.java +++ /dev/null @@ -1,168 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -import java.net.URI; -import java.util.Iterator; -import java.util.List; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.filter.DependencyFilter; -import org.commonjava.maven.atlas.graph.model.GraphPath; -import org.commonjava.maven.atlas.graph.mutate.ManagedDependencyMutator; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.traverse.AncestryTraversal; -import org.commonjava.maven.atlas.graph.traverse.TraversalType; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.junit.Test; -import org.slf4j.LoggerFactory; - -public abstract class RelationshipGraphTCK - extends AbstractSPI_TCK -{ - - @Test - public void createPath_ReturnNullWhenTargetVersionIsAnExpression() - throws Exception - { - final ProjectVersionRef from = new SimpleProjectVersionRef( "org.from", "project", "1.0" ); - final ProjectVersionRef to = new SimpleProjectVersionRef( "org.to", "artifact", "${version.target}" ); - - final URI src = new URI( "test:source-uri" ); - final ProjectRelationship rel = - new DependencyRelationship( src, from, to.asArtifactRef( "jar", null ), DependencyScope.compile, 0, false ); - - final RelationshipGraph graph = simpleGraph( from ); - final GraphPath path = graph.createPath( rel ); - - assertThat( path, nullValue() ); - } - - @Test - public void storeBOMThenVerifyBomGAVPresentInView() - throws Exception - { - final URI src = sourceURI(); - final ProjectVersionRef gav = new SimpleProjectVersionRef( "g", "a", "v" ); - - final ProjectVersionRef d1 = new SimpleProjectVersionRef( "g", "d1", "1" ); - final ProjectVersionRef d2 = new SimpleProjectVersionRef( "g", "d2", "2" ); - - final RelationshipGraph graph = - openGraph( new ViewParams( newWorkspaceId(), new DependencyFilter(), new ManagedDependencyMutator(), gav ), - true ); - - /* @formatter:off */ - graph.storeRelationships( - new ParentRelationship(src, gav), - new DependencyRelationship(src, gav, d1.asArtifactRef("jar", - null), DependencyScope.compile, 0, true), - new DependencyRelationship(src, gav, d2.asArtifactRef("jar", - null), DependencyScope.compile, 1, true)); - /* @formatter:on */ - - graph.containsGraph( gav ); - } - - @Test - public void connectThreeGraphsWithParentInterrelationships() - throws Exception - { - final ProjectVersionRef r = new SimpleProjectVersionRef( "org.test", "root", "1" ); - final ProjectVersionRef p = new SimpleProjectVersionRef( "org.test", "parent", "1.0" ); - final ProjectVersionRef c = new SimpleProjectVersionRef( "org.test", "child", "1.0" ); - - final URI source = sourceURI(); - - final String wsid = newWorkspaceId(); - - openGraph( new ViewParams( wsid, r ), true ).storeRelationships( new ParentRelationship( source, r ) ); - - openGraph( new ViewParams( wsid, p ), true ).storeRelationships( new ParentRelationship( source, p, r ) ); - - final RelationshipGraph child = openGraph( new ViewParams( wsid, c ), true ); - - child.storeRelationships( new ParentRelationship( source, c, p ) ); - - System.out.println( "Incomplete subgraphs: " + child.getIncompleteSubgraphs() ); - System.out.flush(); - assertThat( child.isComplete(), equalTo( true ) ); - - final AncestryTraversal ancestryTraversal = new AncestryTraversal(); - child.traverse( ancestryTraversal, TraversalType.depth_first ); - - final List ancestry = ancestryTraversal.getAncestry(); - LoggerFactory.getLogger( getClass() ) - .info( "Ancestry: {}", ancestry ); - - assertThat( ancestry, notNullValue() ); - assertThat( ancestry.size(), equalTo( 3 ) ); - - final Iterator iterator = ancestry.iterator(); - assertThat( iterator.next(), equalTo( c ) ); - assertThat( iterator.next(), equalTo( p ) ); - assertThat( iterator.next(), equalTo( r ) ); - } - - @Test - public void connectThreeGraphsWithParentInterrelationships_WrongOrder() - throws Exception - { - final ProjectVersionRef r = new SimpleProjectVersionRef( "org.test", "root", "1" ); - final ProjectVersionRef p = new SimpleProjectVersionRef( "org.test", "parent", "1.0" ); - final ProjectVersionRef c = new SimpleProjectVersionRef( "org.test", "child", "1.0" ); - - final URI source = sourceURI(); - - final String wsid = newWorkspaceId(); - - final RelationshipGraph child = openGraph( new ViewParams( wsid, c ), true ); - - child.storeRelationships( new ParentRelationship( source, c, p ) ); - - openGraph( new ViewParams( wsid, p ), true ).storeRelationships( new ParentRelationship( source, p, r ) ); - - openGraph( new ViewParams( wsid, r ), true ).storeRelationships( new ParentRelationship( source, r ) ); - - assertThat( child.isComplete(), equalTo( true ) ); - - final AncestryTraversal ancestryTraversal = new AncestryTraversal(); - child.traverse( ancestryTraversal, TraversalType.depth_first ); - - final List ancestry = ancestryTraversal.getAncestry(); - LoggerFactory.getLogger( getClass() ) - .info( "Ancestry: {}", ancestry ); - - assertThat( ancestry, notNullValue() ); - assertThat( ancestry.size(), equalTo( 3 ) ); - - final Iterator iterator = ancestry.iterator(); - assertThat( iterator.next(), equalTo( c ) ); - assertThat( iterator.next(), equalTo( p ) ); - assertThat( iterator.next(), equalTo( r ) ); - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphConnection_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/conn/RelationshipGraphConnection_CreateAndRetrieveByIdTCK.java similarity index 65% rename from tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphConnection_TCK.java rename to tck/src/main/java/org/commonjava/maven/atlas/tck/graph/conn/RelationshipGraphConnection_CreateAndRetrieveByIdTCK.java index faeb7b4d..299979cd 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphConnection_TCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/conn/RelationshipGraphConnection_CreateAndRetrieveByIdTCK.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.tck.graph; +package org.commonjava.maven.atlas.tck.graph.conn; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; @@ -22,14 +22,16 @@ import java.util.Set; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Ignore; import org.junit.Test; -public abstract class RelationshipGraphConnection_TCK +public class RelationshipGraphConnection_CreateAndRetrieveByIdTCK extends AbstractSPI_TCK { @Test - public void createWorkspaceAndRetrieveById() + public void run() throws Exception { final String wsid = newWorkspaceId(); @@ -50,26 +52,4 @@ public void createWorkspaceAndRetrieveById() assertThat( result.equals( connection ), equalTo( true ) ); } - @Test - public void createWorkspaceAndFindInAllWorkspacesListing() - throws Exception - { - final String wsid = newWorkspaceId(); - final RelationshipGraphConnection connection = connectionFactory().openConnection( wsid, true ); - - System.out.println( "wsid: " + connection.getWorkspaceId() ); - - assertThat( connection, notNullValue() ); - - logger.info( "Created connection: {}", connection ); - - final Set all = connectionFactory().listWorkspaces(); - - logger.info( "Retrieved all workspaces: {}", all ); - - assertThat( all, notNullValue() ); - assertThat( all.size(), equalTo( 1 ) ); - assertThat( all.contains( connection.getWorkspaceId() ), equalTo( true ) ); - } - } diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/conn/RelationshipGraphConnection_CreateAndVerifyInListingTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/conn/RelationshipGraphConnection_CreateAndVerifyInListingTCK.java new file mode 100644 index 00000000..a853923d --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/conn/RelationshipGraphConnection_CreateAndVerifyInListingTCK.java @@ -0,0 +1,55 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.conn; + +import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Ignore; +import org.junit.Test; + +import java.util.Set; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertThat; + +public class RelationshipGraphConnection_CreateAndVerifyInListingTCK + extends AbstractSPI_TCK +{ + + @Test + public void run() + throws Exception + { + final String wsid = newWorkspaceId(); + final RelationshipGraphConnection connection = connectionFactory().openConnection( wsid, true ); + + System.out.println( "wsid: " + connection.getWorkspaceId() ); + + assertThat( connection, notNullValue() ); + + logger.info( "Created connection: {}", connection ); + + final Set all = connectionFactory().listWorkspaces(); + + logger.info( "Retrieved all workspaces: {}", all ); + + assertThat( all, notNullValue() ); + assertThat( all.size(), equalTo( 1 ) ); + assertThat( all.contains( connection.getWorkspaceId() ), equalTo( true ) ); + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BackToRootTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BackToRootTCK.java new file mode 100644 index 00000000..97c62c8d --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BackToRootTCK.java @@ -0,0 +1,78 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.cycle; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.ViewParams; +import org.commonjava.maven.atlas.graph.filter.DependencyFilter; +import org.commonjava.maven.atlas.graph.model.EProjectCycle; +import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Ignore; +import org.junit.Test; + +import java.net.URI; +import java.util.HashSet; +import java.util.Set; + +import static org.apache.commons.lang.StringUtils.join; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertThat; + +public class CycleDetection_BackToRootTCK + extends AbstractSPI_TCK +{ + + @Test + public void run() + throws Exception + { + final URI source = sourceURI(); + + final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); + final ProjectVersionRef dep = new SimpleProjectVersionRef( "org.other", "dep", "1.0" ); + final ProjectVersionRef dep2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0" ); + + final RelationshipGraph graph = simpleGraph( project ); + + /* @formatter:off */ + graph.storeRelationships( new SimpleDependencyRelationship( source, project, dep.asJarArtifact(), null, 0, false ), + new SimpleDependencyRelationship( source, dep, dep2.asJarArtifact(), null, 0, false ), + new SimpleDependencyRelationship( source, dep2, project.asJarArtifact(), null, 0, false ) ); + /* @formatter:on */ + + // final EProjectGraph graph = getManager().getGraph( session, project ); + + final Set cycles = graph.getCycles(); + System.out.println( "Cycles:\n\n" + join( cycles, "\n" ) ); + assertThat( cycles.size(), equalTo( 1 ) ); + + for ( final EProjectCycle cycle : cycles ) + { + final Set projects = cycle.getAllParticipatingProjects(); + assertThat( projects.contains( project ), equalTo( true ) ); + assertThat( projects.contains( dep ), equalTo( true ) ); + assertThat( projects.contains( dep2 ), equalTo( true ) ); + } + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java new file mode 100644 index 00000000..ff5723e7 --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java @@ -0,0 +1,88 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.cycle; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.ViewParams; +import org.commonjava.maven.atlas.graph.filter.DependencyFilter; +import org.commonjava.maven.atlas.graph.model.EProjectCycle; +import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Ignore; +import org.junit.Test; + +import java.net.URI; +import java.util.HashSet; +import java.util.Set; + +import static org.apache.commons.lang.StringUtils.join; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertThat; + +public class CycleDetection_BetweenDepLevelsTCK + extends AbstractSPI_TCK +{ + + @Test + public void run() + throws Exception + { + final URI source = sourceURI(); + + final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); + final ProjectVersionRef dep = new SimpleProjectVersionRef( "org.other", "dep", "1.0" ); + final ProjectVersionRef dep2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0" ); + + final RelationshipGraph graph = simpleGraph( project ); + + /* @formatter:off */ + final Set> rejected = graph.storeRelationships( + new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null, false ), null, 0, false ), + new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null, false ), null, 0, false ), + new SimpleDependencyRelationship( source, dep2, new SimpleArtifactRef( dep, null, null, false ), null, 0, false ) ); + /* @formatter:on */ + + assertThat( rejected, notNullValue() ); + + // System.out.println( "Rejects: " + rejected ); + // + // assertThat( rejected.size(), equalTo( 2 ) ); + // final ProjectRelationship reject = rejected.iterator() + // .next(); + // assertThat( reject.getDeclaring(), equalTo( dep2 ) ); + // assertThat( reject.getTarget() + // .asProjectVersionRef(), equalTo( dep ) ); + + final Set cycles = graph.getCycles(); + System.out.println( "Cycles:\n\n" + join( cycles, "\n" ) ); + assertThat( cycles.size(), equalTo( 1 ) ); + + for ( final EProjectCycle cycle : cycles ) + { + final Set projects = cycle.getAllParticipatingProjects(); + assertThat( projects.contains( project ), equalTo( false ) ); + assertThat( projects.contains( dep ), equalTo( true ) ); + assertThat( projects.contains( dep2 ), equalTo( true ) ); + } + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java new file mode 100644 index 00000000..3c32be4b --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java @@ -0,0 +1,105 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.cycle; + +import static org.apache.commons.lang.StringUtils.join; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertThat; + +import java.net.URI; +import java.util.HashSet; +import java.util.Set; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.ViewParams; +import org.commonjava.maven.atlas.graph.filter.DependencyFilter; +import org.commonjava.maven.atlas.graph.model.EProjectCycle; +import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Ignore; +import org.junit.Test; + +public class CycleDetection_FilterRemovesCycleTCK + extends AbstractSPI_TCK +{ + + @Test + public void run() + throws Exception + { + final URI source = sourceURI(); + + final ProjectVersionRef a = new SimpleProjectVersionRef( "project", "A", "1.0" ); + final ProjectVersionRef b = new SimpleProjectVersionRef( "project", "B", "1.0" ); + final ProjectVersionRef c = new SimpleProjectVersionRef( "project", "C", "1.0" ); + + final ProjectVersionRef d = new SimpleProjectVersionRef( "project", "D", "1.0" ); + final ProjectVersionRef e = new SimpleProjectVersionRef( "project", "E", "1.0" ); + + final RelationshipGraph graph = simpleGraph( a ); + + /* @formatter:off */ + // a --> b --> c --> a + // d --> e --> c --> a --> b --> c + graph.storeRelationships( new SimpleDependencyRelationship( source, a, new SimpleArtifactRef( b, null, null, false ), null, 0, false ), + new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( a, null, null, false ), null, 0, false ), + new SimplePluginRelationship( source, b, c, 0, false ), + new SimpleDependencyRelationship( source, d, new SimpleArtifactRef( e, null, null, false ), null, 0, false ), + new SimpleDependencyRelationship( source, e, new SimpleArtifactRef( c, null, null, false ), null, 0, false ) ); + /* @formatter:on */ + + final RelationshipGraph graph2 = + graphFactory().open( new ViewParams.Builder( graph.getParams() ).withFilter( new DependencyFilter() ) + .withRoots( d ) + .build(), false ); + + final Set cycles1 = graph.getCycles(); + System.out.println( "Graph 1 Cycles:\n\n" + join( cycles1, "\n" ) ); + + final Set cycles2 = graph2.getCycles(); + System.out.println( "Graph 2 Cycles:\n\n" + join( cycles2, "\n" ) ); + + assertThat( cycles1.size(), equalTo( 1 ) ); + assertThat( cycles2.size(), equalTo( 0 ) ); + + final Set> cycleSets = new HashSet>(); + cycleSets.add( cycles1 ); + // cycleSets.add( cycles2 ); + + int i = 0; + for ( final Set cycles : cycleSets ) + { + int j = 0; + for ( final EProjectCycle cycle : cycles ) + { + final Set refs = cycle.getAllParticipatingProjects(); + System.out.printf( "Cycle (%d,%d) projects: %s\n\n", i, j, refs); + assertThat( i + ", " + j + " missing A", refs.contains( a ), equalTo( true ) ); + assertThat( i + ", " + j + " missing B", refs.contains( b ), equalTo( true ) ); + assertThat( i + ", " + j + " missing C", refs.contains( c ), equalTo( true ) ); + j++; + } + i++; + } + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java new file mode 100644 index 00000000..fe3e1d11 --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java @@ -0,0 +1,67 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.cycle; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.ViewParams; +import org.commonjava.maven.atlas.graph.filter.DependencyFilter; +import org.commonjava.maven.atlas.graph.model.EProjectCycle; +import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Ignore; +import org.junit.Test; + +import java.net.URI; +import java.util.HashSet; +import java.util.Set; + +import static org.apache.commons.lang.StringUtils.join; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertThat; + +public class CycleDetection_IntroduceToExistingTCK + extends AbstractSPI_TCK +{ + + @Test + public void run() + throws Exception + { + final URI source = sourceURI(); + + final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); + final ProjectVersionRef dep = new SimpleProjectVersionRef( "org.other", "dep", "1.0" ); + final ProjectVersionRef dep2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0" ); + + final RelationshipGraph graph = simpleGraph( project ); + + /* @formatter:off */ + graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null, false ), null, 0, false ), + new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null, false ), null, 0, false ) ); + + final boolean introduces = graph.introducesCycle( new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( project, null, null, false ), null, 0, false ) ); + /* @formatter:on */ + + assertThat( introduces, equalTo( true ) ); + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java new file mode 100644 index 00000000..fb2a5ae2 --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java @@ -0,0 +1,101 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.cycle; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.ViewParams; +import org.commonjava.maven.atlas.graph.filter.DependencyFilter; +import org.commonjava.maven.atlas.graph.model.EProjectCycle; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Ignore; +import org.junit.Test; + +import java.net.URI; +import java.util.HashSet; +import java.util.Set; + +import static org.apache.commons.lang.StringUtils.join; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +public class CycleDetection_RootDependentTCK + extends AbstractSPI_TCK +{ + + @Test + public void run() + throws Exception + { + final URI source = sourceURI(); + + final ProjectVersionRef a = new SimpleProjectVersionRef( "project", "A", "1.0" ); + final ProjectVersionRef b = new SimpleProjectVersionRef( "project", "B", "1.0" ); + final ProjectVersionRef c = new SimpleProjectVersionRef( "project", "C", "1.0" ); + + final ProjectVersionRef d = new SimpleProjectVersionRef( "project", "D", "1.0" ); + final ProjectVersionRef e = new SimpleProjectVersionRef( "project", "E", "1.0" ); + + final RelationshipGraph graph = simpleGraph( a ); + + /* @formatter:off */ + // a --> b --> c --> a + // d --> e --> c --> a --> b --> c + graph.storeRelationships( new SimpleDependencyRelationship( source, a, new SimpleArtifactRef( b, null, null, false ), null, 0, false ), + new SimpleDependencyRelationship( source, b, new SimpleArtifactRef( c, null, null, false ), null, 0, false ), + new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( a, null, null, false ), null, 0, false ), + new SimpleDependencyRelationship( source, d, new SimpleArtifactRef( e, null, null, false ), null, 0, false ), + new SimpleDependencyRelationship( source, e, new SimpleArtifactRef( c, null, null, false ), null, 0, false ) ); + /* @formatter:on */ + + final RelationshipGraph graph2 = + graphFactory().open( new ViewParams.Builder( graph.getParams() ).withRoots( d ) + .build(), false ); + + final Set cycles1 = graph.getCycles(); + System.out.println( "Graph 1 Cycles:\n\n" + join( cycles1, "\n" ) ); + + final Set cycles2 = graph2.getCycles(); + System.out.println( "Graph 2 Cycles:\n\n" + join( cycles2, "\n" ) ); + + assertThat( cycles1.size(), equalTo( 1 ) ); + assertThat( cycles2.size(), equalTo( 1 ) ); + + final Set> cycleSets = new HashSet>(); + cycleSets.add( cycles1 ); + cycleSets.add( cycles2 ); + + int i = 0; + for ( final Set cycles : cycleSets ) + { + int j = 0; + for ( final EProjectCycle cycle : cycles ) + { + final Set refs = cycle.getAllParticipatingProjects(); + assertThat( i + ", " + j + " missing A", refs.contains( a ), equalTo( true ) ); + assertThat( i + ", " + j + " missing B", refs.contains( b ), equalTo( true ) ); + assertThat( i + ", " + j + " missing C", refs.contains( c ), equalTo( true ) ); + j++; + } + i++; + } + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphFactoryTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/fac/RelationshipGraphFactory_OpenStoreDeleteReopenTCK.java similarity index 85% rename from tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphFactoryTCK.java rename to tck/src/main/java/org/commonjava/maven/atlas/tck/graph/fac/RelationshipGraphFactory_OpenStoreDeleteReopenTCK.java index 33dbdcc4..f9966dcd 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/RelationshipGraphFactoryTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/fac/RelationshipGraphFactory_OpenStoreDeleteReopenTCK.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.tck.graph; +package org.commonjava.maven.atlas.tck.graph.fac; import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.Assert.assertThat; @@ -24,20 +24,23 @@ import org.commonjava.maven.atlas.graph.RelationshipGraph; import org.commonjava.maven.atlas.graph.RelationshipGraphException; import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; import org.commonjava.maven.atlas.graph.traverse.RelationshipGraphTraversal; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Ignore; import org.junit.Test; -public abstract class RelationshipGraphFactoryTCK +public class RelationshipGraphFactory_OpenStoreDeleteReopenTCK extends AbstractSPI_TCK { @Test - public void openStoreDeleteAndReopen() +// @Ignore + public void run() throws Exception { final ProjectVersionRef r = new SimpleProjectVersionRef( "org.test", "root", "1" ); @@ -50,12 +53,12 @@ public void openStoreDeleteAndReopen() final RelationshipGraph child = openGraph( new ViewParams( wsid, c ), true ); - child.storeRelationships( new ParentRelationship( source, c, p ) ); + child.storeRelationships( new SimpleParentRelationship( source, c, p ) ); - openGraph( new ViewParams( wsid, p ), true ).storeRelationships( new ParentRelationship( source, p, r ) ); + openGraph( new ViewParams( wsid, p ), true ).storeRelationships( new SimpleParentRelationship( source, p, r ) ); RelationshipGraph graph = openGraph( new ViewParams( wsid, r ), true ); - graph.storeRelationships( new ParentRelationship( source, r ) ); + graph.storeRelationships( new SimpleParentRelationship( source, r ) ); // final Thread t = new Thread( new DelayTraverseRunnable( graph ) ); // t.setDaemon( true ); @@ -68,7 +71,7 @@ public void openStoreDeleteAndReopen() graph = openGraph( new ViewParams( wsid, c ), true ); assertThat( graph, notNullValue() ); - graph.storeRelationships( new ParentRelationship( source, c, p ) ); + graph.storeRelationships( new SimpleParentRelationship( source, c, p ) ); } finally { @@ -94,8 +97,8 @@ public void run() graph.traverse( new RelationshipGraphTraversal() { @Override - public boolean traverseEdge( final ProjectRelationship relationship, - final List> path ) + public boolean traverseEdge( final ProjectRelationship relationship, + final List> path ) { try { @@ -115,8 +118,8 @@ public void startTraverse( final RelationshipGraph graph ) } @Override - public boolean preCheck( final ProjectRelationship relationship, - final List> path ) + public boolean preCheck( final ProjectRelationship relationship, + final List> path ) { return true; } @@ -128,8 +131,8 @@ public void endTraverse( final RelationshipGraph graph ) } @Override - public void edgeTraversed( final ProjectRelationship relationship, - final List> path ) + public void edgeTraversed( final ProjectRelationship relationship, + final List> path ) { } } ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_ConnectOutOfOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_ConnectOutOfOrderTCK.java new file mode 100644 index 00000000..523c2dce --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_ConnectOutOfOrderTCK.java @@ -0,0 +1,87 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.manip; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertThat; + +import java.net.URI; +import java.util.Iterator; +import java.util.List; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.ViewParams; +import org.commonjava.maven.atlas.graph.filter.DependencyFilter; +import org.commonjava.maven.atlas.graph.model.GraphPath; +import org.commonjava.maven.atlas.graph.mutate.ManagedDependencyMutator; +import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; +import org.commonjava.maven.atlas.graph.traverse.AncestryTraversal; +import org.commonjava.maven.atlas.graph.traverse.TraversalType; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Ignore; +import org.junit.Test; +import org.slf4j.LoggerFactory; + +public class RelationshipGraph_ConnectOutOfOrderTCK + extends AbstractSPI_TCK +{ + + @Test + public void run() + throws Exception + { + final ProjectVersionRef r = new SimpleProjectVersionRef( "org.test", "root", "1" ); + final ProjectVersionRef p = new SimpleProjectVersionRef( "org.test", "parent", "1.0" ); + final ProjectVersionRef c = new SimpleProjectVersionRef( "org.test", "child", "1.0" ); + + final URI source = sourceURI(); + + final String wsid = newWorkspaceId(); + + final RelationshipGraph child = openGraph( new ViewParams( wsid, c ), true ); + + child.storeRelationships( new SimpleParentRelationship( source, c, p ) ); + + openGraph( new ViewParams( wsid, p ), true ).storeRelationships( new SimpleParentRelationship( source, p, r ) ); + + openGraph( new ViewParams( wsid, r ), true ).storeRelationships( new SimpleParentRelationship( source, r ) ); + + assertThat( child.isComplete(), equalTo( true ) ); + + final AncestryTraversal ancestryTraversal = new AncestryTraversal(); + child.traverse( ancestryTraversal, TraversalType.depth_first ); + + final List ancestry = ancestryTraversal.getAncestry(); + LoggerFactory.getLogger( getClass() ) + .info( "Ancestry: {}", ancestry ); + + assertThat( ancestry, notNullValue() ); + assertThat( ancestry.size(), equalTo( 3 ) ); + + final Iterator iterator = ancestry.iterator(); + assertThat( iterator.next(), equalTo( c ) ); + assertThat( iterator.next(), equalTo( p ) ); + assertThat( iterator.next(), equalTo( r ) ); + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_ConnectWParentInterTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_ConnectWParentInterTCK.java new file mode 100644 index 00000000..e68a95ba --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_ConnectWParentInterTCK.java @@ -0,0 +1,81 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.manip; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.ViewParams; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; +import org.commonjava.maven.atlas.graph.traverse.AncestryTraversal; +import org.commonjava.maven.atlas.graph.traverse.TraversalType; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Ignore; +import org.junit.Test; +import org.slf4j.LoggerFactory; + +import java.net.URI; +import java.util.Iterator; +import java.util.List; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertThat; + +public class RelationshipGraph_ConnectWParentInterTCK + extends AbstractSPI_TCK +{ + + @Test + public void run() + throws Exception + { + final ProjectVersionRef r = new SimpleProjectVersionRef( "org.test", "root", "1" ); + final ProjectVersionRef p = new SimpleProjectVersionRef( "org.test", "parent", "1.0" ); + final ProjectVersionRef c = new SimpleProjectVersionRef( "org.test", "child", "1.0" ); + + final URI source = sourceURI(); + + final String wsid = newWorkspaceId(); + + openGraph( new ViewParams( wsid, r ), true ).storeRelationships( new SimpleParentRelationship( r ) ); + + openGraph( new ViewParams( wsid, p ), true ).storeRelationships( new SimpleParentRelationship( source, p, r ) ); + + final RelationshipGraph child = openGraph( new ViewParams( wsid, c ), true ); + + child.storeRelationships( new SimpleParentRelationship( source, c, p ) ); + + System.out.println( "Incomplete subgraphs: " + child.getIncompleteSubgraphs() ); + System.out.flush(); + assertThat( child.isComplete(), equalTo( true ) ); + + final AncestryTraversal ancestryTraversal = new AncestryTraversal(); + child.traverse( ancestryTraversal, TraversalType.depth_first ); + + final List ancestry = ancestryTraversal.getAncestry(); + LoggerFactory.getLogger( getClass() ) + .info( "Ancestry: {}", ancestry ); + + assertThat( ancestry, notNullValue() ); + assertThat( ancestry.size(), equalTo( 3 ) ); + + final Iterator iterator = ancestry.iterator(); + assertThat( iterator.next(), equalTo( c ) ); + assertThat( iterator.next(), equalTo( p ) ); + assertThat( iterator.next(), equalTo( r ) ); + } +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_NullPathOnTargetExprVersionTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_NullPathOnTargetExprVersionTCK.java new file mode 100644 index 00000000..5bcb42ea --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_NullPathOnTargetExprVersionTCK.java @@ -0,0 +1,62 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.manip; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.ViewParams; +import org.commonjava.maven.atlas.graph.filter.DependencyFilter; +import org.commonjava.maven.atlas.graph.model.GraphPath; +import org.commonjava.maven.atlas.graph.mutate.ManagedDependencyMutator; +import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; +import org.commonjava.maven.atlas.graph.traverse.AncestryTraversal; +import org.commonjava.maven.atlas.graph.traverse.TraversalType; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Test; +import org.slf4j.LoggerFactory; + +import java.net.URI; +import java.util.Iterator; +import java.util.List; + +import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.assertThat; + +public class RelationshipGraph_NullPathOnTargetExprVersionTCK + extends AbstractSPI_TCK +{ + + @Test + public void run() + throws Exception + { + final ProjectVersionRef from = new SimpleProjectVersionRef( "org.from", "project", "1.0" ); + final ProjectVersionRef to = new SimpleProjectVersionRef( "org.to", "artifact", "${version.target}" ); + + final URI src = new URI( "test:source-uri" ); + final ProjectRelationship rel = + new SimpleDependencyRelationship( src, from, to.asArtifactRef( "jar", null ), DependencyScope.compile, 0, false ); + + final RelationshipGraph graph = simpleGraph( from ); + final GraphPath path = graph.createPath( rel ); + + assertThat( path, nullValue() ); + } +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java new file mode 100644 index 00000000..30019ca3 --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java @@ -0,0 +1,70 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.manip; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.ViewParams; +import org.commonjava.maven.atlas.graph.filter.DependencyFilter; +import org.commonjava.maven.atlas.graph.mutate.ManagedDependencyMutator; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; +import org.commonjava.maven.atlas.graph.traverse.AncestryTraversal; +import org.commonjava.maven.atlas.graph.traverse.TraversalType; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Test; +import org.slf4j.LoggerFactory; + +import java.net.URI; +import java.util.Iterator; +import java.util.List; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertThat; + +public class RelationshipGraph_StoreAndVerifyInView_TCK + extends AbstractSPI_TCK +{ + + @Test + public void run() + throws Exception + { + final URI src = sourceURI(); + final ProjectVersionRef gav = new SimpleProjectVersionRef( "g", "a", "v" ); + + final ProjectVersionRef d1 = new SimpleProjectVersionRef( "g", "d1", "1" ); + final ProjectVersionRef d2 = new SimpleProjectVersionRef( "g", "d2", "2" ); + + final RelationshipGraph graph = + openGraph( new ViewParams( newWorkspaceId(), new DependencyFilter(), new ManagedDependencyMutator(), gav ), + true ); + + /* @formatter:off */ + graph.storeRelationships( + new SimpleParentRelationship(src, gav), + new SimpleDependencyRelationship(src, gav, d1.asArtifactRef("jar", + null), DependencyScope.compile, 0, true), + new SimpleDependencyRelationship(src, gav, d2.asArtifactRef("jar", + null), DependencyScope.compile, 1, true)); + /* @formatter:on */ + + graph.containsGraph( gav ); + } +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java new file mode 100644 index 00000000..b0f06aba --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java @@ -0,0 +1,80 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.selection; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertThat; + +import java.net.URI; +import java.util.Set; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.ViewParams; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Ignore; +import org.junit.Test; + +public class SubGraphSelectionTCK + extends AbstractSPI_TCK +{ + + @Test + public void run() + throws Exception + { + final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); + final ProjectVersionRef varDep = new SimpleProjectVersionRef( "org.other", "dep", "1.0-SNAPSHOT" ); + final ProjectVersionRef varD2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0-SNAPSHOT" ); + final ProjectVersionRef selected = new SimpleProjectVersionRef( varDep, "1.0-20130314.161200-1" ); + final ProjectVersionRef sel2 = new SimpleProjectVersionRef( varD2, "1.0-20130314.161200-1" ); + + assertThat( varDep.isVariableVersion(), equalTo( true ) ); + + final URI source = sourceURI(); + final RelationshipGraph graph = simpleGraph( project ); + + /* @formatter:off */ + graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false ), + new SimpleDependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false ) ); + /* @formatter:on */ + + Set variables = graph.getVariableSubgraphs(); + System.out.println( "Before selection here are the variable nodes: " + variables ); + assertThat( variables.contains( varDep ), equalTo( true ) ); + + final RelationshipGraph graph2 = + graphFactory().open( + new ViewParams.Builder( graph.getParams() ).withSelection( varDep.asProjectRef(), selected ) + .withSelection( varD2.asProjectRef(), sel2 ) + .build(), false ); + + // final ProjectVersionRef selDep = view.selectVersion( varDep.asProjectRef(), selected ); + // assertThat( selDep.asProjectRef(), equalTo( varDep.asProjectRef() ) ); + + variables = graph2.getVariableSubgraphs(); + System.out.println( "After selection here are the variable nodes: " + variables ); + assertThat( variables.isEmpty(), equalTo( true ) ); + + final Set incomplete = graph2.getIncompleteSubgraphs(); + System.out.println( "Checking missing subgraphs for: " + selected ); + assertThat( incomplete.contains( selected ), equalTo( true ) ); + } +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/SubGraphSelectionTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelection_ContextualToViewTCK.java similarity index 55% rename from tck/src/main/java/org/commonjava/maven/atlas/tck/graph/SubGraphSelectionTCK.java rename to tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelection_ContextualToViewTCK.java index 1599e0a3..79ba471b 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/SubGraphSelectionTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelection_ContextualToViewTCK.java @@ -13,69 +13,31 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.tck.graph; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -import java.net.URI; -import java.util.Set; +package org.commonjava.maven.atlas.tck.graph.selection; import org.commonjava.maven.atlas.graph.RelationshipGraph; import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Ignore; import org.junit.Test; -public abstract class SubGraphSelectionTCK - extends AbstractSPI_TCK -{ - - @Test - // @Ignore - public void selectVersionForVariableSubgraph() - throws Exception - { - final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); - final ProjectVersionRef varDep = new SimpleProjectVersionRef( "org.other", "dep", "1.0-SNAPSHOT" ); - final ProjectVersionRef varD2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0-SNAPSHOT" ); - final ProjectVersionRef selected = new SimpleProjectVersionRef( varDep, "1.0-20130314.161200-1" ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( project ); - - /* @formatter:off */ - graph.storeRelationships( new DependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false ), - new DependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false ) ); - /* @formatter:on */ - - Set variables = graph.getVariableSubgraphs(); - System.out.println( "Before selection here are the variable nodes: " + variables ); - assertThat( variables.contains( varDep ), equalTo( true ) ); - - final RelationshipGraph graph2 = - graphFactory().open( new ViewParams.Builder( graph.getParams() ).withSelection( varDep.asProjectRef(), - selected ) - .build(), false ); - - // final ProjectVersionRef selDep = view.selectVersion( varDep.asProjectRef(), selected ); - // assertThat( selDep.asProjectRef(), equalTo( varDep.asProjectRef() ) ); +import java.net.URI; +import java.util.Set; - variables = graph2.getVariableSubgraphs(); - System.out.println( "After selection here are the variable nodes: " + variables ); - assertThat( variables.isEmpty(), equalTo( true ) ); +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertThat; - final Set incomplete = graph2.getIncompleteSubgraphs(); - System.out.println( "Checking missing subgraphs for: " + selected ); - assertThat( incomplete.contains( selected ), equalTo( true ) ); - } +public class SubGraphSelection_ContextualToViewTCK + extends AbstractSPI_TCK +{ @Test - // @Ignore - public void selectVersionForVariableSubgraph_SelectionsContextualToView() + public void run() throws Exception { final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); @@ -87,8 +49,8 @@ public void selectVersionForVariableSubgraph_SelectionsContextualToView() final RelationshipGraph graph = simpleGraph( project ); /* @formatter:off */ - graph.storeRelationships( new DependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false ), - new DependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false ) ); + graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false ), + new SimpleDependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false ) ); /* @formatter:on */ Set variables = graph.getVariableSubgraphs(); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/testutil/TCKDriver.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/testutil/TCKDriver.java new file mode 100644 index 00000000..87cba852 --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/testutil/TCKDriver.java @@ -0,0 +1,19 @@ +package org.commonjava.maven.atlas.tck.graph.testutil; + +import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; +import org.junit.rules.TemporaryFolder; + +import java.io.Closeable; + +/** + * Created by jdcasey on 8/24/15. + */ +public interface TCKDriver extends Closeable +{ + + void setup( TemporaryFolder temp ) + throws Exception; + + RelationshipGraphConnectionFactory getConnectionFactory() + throws Exception; +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/AncestryTraversalTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/AncestryTraversalTCK.java deleted file mode 100644 index 020b0f5f..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/AncestryTraversalTCK.java +++ /dev/null @@ -1,176 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.traverse; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -import java.net.URI; -import java.util.List; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.graph.traverse.AncestryTraversal; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Test; - -public abstract class AncestryTraversalTCK - extends AbstractSPI_TCK -{ - - @Test - public void traverseTwoAncestors() - throws Exception - { - final ProjectVersionRef myRef = new SimpleProjectVersionRef( "my.group", "my-artifact", "1.0" ); - final ProjectVersionRef parentRef = new SimpleProjectVersionRef( "my.group", "my-dad", "1" ); - final ProjectVersionRef grandRef = new SimpleProjectVersionRef( "other.group", "grandpa", "20120821" ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( myRef ); - - graph.storeRelationships( new ParentRelationship( source, myRef, parentRef ), - new ParentRelationship( source, parentRef, grandRef ), - new ParentRelationship( source, grandRef ) ); - - final Set projects = graph.getAllProjects(); - assertThat( projects.size(), equalTo( 3 ) ); - assertThat( projects.contains( myRef ), equalTo( true ) ); - assertThat( projects.contains( parentRef ), equalTo( true ) ); - assertThat( projects.contains( grandRef ), equalTo( true ) ); - - final AncestryTraversal ancestry = new AncestryTraversal(); - graph.traverse( ancestry ); - - final List ancestorRefs = ancestry.getAncestry(); - - logger.info( "Ancestry: %s", ancestorRefs ); - - assertThat( ancestorRefs.size(), equalTo( 3 ) ); - - int idx = 0; - ProjectVersionRef ref = ancestorRefs.get( idx++ ); - - assertThat( ref.getGroupId(), equalTo( "my.group" ) ); - assertThat( ref.getArtifactId(), equalTo( "my-artifact" ) ); - - ref = ancestorRefs.get( idx++ ); - - assertThat( ref.getGroupId(), equalTo( "my.group" ) ); - assertThat( ref.getArtifactId(), equalTo( "my-dad" ) ); - - ref = ancestorRefs.get( idx++ ); - - assertThat( ref.getGroupId(), equalTo( "other.group" ) ); - assertThat( ref.getArtifactId(), equalTo( "grandpa" ) ); - - } - - @Test - public void traverseTwoAncestorsWithEmptyGrandParentRels() - throws Exception - { - final ProjectVersionRef myRef = new SimpleProjectVersionRef( "my.group", "my-artifact", "1.0" ); - final ProjectVersionRef parentRef = new SimpleProjectVersionRef( "my.group", "my-dad", "1" ); - final ProjectVersionRef grandRef = new SimpleProjectVersionRef( "other.group", "grandpa", "20120821" ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( myRef ); - - graph.storeRelationships( new ParentRelationship( source, myRef, parentRef ), - new ParentRelationship( source, parentRef, grandRef ) ); - - final AncestryTraversal ancestry = new AncestryTraversal(); - graph.traverse( ancestry ); - - final List ancestorRefs = ancestry.getAncestry(); - - assertThat( ancestorRefs.size(), equalTo( 3 ) ); - - int idx = 0; - ProjectVersionRef ref = ancestorRefs.get( idx++ ); - - assertThat( ref.getGroupId(), equalTo( "my.group" ) ); - assertThat( ref.getArtifactId(), equalTo( "my-artifact" ) ); - - ref = ancestorRefs.get( idx++ ); - - assertThat( ref.getGroupId(), equalTo( "my.group" ) ); - assertThat( ref.getArtifactId(), equalTo( "my-dad" ) ); - - ref = ancestorRefs.get( idx++ ); - - assertThat( ref.getGroupId(), equalTo( "other.group" ) ); - assertThat( ref.getArtifactId(), equalTo( "grandpa" ) ); - - } - - @Test - public void traverseTwoAncestors_IgnoreNonParentRelationships() - throws Exception - { - final ProjectVersionRef myRef = new SimpleProjectVersionRef( "my.group", "my-artifact", "1.0" ); - final ProjectVersionRef parentRef = new SimpleProjectVersionRef( "my.group", "my-dad", "1" ); - final ProjectVersionRef grandRef = new SimpleProjectVersionRef( "other.group", "grandpa", "20120821" ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( myRef ); - - /* @formatter:off */ - graph.storeRelationships( new ParentRelationship( source, myRef, parentRef ), - new DependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "foo", "1.0" ), null, null, false ), null, 0, false ), - new DependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "bar", "1.2.1" ), null, null, false ), null, 1, false ), - new PluginRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.5.1" ), 0, false ), - new PluginRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins","maven-jar-plugin", "2.2" ), 1, false ), - new ExtensionRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.5.1" ), 0 ), - new ParentRelationship( source, parentRef, grandRef ), - new DependencyRelationship( source, parentRef, new SimpleProjectVersionRef( "other.group", "utils", "3-1" ).asJarArtifact(), null, 0, false ) - ); - /* @formatter:on */ - - final AncestryTraversal ancestry = new AncestryTraversal(); - graph.traverse( ancestry ); - - final List ancestorRefs = ancestry.getAncestry(); - - assertThat( ancestorRefs.size(), equalTo( 3 ) ); - - int idx = 0; - ProjectVersionRef ref = ancestorRefs.get( idx++ ); - - assertThat( ref.getGroupId(), equalTo( "my.group" ) ); - assertThat( ref.getArtifactId(), equalTo( "my-artifact" ) ); - - ref = ancestorRefs.get( idx++ ); - - assertThat( ref.getGroupId(), equalTo( "my.group" ) ); - assertThat( ref.getArtifactId(), equalTo( "my-dad" ) ); - - ref = ancestorRefs.get( idx++ ); - - assertThat( ref.getGroupId(), equalTo( "other.group" ) ); - assertThat( ref.getArtifactId(), equalTo( "grandpa" ) ); - - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java deleted file mode 100644 index e65b2f04..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/BuildOrderTraversalTCK.java +++ /dev/null @@ -1,330 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.traverse; - -import static org.apache.commons.lang.StringUtils.join; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.filter.DependencyFilter; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.graph.traverse.BuildOrderTraversal; -import org.commonjava.maven.atlas.graph.traverse.model.BuildOrder; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Test; -import org.slf4j.LoggerFactory; - -public abstract class BuildOrderTraversalTCK - extends AbstractSPI_TCK -{ - - @Test - public void simpleDependencyBuildOrder() - throws Exception - { - final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); - final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); - final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); - - final Map relativeOrder = - new HashMap(); - relativeOrder.put( c, b ); - relativeOrder.put( b, a ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( c ); - - /* @formatter:off */ - graph.storeRelationships( new DependencyRelationship( source, c, new SimpleArtifactRef( b, null, null, false ), null, 0, false ), - new DependencyRelationship( source, b, new SimpleArtifactRef( a, null, null, false ), null, 0, false ) ); - /* @formatter:on */ - - assertThat( graph.getAllRelationships() - .size(), equalTo( 2 ) ); - - logger.info( "Starting build-order traversal" ); - final BuildOrderTraversal bo = new BuildOrderTraversal( new DependencyFilter( DependencyScope.test ) ); - graph.traverse( bo ); - - final BuildOrder buildOrderObj = bo.getBuildOrder(); - final List buildOrder = buildOrderObj.getOrder(); - - assertRelativeOrder( relativeOrder, buildOrder ); - } - - @Test - //@Ignore - public void simpleDependencyBuildOrder_includeDepParent() - throws Exception - - { - final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); - final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); - final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); - final ProjectVersionRef p = new SimpleProjectVersionRef( "group.id", "b-parent", "1001" ); - - final Map relativeOrder = - new HashMap(); - relativeOrder.put( c, b ); - relativeOrder.put( b, a ); - relativeOrder.put( b, p ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( c ); - - /* @formatter:off */ - graph.storeRelationships( new ParentRelationship( source, c ), - new ParentRelationship( source, b, p ), - new DependencyRelationship( source, c, b.asJarArtifact(), null, 0, false ), - new DependencyRelationship( source, b, a.asJarArtifact(), null, 0, false ) - ); - /* @formatter:on */ - - assertThat( graph.getAllRelationships() - .size(), equalTo( 3 ) ); - - final BuildOrderTraversal bo = new BuildOrderTraversal( new DependencyFilter( DependencyScope.test ) ); - graph.traverse( bo ); - - final BuildOrder buildOrderObj = bo.getBuildOrder(); - final List buildOrder = buildOrderObj.getOrder(); - - LoggerFactory.getLogger( getClass() ) - .info( "Build order: {}", buildOrder ); - - assertThat( buildOrder.size(), equalTo( 4 ) ); - - assertRelativeOrder( relativeOrder, buildOrder ); - } - - @Test - //@Ignore - public void simpleDependencyBuildOrder_IgnorePluginPath() - throws Exception - { - final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); - final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); - final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); - final ProjectVersionRef pa = new SimpleProjectVersionRef( "plugin.id", "p-a", "1" ); - final ProjectVersionRef pb = new SimpleProjectVersionRef( "plugin.id", "p-b", "2" ); - - final Map relativeOrder = - new HashMap(); - relativeOrder.put( c, b ); - relativeOrder.put( b, a ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( c ); - - /* @formatter:off */ - graph.storeRelationships( new ParentRelationship( source, c ), - new DependencyRelationship( source, c, b.asJarArtifact(), null, 0, false ), - new PluginRelationship( source, c, pb, 0, false ), - new DependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false ), - new DependencyRelationship( source, b, a.asJarArtifact(), null, 0, false ) - ); - /* @formatter:on */ - - assertThat( graph.getAllRelationships() - .size(), equalTo( 4 ) ); - - final BuildOrderTraversal bo = new BuildOrderTraversal( new DependencyFilter( DependencyScope.test ) ); - graph.traverse( bo ); - - final BuildOrder buildOrderObj = bo.getBuildOrder(); - final List buildOrder = buildOrderObj.getOrder(); - - assertRelativeOrder( relativeOrder, buildOrder ); - } - - @Test - //@Ignore - public void simpleDependencyBuildOrder_runtimeDepsOnly() - throws Exception - { - final ProjectVersionRef e = new SimpleProjectVersionRef( "group.id", "e", "5" ); - final ProjectVersionRef d = new SimpleProjectVersionRef( "group.id", "d", "4" ); - final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); - final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); - final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); - final ProjectVersionRef pa = new SimpleProjectVersionRef( "plugin.id", "p-a", "1" ); - final ProjectVersionRef pb = new SimpleProjectVersionRef( "plugin.id", "p-b", "2" ); - - final Map relativeOrder = - new HashMap(); - relativeOrder.put( c, b ); - relativeOrder.put( b, a ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( c ); - - /* @formatter:off */ - graph.storeRelationships( new ParentRelationship( source, c ), - new DependencyRelationship( source, c, b.asJarArtifact(), null, 0, false ), - new DependencyRelationship( source, c, d.asJarArtifact(), DependencyScope.test, 1, false ), - new PluginRelationship( source, c, pb, 0, false ), - new DependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false ), - new DependencyRelationship( source, d, e.asJarArtifact(), DependencyScope.runtime, 0, false ), - new DependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false ) - ); - /* @formatter:on */ - - assertThat( graph.getAllRelationships() - .size(), equalTo( 6 ) ); - - final BuildOrderTraversal bo = new BuildOrderTraversal( new DependencyFilter( DependencyScope.runtime ) ); - graph.traverse( bo ); - - final BuildOrder buildOrderObj = bo.getBuildOrder(); - final List buildOrder = buildOrderObj.getOrder(); - - assertThat( buildOrder.size(), equalTo( 3 ) ); - - assertRelativeOrder( relativeOrder, buildOrder ); - } - - @Test - //@Ignore - public void simpleDependencyBuildOrder_ignoreExcluded() - throws Exception - { - final ProjectVersionRef d = new SimpleProjectVersionRef( "group.id", "d", "4" ); - final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); - final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); - final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); - - final Map relativeOrder = - new HashMap(); - relativeOrder.put( c, b ); - relativeOrder.put( b, a ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( c ); - - /* @formatter:off */ - graph.storeRelationships( new ParentRelationship( source, c ), - new DependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, d ), - new DependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false ), - new DependencyRelationship( source, b, d.asJarArtifact(), DependencyScope.runtime, 1, false ) - ); - /* @formatter:on */ - - assertThat( graph.getAllRelationships() - .size(), equalTo( 3 ) ); - - final BuildOrderTraversal bo = new BuildOrderTraversal( new DependencyFilter( DependencyScope.runtime ) ); - graph.traverse( bo ); - - final BuildOrder buildOrderObj = bo.getBuildOrder(); - final List buildOrder = buildOrderObj.getOrder(); - - logger.info( "Build order: {}", buildOrder ); - assertThat( buildOrder.size(), equalTo( 3 ) ); - - assertRelativeOrder( relativeOrder, buildOrder ); - } - - @Test - //@Ignore - public void simpleEverythingBuildOrder() - throws Exception - { - final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); - final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); - final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); - final ProjectVersionRef pa = new SimpleProjectVersionRef( "plugin.dep.id", "p-a", "1" ); - final ProjectVersionRef pb = new SimpleProjectVersionRef( "plugin.id", "p-b", "2" ); - - final Map relativeOrder = - new HashMap(); - relativeOrder.put( c, b ); - relativeOrder.put( b, a ); - relativeOrder.put( c, pb ); - relativeOrder.put( pb, pa ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( c ); - - /* @formatter:off */ - graph.storeRelationships( new ParentRelationship( source, c ), - new DependencyRelationship( source, c, b.asJarArtifact(), null, 0, false ), - new PluginRelationship( source, c, pb, 0, false ), - new DependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false ), - new DependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false ) - ); - /* @formatter:on */ - - System.out.println( "Got relationships:\n\n " + join( graph.getAllRelationships(), "\n " ) ); - assertThat( graph.getAllRelationships() - .size(), equalTo( 4 ) ); - - final BuildOrderTraversal bo = new BuildOrderTraversal(); - graph.traverse( bo ); - - final BuildOrder buildOrderObj = bo.getBuildOrder(); - final List buildOrder = buildOrderObj.getOrder(); - - System.out.printf( "Build order: %s\n", buildOrder ); - - assertRelativeOrder( relativeOrder, buildOrder ); - } - - private void assertRelativeOrder( final Map relativeOrder, - final List buildOrder ) - { - for ( final Map.Entry entry : relativeOrder.entrySet() ) - { - final ProjectRef k = entry.getKey() - .asProjectRef(); - final ProjectRef v = entry.getValue() - .asProjectRef(); - - final int kidx = buildOrder.indexOf( k ); - final int vidx = buildOrder.indexOf( v ); - - if ( kidx < 0 ) - { - fail( "Cannot find: " + k + " in build order: " + buildOrder ); - } - - if ( vidx < 0 ) - { - fail( "Cannot find: " + v + " in build order: " + buildOrder ); - } - - if ( vidx >= kidx ) - { - fail( "prerequisite project: " + v + " of: " + k + " appears AFTER it in the build order: " - + buildOrder ); - } - } - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/TransitiveDependencyTraversalTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/TransitiveDependencyTraversalTCK.java deleted file mode 100644 index ebbaed59..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/TransitiveDependencyTraversalTCK.java +++ /dev/null @@ -1,192 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.traverse; - -import static org.commonjava.maven.atlas.ident.DependencyScope.compile; -import static org.commonjava.maven.atlas.ident.util.IdentityUtils.projectVersion; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -import java.net.URI; -import java.util.List; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; -import org.commonjava.maven.atlas.graph.traverse.TransitiveDependencyTraversal; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Test; - -public abstract class TransitiveDependencyTraversalTCK - extends AbstractSPI_TCK -{ - - @Test - public void collectDependencyOfDependency() - throws Exception - { - final URI source = sourceURI(); - final ProjectVersionRef root = projectVersion( "group.id", "my-project", "1.0" ); - final ProjectVersionRef d1 = projectVersion( "other.group", "dep-L1", "1.0.1" ); - final ProjectVersionRef d2 = projectVersion( "foo", "dep-L2", "1.1.1" ); - - final RelationshipGraph graph = simpleGraph( root ); - - /* @formatter:off */ - graph.storeRelationships( new ParentRelationship( source, root ), - new DependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false ), - new DependencyRelationship( source, d1, d2.asJarArtifact(), compile, 0, false ) - ); - /* @formatter:on */ - - final TransitiveDependencyTraversal depTraversal = new TransitiveDependencyTraversal(); - graph.traverse( depTraversal ); - - final List artifacts = depTraversal.getArtifacts(); - - assertThat( artifacts.size(), equalTo( 2 ) ); - - int idx = 0; - - ArtifactRef ref = artifacts.get( idx++ ); - assertThat( ref.getArtifactId(), equalTo( "dep-L1" ) ); - - ref = artifacts.get( idx++ ); - assertThat( ref.getArtifactId(), equalTo( "dep-L2" ) ); - } - - @Test - public void collectDependencyOfDependencyWithExternalDepManagement() - throws Exception - { - final URI source = sourceURI(); - final ProjectVersionRef root = projectVersion( "group.id", "my-project", "1.0" ); - final ProjectVersionRef d1 = projectVersion( "other.group", "dep-L1", "1.0.1" ); - final ProjectVersionRef d2 = projectVersion( "foo", "dep-L2", "1.1.1" ); - final ProjectVersionRef d3 = projectVersion( "foo", "dep-L2", "1.1.2" ); - - RelationshipGraph graph = simpleGraph( root ); - - /* @formatter:off */ - graph.storeRelationships( new ParentRelationship( source, root ), - new DependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false ), - new DependencyRelationship( source, d1, d2.asJarArtifact(), compile, 0, false ) - ); - /* @formatter:on */ - - graph = graphFactory().open( new ViewParams.Builder( graph.getParams() ).withSelection( d2.asProjectRef(), d3 ) - .build(), false ); - - // graph.getView() - // .selectVersion( d2.asProjectRef(), d3 ); - - final TransitiveDependencyTraversal depTraversal = new TransitiveDependencyTraversal(); - graph.traverse( depTraversal ); - - final List artifacts = depTraversal.getArtifacts(); - - assertThat( artifacts.size(), equalTo( 2 ) ); - - int idx = 0; - - ArtifactRef ref = artifacts.get( idx++ ); - assertThat( ref.getArtifactId(), equalTo( "dep-L1" ) ); - - ref = artifacts.get( idx++ ); - assertThat( ref.getArtifactId(), equalTo( "dep-L2" ) ); - assertThat( ref.getVersionString(), equalTo( d3.getVersionString() ) ); - } - - @Test - public void preferDirectDependency() - throws Exception - { - final URI source = sourceURI(); - - final ProjectVersionRef root = projectVersion( "group.id", "my-project", "1.0" ); - final ProjectVersionRef d1 = projectVersion( "other.group", "dep-L1", "1.0.1" ); - final ProjectVersionRef d2a = projectVersion( "foo", "dep-L2", "1.1.1" ); - final ProjectVersionRef d2b = projectVersion( "foo", "dep-L2", "1.0" ); - - final RelationshipGraph graph = simpleGraph( root ); - - /* @formatter:off */ - graph.storeRelationships( new ParentRelationship( source, root ), - new DependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false ), - new DependencyRelationship( source, root, d2a.asJarArtifact(), compile, 1, false ), - new DependencyRelationship( source, d1, d2b.asJarArtifact(), compile, 0, false ) - ); - /* @formatter:on */ - - final TransitiveDependencyTraversal depTraversal = new TransitiveDependencyTraversal(); - graph.traverse( depTraversal ); - - final List artifacts = depTraversal.getArtifacts(); - - assertThat( artifacts.size(), equalTo( 2 ) ); - - int idx = 0; - - ArtifactRef ref = artifacts.get( idx++ ); - assertThat( ref.getArtifactId(), equalTo( "dep-L1" ) ); - - ref = artifacts.get( idx++ ); - assertThat( ref.getArtifactId(), equalTo( "dep-L2" ) ); - assertThat( ref.getVersionSpec() - .renderStandard(), equalTo( "1.1.1" ) ); - } - - @Test - public void preferLocalDirectDepOverDirectDepInParent() - throws Exception - { - final URI source = sourceURI(); - - final ProjectVersionRef root = projectVersion( "group.id", "my-project", "1.0" ); - final ProjectVersionRef parent = projectVersion( "group.id", "parent", "1" ); - final ProjectVersionRef d1a = projectVersion( "other.group", "dep-L1", "1.1.1" ); - final ProjectVersionRef d1b = projectVersion( "other.group", "dep-L1", "1.0" ); - - final RelationshipGraph graph = simpleGraph( root ); - - /* @formatter:off */ - graph.storeRelationships( new ParentRelationship( source, root, parent ), - new DependencyRelationship( source, root, d1a.asJarArtifact(), compile, 0, false ), - new DependencyRelationship( source, parent, d1b.asJarArtifact(), compile, 0, false ) - ); - /* @formatter:on */ - - final TransitiveDependencyTraversal depTraversal = new TransitiveDependencyTraversal(); - graph.traverse( depTraversal ); - - final List artifacts = depTraversal.getArtifacts(); - - assertThat( artifacts.size(), equalTo( 1 ) ); - - int idx = 0; - - final ArtifactRef ref = artifacts.get( idx++ ); - assertThat( ref.getArtifactId(), equalTo( "dep-L1" ) ); - - assertThat( ref.getVersionSpec() - .renderStandard(), equalTo( "1.1.1" ) ); - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_EmptyGrandparentRels_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_EmptyGrandparentRels_TCK.java new file mode 100644 index 00000000..d76918e8 --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_EmptyGrandparentRels_TCK.java @@ -0,0 +1,80 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.traverse.ancestry; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleExtensionRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; +import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; +import org.commonjava.maven.atlas.graph.traverse.AncestryTraversal; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Ignore; +import org.junit.Test; + +import java.net.URI; +import java.util.List; +import java.util.Set; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +public class AncestryTraversal_EmptyGrandparentRels_TCK + extends AbstractSPI_TCK +{ + + @Test + public void run() + throws Exception + { + final ProjectVersionRef myRef = new SimpleProjectVersionRef( "my.group", "my-artifact", "1.0" ); + final ProjectVersionRef parentRef = new SimpleProjectVersionRef( "my.group", "my-dad", "1" ); + final ProjectVersionRef grandRef = new SimpleProjectVersionRef( "other.group", "grandpa", "20120821" ); + + final URI source = sourceURI(); + final RelationshipGraph graph = simpleGraph( myRef ); + + graph.storeRelationships( new SimpleParentRelationship( source, myRef, parentRef ), + new SimpleParentRelationship( source, parentRef, grandRef ) ); + + final AncestryTraversal ancestry = new AncestryTraversal(); + graph.traverse( ancestry ); + + final List ancestorRefs = ancestry.getAncestry(); + + assertThat( ancestorRefs.size(), equalTo( 3 ) ); + + int idx = 0; + ProjectVersionRef ref = ancestorRefs.get( idx++ ); + + assertThat( ref.getGroupId(), equalTo( "my.group" ) ); + assertThat( ref.getArtifactId(), equalTo( "my-artifact" ) ); + + ref = ancestorRefs.get( idx++ ); + + assertThat( ref.getGroupId(), equalTo( "my.group" ) ); + assertThat( ref.getArtifactId(), equalTo( "my-dad" ) ); + + ref = ancestorRefs.get( idx++ ); + + assertThat( ref.getGroupId(), equalTo( "other.group" ) ); + assertThat( ref.getArtifactId(), equalTo( "grandpa" ) ); + + } +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java new file mode 100644 index 00000000..5ca224ea --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java @@ -0,0 +1,87 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.traverse.ancestry; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.net.URI; +import java.util.List; +import java.util.Set; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.rel.*; +import org.commonjava.maven.atlas.graph.traverse.AncestryTraversal; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Ignore; +import org.junit.Test; + +public class AncestryTraversal_IgnoreNonParentRels_TCK + extends AbstractSPI_TCK +{ + + @Test + public void run() + throws Exception + { + final ProjectVersionRef myRef = new SimpleProjectVersionRef( "my.group", "my-artifact", "1.0" ); + final ProjectVersionRef parentRef = new SimpleProjectVersionRef( "my.group", "my-dad", "1" ); + final ProjectVersionRef grandRef = new SimpleProjectVersionRef( "other.group", "grandpa", "20120821" ); + + final URI source = sourceURI(); + final RelationshipGraph graph = simpleGraph( myRef ); + + /* @formatter:off */ + graph.storeRelationships( new SimpleParentRelationship( source, myRef, parentRef ), + new SimpleDependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "foo", "1.0" ), null, null, false ), null, 0, false ), + new SimpleDependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "bar", "1.2.1" ), null, null, false ), null, 1, false ), + new SimplePluginRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.5.1" ), 0, false ), + new SimplePluginRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins","maven-jar-plugin", "2.2" ), 1, false ), + new SimpleExtensionRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.5.1" ), 0 ), + new SimpleParentRelationship( source, parentRef, grandRef ), + new SimpleDependencyRelationship( source, parentRef, new SimpleProjectVersionRef( "other.group", "utils", "3-1" ).asJarArtifact(), null, 0, false ) + ); + /* @formatter:on */ + + final AncestryTraversal ancestry = new AncestryTraversal(); + graph.traverse( ancestry ); + + final List ancestorRefs = ancestry.getAncestry(); + + assertThat( ancestorRefs.size(), equalTo( 3 ) ); + + int idx = 0; + ProjectVersionRef ref = ancestorRefs.get( idx++ ); + + assertThat( ref.getGroupId(), equalTo( "my.group" ) ); + assertThat( ref.getArtifactId(), equalTo( "my-artifact" ) ); + + ref = ancestorRefs.get( idx++ ); + + assertThat( ref.getGroupId(), equalTo( "my.group" ) ); + assertThat( ref.getArtifactId(), equalTo( "my-dad" ) ); + + ref = ancestorRefs.get( idx++ ); + + assertThat( ref.getGroupId(), equalTo( "other.group" ) ); + assertThat( ref.getArtifactId(), equalTo( "grandpa" ) ); + + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_TwoAncestors_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_TwoAncestors_TCK.java new file mode 100644 index 00000000..2ea347d5 --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_TwoAncestors_TCK.java @@ -0,0 +1,90 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.traverse.ancestry; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleExtensionRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; +import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; +import org.commonjava.maven.atlas.graph.traverse.AncestryTraversal; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Ignore; +import org.junit.Test; + +import java.net.URI; +import java.util.List; +import java.util.Set; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +public class AncestryTraversal_TwoAncestors_TCK + extends AbstractSPI_TCK +{ + + @Test + public void run() + throws Exception + { + final ProjectVersionRef myRef = new SimpleProjectVersionRef( "my.group", "my-artifact", "1.0" ); + final ProjectVersionRef parentRef = new SimpleProjectVersionRef( "my.group", "my-dad", "1" ); + final ProjectVersionRef grandRef = new SimpleProjectVersionRef( "other.group", "grandpa", "20120821" ); + + final URI source = sourceURI(); + final RelationshipGraph graph = simpleGraph( myRef ); + + graph.storeRelationships( new SimpleParentRelationship( source, myRef, parentRef ), + new SimpleParentRelationship( source, parentRef, grandRef ), + new SimpleParentRelationship( grandRef ) ); + + final Set projects = graph.getAllProjects(); + assertThat( projects.size(), equalTo( 3 ) ); + assertThat( projects.contains( myRef ), equalTo( true ) ); + assertThat( projects.contains( parentRef ), equalTo( true ) ); + assertThat( projects.contains( grandRef ), equalTo( true ) ); + + final AncestryTraversal ancestry = new AncestryTraversal(); + graph.traverse( ancestry ); + + final List ancestorRefs = ancestry.getAncestry(); + + logger.info( "Ancestry: {}", ancestorRefs ); + + assertThat( ancestorRefs.size(), equalTo( 3 ) ); + + int idx = 0; + ProjectVersionRef ref = ancestorRefs.get( idx++ ); + + assertThat( ref.getGroupId(), equalTo( "my.group" ) ); + assertThat( ref.getArtifactId(), equalTo( "my-artifact" ) ); + + ref = ancestorRefs.get( idx++ ); + + assertThat( ref.getGroupId(), equalTo( "my.group" ) ); + assertThat( ref.getArtifactId(), equalTo( "my-dad" ) ); + + ref = ancestorRefs.get( idx++ ); + + assertThat( ref.getGroupId(), equalTo( "other.group" ) ); + assertThat( ref.getArtifactId(), equalTo( "grandpa" ) ); + + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/AbstractBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/AbstractBuildOrderTCK.java new file mode 100644 index 00000000..683fea4f --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/AbstractBuildOrderTCK.java @@ -0,0 +1,79 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; + +import static org.apache.commons.lang.StringUtils.join; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; + +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.filter.DependencyFilter; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; +import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; +import org.commonjava.maven.atlas.graph.traverse.BuildOrderTraversal; +import org.commonjava.maven.atlas.graph.traverse.model.BuildOrder; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Test; +import org.slf4j.LoggerFactory; + +public class AbstractBuildOrderTCK + extends AbstractSPI_TCK +{ + + protected void assertRelativeOrder( final Map relativeOrder, + final List buildOrder ) + { + for ( final Map.Entry entry : relativeOrder.entrySet() ) + { + final ProjectRef k = entry.getKey() + .asProjectRef(); + final ProjectRef v = entry.getValue() + .asProjectRef(); + + final int kidx = buildOrder.indexOf( k ); + final int vidx = buildOrder.indexOf( v ); + + if ( kidx < 0 ) + { + fail( "Cannot find: " + k + " in build order: " + buildOrder ); + } + + if ( vidx < 0 ) + { + fail( "Cannot find: " + v + " in build order: " + buildOrder ); + } + + if ( vidx >= kidx ) + { + fail( "prerequisite project: " + v + " of: " + k + " appears AFTER it in the build order: " + + buildOrder ); + } + } + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java new file mode 100644 index 00000000..774101ab --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java @@ -0,0 +1,71 @@ +package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.filter.DependencyFilter; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; +import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; +import org.commonjava.maven.atlas.graph.traverse.BuildOrderTraversal; +import org.commonjava.maven.atlas.graph.traverse.model.BuildOrder; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.junit.Ignore; +import org.junit.Test; + +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +/** + * Created by jdcasey on 8/24/15. + */ +public class DependencyBuildOrderIgnoringPluginPathTCK + extends AbstractBuildOrderTCK +{ + + @Test + public void run() + throws Exception + { + final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); + final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); + final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); + final ProjectVersionRef pa = new SimpleProjectVersionRef( "plugin.id", "p-a", "1" ); + final ProjectVersionRef pb = new SimpleProjectVersionRef( "plugin.id", "p-b", "2" ); + + final Map relativeOrder = + new HashMap(); + relativeOrder.put( c, b ); + relativeOrder.put( b, a ); + + final URI source = sourceURI(); + final RelationshipGraph graph = simpleGraph( c ); + + /* @formatter:off */ + graph.storeRelationships( new SimpleParentRelationship( source, c ), + new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false ), + new SimplePluginRelationship( source, c, pb, 0, false ), + new SimpleDependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false ), + new SimpleDependencyRelationship( source, b, a.asJarArtifact(), null, 0, false ) + ); + /* @formatter:on */ + + assertThat( graph.getAllRelationships() + .size(), equalTo( 4 ) ); + + final BuildOrderTraversal bo = new BuildOrderTraversal( new DependencyFilter( DependencyScope.test ) ); + graph.traverse( bo ); + + final BuildOrder buildOrderObj = bo.getBuildOrder(); + final List buildOrder = buildOrderObj.getOrder(); + + assertRelativeOrder( relativeOrder, buildOrder ); + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java new file mode 100644 index 00000000..946f970d --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java @@ -0,0 +1,70 @@ +package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.filter.DependencyFilter; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; +import org.commonjava.maven.atlas.graph.traverse.BuildOrderTraversal; +import org.commonjava.maven.atlas.graph.traverse.model.BuildOrder; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.junit.Ignore; +import org.junit.Test; + +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +/** + * Created by jdcasey on 8/24/15. + */ +public class DependencyExcludesBuildOrderTCK + extends AbstractBuildOrderTCK +{ + @Test + public void run() + throws Exception + { + final ProjectVersionRef d = new SimpleProjectVersionRef( "group.id", "d", "4" ); + final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); + final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); + final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); + + final Map relativeOrder = + new HashMap(); + relativeOrder.put( c, b ); + relativeOrder.put( b, a ); + + final URI source = sourceURI(); + final RelationshipGraph graph = simpleGraph( c ); + + /* @formatter:off */ + graph.storeRelationships( new SimpleParentRelationship( c ), + new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, d ), + new SimpleDependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false ), + new SimpleDependencyRelationship( source, b, d.asJarArtifact(), DependencyScope.runtime, 1, false ) + ); + /* @formatter:on */ + + assertThat( graph.getAllRelationships() + .size(), equalTo( 3 ) ); + + final BuildOrderTraversal bo = new BuildOrderTraversal( new DependencyFilter( DependencyScope.runtime ) ); + graph.traverse( bo ); + + final BuildOrder buildOrderObj = bo.getBuildOrder(); + final List buildOrder = buildOrderObj.getOrder(); + + logger.info( "Build order: {}", buildOrder ); + assertThat( buildOrder.size(), equalTo( 3 ) ); + + assertRelativeOrder( relativeOrder, buildOrder ); + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java new file mode 100644 index 00000000..0c80a12c --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java @@ -0,0 +1,75 @@ +package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.filter.DependencyFilter; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; +import org.commonjava.maven.atlas.graph.traverse.BuildOrderTraversal; +import org.commonjava.maven.atlas.graph.traverse.model.BuildOrder; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.junit.Ignore; +import org.junit.Test; +import org.slf4j.LoggerFactory; + +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +/** + * Created by jdcasey on 8/24/15. + */ +public class ParentDependencyBuildOrderTCK + extends AbstractBuildOrderTCK +{ + @Test + public void run() + throws Exception + + { + final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); + final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); + final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); + final ProjectVersionRef p = new SimpleProjectVersionRef( "group.id", "b-parent", "1001" ); + + final Map relativeOrder = + new HashMap(); + relativeOrder.put( c, b ); + relativeOrder.put( b, a ); + relativeOrder.put( b, p ); + + final URI source = sourceURI(); + final RelationshipGraph graph = simpleGraph( c ); + + /* @formatter:off */ + graph.storeRelationships( new SimpleParentRelationship( source, c ), + new SimpleParentRelationship( source, b, p ), + new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false ), + new SimpleDependencyRelationship( source, b, a.asJarArtifact(), null, 0, false ) + ); + /* @formatter:on */ + + assertThat( graph.getAllRelationships() + .size(), equalTo( 3 ) ); + + final BuildOrderTraversal bo = new BuildOrderTraversal( new DependencyFilter( DependencyScope.test ) ); + graph.traverse( bo ); + + final BuildOrder buildOrderObj = bo.getBuildOrder(); + final List buildOrder = buildOrderObj.getOrder(); + + LoggerFactory.getLogger( getClass() ) + .info( "Build order: {}", buildOrder ); + + assertThat( buildOrder.size(), equalTo( 4 ) ); + + assertRelativeOrder( relativeOrder, buildOrder ); + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java new file mode 100644 index 00000000..9c5fef0b --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java @@ -0,0 +1,77 @@ +package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.filter.DependencyFilter; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; +import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; +import org.commonjava.maven.atlas.graph.traverse.BuildOrderTraversal; +import org.commonjava.maven.atlas.graph.traverse.model.BuildOrder; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.junit.Ignore; +import org.junit.Test; + +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +/** + * Created by jdcasey on 8/24/15. + */ +public class RuntimeDependencyBuildOrderTCK + extends AbstractBuildOrderTCK +{ + + @Test + public void run() + throws Exception + { + final ProjectVersionRef e = new SimpleProjectVersionRef( "group.id", "e", "5" ); + final ProjectVersionRef d = new SimpleProjectVersionRef( "group.id", "d", "4" ); + final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); + final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); + final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); + final ProjectVersionRef pa = new SimpleProjectVersionRef( "plugin.id", "p-a", "1" ); + final ProjectVersionRef pb = new SimpleProjectVersionRef( "plugin.id", "p-b", "2" ); + + final Map relativeOrder = + new HashMap(); + relativeOrder.put( c, b ); + relativeOrder.put( b, a ); + + final URI source = sourceURI(); + final RelationshipGraph graph = simpleGraph( c ); + + /* @formatter:off */ + graph.storeRelationships( new SimpleParentRelationship( source, c ), + new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false ), + new SimpleDependencyRelationship( source, c, d.asJarArtifact(), DependencyScope.test, 1, false ), + new SimplePluginRelationship( source, c, pb, 0, false ), + new SimpleDependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false ), + new SimpleDependencyRelationship( source, d, e.asJarArtifact(), DependencyScope.runtime, 0, false ), + new SimpleDependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false ) + ); + /* @formatter:on */ + + assertThat( graph.getAllRelationships() + .size(), equalTo( 6 ) ); + + final BuildOrderTraversal bo = new BuildOrderTraversal( new DependencyFilter( DependencyScope.runtime ) ); + graph.traverse( bo ); + + final BuildOrder buildOrderObj = bo.getBuildOrder(); + final List buildOrder = buildOrderObj.getOrder(); + + assertThat( buildOrder.size(), equalTo( 3 ) ); + + assertRelativeOrder( relativeOrder, buildOrder ); + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java new file mode 100644 index 00000000..bda01167 --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java @@ -0,0 +1,64 @@ +package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.filter.DependencyFilter; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.traverse.BuildOrderTraversal; +import org.commonjava.maven.atlas.graph.traverse.model.BuildOrder; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.junit.Ignore; +import org.junit.Test; + +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +/** + * Created by jdcasey on 8/24/15. + */ +public class SimpleDependencyBuildOrderTCK + extends AbstractBuildOrderTCK +{ + @Test + public void run() + throws Exception + { + final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); + final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); + final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); + + final Map relativeOrder = + new HashMap(); + relativeOrder.put( c, b ); + relativeOrder.put( b, a ); + + final URI source = sourceURI(); + final RelationshipGraph graph = simpleGraph( c ); + + /* @formatter:off */ + graph.storeRelationships( new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( b, null, null, false ), null, 0, false ), + new SimpleDependencyRelationship( source, b, new SimpleArtifactRef( a, null, null, false ), null, 0, false ) ); + /* @formatter:on */ + + assertThat( graph.getAllRelationships() + .size(), equalTo( 2 ) ); + + logger.info( "Starting build-order traversal" ); + final BuildOrderTraversal bo = new BuildOrderTraversal( new DependencyFilter( DependencyScope.test ) ); + graph.traverse( bo ); + + final BuildOrder buildOrderObj = bo.getBuildOrder(); + final List buildOrder = buildOrderObj.getOrder(); + + assertRelativeOrder( relativeOrder, buildOrder ); + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java new file mode 100644 index 00000000..0b95a60a --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java @@ -0,0 +1,76 @@ +package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; +import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; +import org.commonjava.maven.atlas.graph.traverse.BuildOrderTraversal; +import org.commonjava.maven.atlas.graph.traverse.model.BuildOrder; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.junit.Ignore; +import org.junit.Test; + +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.apache.commons.lang.StringUtils.join; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +/** + * Created by jdcasey on 8/24/15. + */ +public class SimpleEverythingBuildOrderTCK + extends AbstractBuildOrderTCK +{ + + @Test + public void run() + throws Exception + { + final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); + final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); + final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); + final ProjectVersionRef pa = new SimpleProjectVersionRef( "plugin.dep.id", "p-a", "1" ); + final ProjectVersionRef pb = new SimpleProjectVersionRef( "plugin.id", "p-b", "2" ); + + final Map relativeOrder = + new HashMap(); + relativeOrder.put( c, b ); + relativeOrder.put( b, a ); + relativeOrder.put( c, pb ); + relativeOrder.put( pb, pa ); + + final URI source = sourceURI(); + final RelationshipGraph graph = simpleGraph( c ); + + /* @formatter:off */ + graph.storeRelationships( new SimpleParentRelationship( source, c ), + new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false ), + new SimplePluginRelationship( source, c, pb, 0, false ), + new SimpleDependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false ), + new SimpleDependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false ) + ); + /* @formatter:on */ + + System.out.println( "Got relationships:\n\n " + join( graph.getAllRelationships(), "\n " ) ); + assertThat( graph.getAllRelationships() + .size(), equalTo( 4 ) ); + + final BuildOrderTraversal bo = new BuildOrderTraversal(); + graph.traverse( bo ); + + final BuildOrder buildOrderObj = bo.getBuildOrder(); + final List buildOrder = buildOrderObj.getOrder(); + + System.out.printf( "Build order: %s\n", buildOrder ); + + assertRelativeOrder( relativeOrder, buildOrder ); + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDepTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDepTCK.java new file mode 100644 index 00000000..278035a3 --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDepTCK.java @@ -0,0 +1,75 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.traverse.transdep; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.ViewParams; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; +import org.commonjava.maven.atlas.graph.traverse.TransitiveDependencyTraversal; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Ignore; +import org.junit.Test; + +import java.net.URI; +import java.util.List; + +import static org.commonjava.maven.atlas.ident.DependencyScope.compile; +import static org.commonjava.maven.atlas.ident.util.IdentityUtils.projectVersion; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +public class TransitiveDependencyTraversal_DepOfDepTCK + extends AbstractSPI_TCK +{ + + @Test + public void run() + throws Exception + { + final URI source = sourceURI(); + final ProjectVersionRef root = projectVersion( "group.id", "my-project", "1.0" ); + final ProjectVersionRef d1 = projectVersion( "other.group", "dep-L1", "1.0.1" ); + final ProjectVersionRef d2 = projectVersion( "foo", "dep-L2", "1.1.1" ); + + final RelationshipGraph graph = simpleGraph( root ); + + /* @formatter:off */ + graph.storeRelationships( new SimpleParentRelationship( source, root ), + new SimpleDependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false ), + new SimpleDependencyRelationship( source, d1, d2.asJarArtifact(), compile, 0, false ) + ); + /* @formatter:on */ + + final TransitiveDependencyTraversal depTraversal = new TransitiveDependencyTraversal(); + graph.traverse( depTraversal ); + + final List artifacts = depTraversal.getArtifacts(); + + assertThat( artifacts.size(), equalTo( 2 ) ); + + int idx = 0; + + ArtifactRef ref = artifacts.get( idx++ ); + assertThat( ref.getArtifactId(), equalTo( "dep-L1" ) ); + + ref = artifacts.get( idx++ ); + assertThat( ref.getArtifactId(), equalTo( "dep-L2" ) ); + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDep_ExtMgmtTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDep_ExtMgmtTCK.java new file mode 100644 index 00000000..34d768b7 --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDep_ExtMgmtTCK.java @@ -0,0 +1,83 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.traverse.transdep; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.ViewParams; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; +import org.commonjava.maven.atlas.graph.traverse.TransitiveDependencyTraversal; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Ignore; +import org.junit.Test; + +import java.net.URI; +import java.util.List; + +import static org.commonjava.maven.atlas.ident.DependencyScope.compile; +import static org.commonjava.maven.atlas.ident.util.IdentityUtils.projectVersion; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +public class TransitiveDependencyTraversal_DepOfDep_ExtMgmtTCK + extends AbstractSPI_TCK +{ + + @Test + public void run() + throws Exception + { + final URI source = sourceURI(); + final ProjectVersionRef root = projectVersion( "group.id", "my-project", "1.0" ); + final ProjectVersionRef d1 = projectVersion( "other.group", "dep-L1", "1.0.1" ); + final ProjectVersionRef d2 = projectVersion( "foo", "dep-L2", "1.1.1" ); + final ProjectVersionRef d3 = projectVersion( "foo", "dep-L2", "1.1.2" ); + + RelationshipGraph graph = simpleGraph( root ); + + /* @formatter:off */ + graph.storeRelationships( new SimpleParentRelationship( source, root ), + new SimpleDependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false ), + new SimpleDependencyRelationship( source, d1, d2.asJarArtifact(), compile, 0, false ) + ); + /* @formatter:on */ + + graph = graphFactory().open( new ViewParams.Builder( graph.getParams() ).withSelection( d2.asProjectRef(), d3 ) + .build(), false ); + + // graph.getView() + // .selectVersion( d2.asProjectRef(), d3 ); + + final TransitiveDependencyTraversal depTraversal = new TransitiveDependencyTraversal(); + graph.traverse( depTraversal ); + + final List artifacts = depTraversal.getArtifacts(); + + assertThat( artifacts.size(), equalTo( 2 ) ); + + int idx = 0; + + ArtifactRef ref = artifacts.get( idx++ ); + assertThat( ref.getArtifactId(), equalTo( "dep-L1" ) ); + + ref = artifacts.get( idx++ ); + assertThat( ref.getArtifactId(), equalTo( "dep-L2" ) ); + assertThat( ref.getVersionString(), equalTo( d3.getVersionString() ) ); + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferDirectTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferDirectTCK.java new file mode 100644 index 00000000..c17525d0 --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferDirectTCK.java @@ -0,0 +1,79 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.traverse.transdep; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; +import org.commonjava.maven.atlas.graph.traverse.TransitiveDependencyTraversal; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Ignore; +import org.junit.Test; + +import java.net.URI; +import java.util.List; + +import static org.commonjava.maven.atlas.ident.DependencyScope.compile; +import static org.commonjava.maven.atlas.ident.util.IdentityUtils.projectVersion; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +public class TransitiveDependencyTraversal_PreferDirectTCK + extends AbstractSPI_TCK +{ + + @Test + public void run() + throws Exception + { + final URI source = sourceURI(); + + final ProjectVersionRef root = projectVersion( "group.id", "my-project", "1.0" ); + final ProjectVersionRef d1 = projectVersion( "other.group", "dep-L1", "1.0.1" ); + final ProjectVersionRef d2a = projectVersion( "foo", "dep-L2", "1.1.1" ); + final ProjectVersionRef d2b = projectVersion( "foo", "dep-L2", "1.0" ); + + final RelationshipGraph graph = simpleGraph( root ); + + /* @formatter:off */ + graph.storeRelationships( new SimpleParentRelationship( source, root ), + new SimpleDependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false ), + new SimpleDependencyRelationship( source, root, d2a.asJarArtifact(), compile, 1, false ), + new SimpleDependencyRelationship( source, d1, d2b.asJarArtifact(), compile, 0, false ) + ); + /* @formatter:on */ + + final TransitiveDependencyTraversal depTraversal = new TransitiveDependencyTraversal(); + graph.traverse( depTraversal ); + + final List artifacts = depTraversal.getArtifacts(); + + assertThat( artifacts.size(), equalTo( 2 ) ); + + int idx = 0; + + ArtifactRef ref = artifacts.get( idx++ ); + assertThat( ref.getArtifactId(), equalTo( "dep-L1" ) ); + + ref = artifacts.get( idx++ ); + assertThat( ref.getArtifactId(), equalTo( "dep-L2" ) ); + assertThat( ref.getVersionSpec() + .renderStandard(), equalTo( "1.1.1" ) ); + } + +} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferLocalTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferLocalTCK.java new file mode 100644 index 00000000..ce3e58df --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferLocalTCK.java @@ -0,0 +1,77 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.traverse.transdep; + +import static org.commonjava.maven.atlas.ident.DependencyScope.compile; +import static org.commonjava.maven.atlas.ident.util.IdentityUtils.projectVersion; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.net.URI; +import java.util.List; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.ViewParams; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; +import org.commonjava.maven.atlas.graph.traverse.TransitiveDependencyTraversal; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Ignore; +import org.junit.Test; + +public class TransitiveDependencyTraversal_PreferLocalTCK + extends AbstractSPI_TCK +{ + + @Test + public void run() + throws Exception + { + final URI source = sourceURI(); + + final ProjectVersionRef root = projectVersion( "group.id", "my-project", "1.0" ); + final ProjectVersionRef parent = projectVersion( "group.id", "parent", "1" ); + final ProjectVersionRef d1a = projectVersion( "other.group", "dep-L1", "1.1.1" ); + final ProjectVersionRef d1b = projectVersion( "other.group", "dep-L1", "1.0" ); + + final RelationshipGraph graph = simpleGraph( root ); + + /* @formatter:off */ + graph.storeRelationships( new SimpleParentRelationship( source, root, parent ), + new SimpleDependencyRelationship( source, root, d1a.asJarArtifact(), compile, 0, false ), + new SimpleDependencyRelationship( source, parent, d1b.asJarArtifact(), compile, 0, false ) + ); + /* @formatter:on */ + + final TransitiveDependencyTraversal depTraversal = new TransitiveDependencyTraversal(); + graph.traverse( depTraversal ); + + final List artifacts = depTraversal.getArtifacts(); + + assertThat( artifacts.size(), equalTo( 1 ) ); + + int idx = 0; + + final ArtifactRef ref = artifacts.get( idx++ ); + assertThat( ref.getArtifactId(), equalTo( "dep-L1" ) ); + + assertThat( ref.getVersionSpec() + .renderStandard(), equalTo( "1.1.1" ) ); + } + +} From 127fbfa76661cd35dbe81b365db42c9683f84778 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 25 Aug 2015 16:40:05 -0500 Subject: [PATCH 098/240] fixing preservation of dirty state in neo4j-specific identity classes when creating derivative instances. --- .../graph/spi/neo4j/model/NeoProjectRef.java | 17 ++++++++++------- .../spi/neo4j/model/NeoProjectVersionRef.java | 12 ++++++++++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java index 855d1776..d80228fb 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java @@ -38,10 +38,8 @@ public class NeoProjectRef private static final long serialVersionUID = 1L; - // NEVER null private String groupId; - // NEVER null private String artifactId; protected PropertyContainer container; @@ -54,7 +52,12 @@ public NeoProjectRef(ProjectRef ref) { if ( ref instanceof NeoProjectRef) { - container = ((NeoProjectRef)ref).container; + NeoProjectRef npr = (NeoProjectRef) ref; + container = npr.container; + this.groupId = npr.groupId; + this.artifactId = npr.artifactId; + this.groupIdProperty = npr.groupIdProperty; + this.artifactIdProperty = npr.artifactIdProperty; } else { @@ -65,14 +68,14 @@ public NeoProjectRef(ProjectRef ref) public NeoProjectRef( final String groupId, final String artifactId ) { - if ( isEmpty( groupId ) || isEmpty( artifactId ) ) + this.groupId = groupId; + this.artifactId = artifactId; + + if ( isEmpty( getGroupId() ) || isEmpty( getArtifactId() ) ) { throw new InvalidRefException( "ProjectId must contain non-empty groupId AND artifactId. (Given: '" + groupId + "':'" + artifactId + "')" ); } - - this.groupId = groupId; - this.artifactId = artifactId; } public NeoProjectRef( Node container ) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java index df49089a..9add7964 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java @@ -93,6 +93,11 @@ public NeoProjectVersionRef( ProjectVersionRef ref ) this.versionString = ref.getVersionStringRaw(); this.versionSpec = ref.getVersionSpecRaw(); } + else if ( ref instanceof NeoProjectVersionRef ) + { + this.versionString = ((NeoProjectVersionRef)ref).versionString; + this.versionSpec = ((NeoProjectVersionRef)ref).versionSpec; + } } public static ProjectVersionRef parse( final String gav ) @@ -109,11 +114,14 @@ public static ProjectVersionRef parse( final String gav ) } @Override - public NeoProjectVersionRef asProjectVersionRef() + public ProjectVersionRef asProjectVersionRef() { + Logger logger = LoggerFactory.getLogger( getClass() ); + logger.debug("Trying to create new ProjectVersionRef from: {}", getClass().getSimpleName()); + return NeoProjectVersionRef.class.equals( getClass() ) ? this : - new NeoProjectVersionRef( getGroupId(), getArtifactId(), getVersionSpecRaw(), getVersionStringRaw() ); + new NeoProjectVersionRef( this ); } @Override From 40d95c16ca27daf41ca514fced0ab723a1020434 Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 26 Aug 2015 18:40:24 -0500 Subject: [PATCH 099/240] Fixing tests and serialization to/from JSON. Adding serializers specific to neo4j identities/relationships. --- .../ident/jackson/ProjectRefDeserializer.java | 48 +++ .../jackson/ProjectRefKeyDeserializer.java | 46 +++ .../ident/jackson/ProjectRefSerializer.java | 53 +++ .../ProjectVersionRefSerializerModule.java | 187 ++------- .../jackson/SerializerIdentityUtils.java | 75 ++++ .../ProjectRelationshipDeserializer.java | 257 +++++++++++++ .../ProjectRelationshipSerializer.java | 110 ++++++ .../ProjectRelationshipSerializerModule.java | 326 ++-------------- bindings/pom.xml | 4 + .../spi/jung/JungGraphConnectionFactory.java | 3 +- drivers/neo4j-embedded/pom.xml | 16 + .../spi/neo4j/FileNeo4JGraphConnection.java | 9 +- .../spi/neo4j/FileNeo4jConnectionFactory.java | 34 +- .../atlas/graph/spi/neo4j/io/Conversions.java | 142 ++++--- ...icProjectRelationshipSerializerModule.java | 83 ++++ ...ificProjectVersionRefSerializerModule.java | 95 +++++ .../model/AbstractNeoProjectRelationship.java | 46 ++- .../graph/spi/neo4j/model/NeoArtifactRef.java | 2 +- .../model/NeoDependencyRelationship.java | 10 +- .../spi/neo4j/model/NeoIdentityUtils.java | 26 ++ .../neo4j/model/NeoParentRelationship.java | 14 +- .../graph/spi/neo4j/model/NeoProjectRef.java | 2 +- .../spi/neo4j/model/NeoProjectVersionRef.java | 8 +- .../model/NeoVersionlessArtifactRef.java | 20 +- ...ojectRelationshipSerializerModuleTest.java | 359 ++++++++++++++++++ ...ProjectVersionRefSerializerModuleTest.java | 201 ++++++++++ .../graph/spi/jung/fixture/JungTCKDriver.java | 24 +- .../graph/spi/neo4j/fixture/NeoTCKDriver.java | 24 +- .../maven/atlas/ident/ref/ArtifactRef.java | 15 + .../maven/atlas/ident/ref/ProjectRef.java | 15 + .../atlas/ident/ref/ProjectVersionRef.java | 15 + .../atlas/ident/ref/TypeAndClassifier.java | 15 + .../ident/ref/VersionlessArtifactRef.java | 15 + .../atlas/graph/RelationshipGraphFactory.java | 11 +- .../atlas/graph/rel/BomRelationship.java | 15 + .../graph/rel/DependencyRelationship.java | 15 + .../graph/rel/ExtensionRelationship.java | 15 + .../atlas/graph/rel/ParentRelationship.java | 15 + .../rel/PluginDependencyRelationship.java | 15 + .../atlas/graph/rel/PluginRelationship.java | 15 + .../spi/RelationshipGraphConnection.java | 6 +- .../RelationshipGraphConnectionFactory.java | 5 +- .../atlas/tck/graph/testutil/TCKDriver.java | 15 + ...ndencyBuildOrderIgnoringPluginPathTCK.java | 15 + .../DependencyExcludesBuildOrderTCK.java | 15 + .../ParentDependencyBuildOrderTCK.java | 15 + .../RuntimeDependencyBuildOrderTCK.java | 15 + .../SimpleDependencyBuildOrderTCK.java | 15 + .../SimpleEverythingBuildOrderTCK.java | 15 + 49 files changed, 1939 insertions(+), 577 deletions(-) create mode 100644 bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefDeserializer.java create mode 100644 bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefKeyDeserializer.java create mode 100644 bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefSerializer.java create mode 100644 bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/SerializerIdentityUtils.java create mode 100644 bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java create mode 100644 bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java create mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoSpecificProjectRelationshipSerializerModule.java create mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoSpecificProjectVersionRefSerializerModule.java create mode 100644 drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectRelationshipSerializerModuleTest.java create mode 100644 drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectVersionRefSerializerModuleTest.java diff --git a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefDeserializer.java b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefDeserializer.java new file mode 100644 index 00000000..0cb5d4f9 --- /dev/null +++ b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefDeserializer.java @@ -0,0 +1,48 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.ident.jackson; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; + +import java.io.IOException; + +/** + * Created by jdcasey on 8/26/15. + */ +public class ProjectRefDeserializer + extends StdDeserializer +{ + private static final long serialVersionUID = 1L; + + private final Class refCls; + + public ProjectRefDeserializer( final Class refCls ) + { + super( refCls ); + this.refCls = refCls; + } + + @Override + public T deserialize( final JsonParser jp, final DeserializationContext ctxt ) + throws IOException, JsonProcessingException + { + return SerializerIdentityUtils.parse( jp.getText(), refCls ); + } +} diff --git a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefKeyDeserializer.java b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefKeyDeserializer.java new file mode 100644 index 00000000..7555a815 --- /dev/null +++ b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefKeyDeserializer.java @@ -0,0 +1,46 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.ident.jackson; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.KeyDeserializer; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; + +import java.io.IOException; + +/** + * Created by jdcasey on 8/26/15. + */ +public class ProjectRefKeyDeserializer + extends KeyDeserializer +{ + private static final long serialVersionUID = 1L; + + private final Class refCls; + + public ProjectRefKeyDeserializer( final Class type ) + { + this.refCls = type; + } + + @Override + public Object deserializeKey( String key, DeserializationContext ctxt ) + throws IOException, JsonProcessingException + { + return SerializerIdentityUtils.parse( key, refCls ); + } +} diff --git a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefSerializer.java b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefSerializer.java new file mode 100644 index 00000000..5be3902b --- /dev/null +++ b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefSerializer.java @@ -0,0 +1,53 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.ident.jackson; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; + +import java.io.IOException; + +/** + * Created by jdcasey on 8/26/15. + */ +public final class ProjectRefSerializer + extends StdSerializer +{ + private boolean keySer; + + public ProjectRefSerializer( final Class refCls, boolean keySer ) + { + super( refCls ); + this.keySer = keySer; + } + + @Override + public void serialize( final T src, final JsonGenerator generator, final SerializerProvider provider ) + throws IOException, JsonGenerationException + { + if ( keySer ) + { + generator.writeFieldName( src.toString() ); + } + else + { + generator.writeString( src.toString() ); + } + } +} diff --git a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java index b597dca4..8c384a06 100644 --- a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java +++ b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java @@ -15,196 +15,67 @@ */ package org.commonjava.maven.atlas.ident.jackson; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; -import com.fasterxml.jackson.core.*; -import com.fasterxml.jackson.databind.KeyDeserializer; import org.commonjava.maven.atlas.ident.ref.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.fasterxml.jackson.databind.module.SimpleModule; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; public class ProjectVersionRefSerializerModule - extends SimpleModule + extends SimpleModule { private static final long serialVersionUID = 1L; - public ProjectVersionRefSerializerModule() - { - super( "ProjectRef (with variants) Serializer" ); - - Logger logger = LoggerFactory.getLogger( getClass() ); - logger.debug( "Registering ProjectRef serializer/deserialer" ); - // ProjectRef - addSerializer( ProjectRef.class, new ProjectRefSerializer( ProjectRef.class, false ) ); - addKeySerializer( ProjectRef.class, new ProjectRefSerializer( ProjectRef.class, true ) ); - - addDeserializer( ProjectRef.class, new ProjectRefDeserializer( ProjectRef.class ) ); - addKeyDeserializer( ProjectRef.class, new ProjectRefKeyDeserializer( ProjectRef.class ) ); - - logger.debug( "Registering ProjectVersionRef serializer/deserialer" ); - // ProjectVersionRef - addSerializer( ProjectVersionRef.class, - new ProjectRefSerializer( ProjectVersionRef.class, false ) ); - addKeySerializer( ProjectVersionRef.class, - new ProjectRefSerializer( ProjectVersionRef.class, true ) ); - - addDeserializer( ProjectVersionRef.class, - new ProjectRefDeserializer( ProjectVersionRef.class ) ); - addKeyDeserializer( ProjectVersionRef.class, - new ProjectRefKeyDeserializer( ProjectVersionRef.class ) ); - - logger.debug( "Registering SimpleArtifactRef serializer/deserialer" ); - // SimpleArtifactRef - addSerializer( ArtifactRef.class, new ProjectRefSerializer( ArtifactRef.class, false ) ); - addKeySerializer( ArtifactRef.class, new ProjectRefSerializer( ArtifactRef.class, true ) ); - - addDeserializer( ArtifactRef.class, new ProjectRefDeserializer( ArtifactRef.class ) ); - addKeyDeserializer( ArtifactRef.class, new ProjectRefKeyDeserializer( ArtifactRef.class ) ); - - logger.debug( "Registering VersionlessArtifactRef serializer/deserialer" ); - // VersionlessArtifactRef - addSerializer( VersionlessArtifactRef.class, - new ProjectRefSerializer( VersionlessArtifactRef.class, false ) ); - addKeySerializer( VersionlessArtifactRef.class, - new ProjectRefSerializer( VersionlessArtifactRef.class, true ) ); - - addDeserializer( VersionlessArtifactRef.class, - new ProjectRefDeserializer( VersionlessArtifactRef.class ) ); - addKeyDeserializer( VersionlessArtifactRef.class, - new ProjectRefKeyDeserializer( VersionlessArtifactRef.class ) ); - } + private static final Set> REF_CLASSES; - @Override - public int hashCode() + static { - return getClass().getSimpleName().hashCode() + 17; + REF_CLASSES = Collections.unmodifiableSet( new HashSet>( + Arrays.asList( ProjectRef.class, ProjectVersionRef.class, ArtifactRef.class, + VersionlessArtifactRef.class, SimpleProjectRef.class, SimpleProjectVersionRef.class, + SimpleArtifactRef.class, SimpleVersionlessArtifactRef.class ) ) ); } - @Override - public boolean equals( final Object other ) - { - return getClass().equals( other.getClass() ); - } + public static final ProjectVersionRefSerializerModule INSTANCE = new ProjectVersionRefSerializerModule(); - private T parse( final String value, final Class type ) - throws IOException + public ProjectVersionRefSerializerModule() { - Class realType = null; - if ( ProjectRef.class.equals( type ) ) - { - realType = SimpleProjectRef.class; - } - else if ( ProjectVersionRef.class.equals( type ) ) - { - realType = SimpleProjectVersionRef.class; - } - else if ( ArtifactRef.class.equals( type ) ) - { - realType = SimpleArtifactRef.class; - } - else if ( VersionlessArtifactRef.class.equals( type ) ) - { - realType = SimpleVersionlessArtifactRef.class; - } - - if ( realType == null ) - { - throw new IOException( "Cannot find concrete class for type: " + type.getSimpleName() ); - } + super( "ProjectRef (with variants) Serializer" ); - try - { - final Method parseMethod = realType.getMethod( "parse", String.class ); - return type.cast( parseMethod.invoke( null, value ) ); - } - catch ( final NoSuchMethodException e ) + for ( Class cls: REF_CLASSES ) { - throw new IOException( "Failed to lookup/invoke parse() method on " + type.getSimpleName(), e ); - } - catch ( final IllegalAccessException e ) - { - throw new IOException( "Failed to lookup/invoke parse() method on " + type.getSimpleName(), e ); - } - catch ( final InvocationTargetException e ) - { - throw new IOException( "Failed to lookup/invoke parse() method on " + type.getSimpleName(), e ); + register( cls ); } } - private static final class ProjectRefSerializer - extends StdSerializer + private void register( Class cls ) { - private boolean keySer; + Logger logger = LoggerFactory.getLogger( getClass() ); + logger.debug( "Registering {} serializers/deserialers", cls.getSimpleName() ); - ProjectRefSerializer( final Class refCls, boolean keySer ) - { - super( refCls ); - this.keySer = keySer; - } + addSerializer( cls, new ProjectRefSerializer( cls, false ) ); + addKeySerializer( cls, new ProjectRefSerializer( cls, true ) ); - @Override - public void serialize( final T src, final JsonGenerator generator, final SerializerProvider provider ) - throws IOException, JsonGenerationException - { - if ( keySer ) - { - generator.writeFieldName( src.toString() ); - } - else - { - generator.writeString( src.toString() ); - } - } + addDeserializer( cls, new ProjectRefDeserializer( cls ) ); + addKeyDeserializer( cls, new ProjectRefKeyDeserializer( cls ) ); } - private class ProjectRefDeserializer - extends StdDeserializer + @Override + public int hashCode() { - private static final long serialVersionUID = 1L; - - private final Class refCls; - - ProjectRefDeserializer( final Class refCls ) - { - super( refCls ); - this.refCls = refCls; - } - - @Override - public T deserialize( final JsonParser jp, final DeserializationContext ctxt ) - throws IOException, JsonProcessingException - { - return parse( jp.getText(), refCls ); - } + return getClass().getSimpleName().hashCode() + 17; } - public class ProjectRefKeyDeserializer - extends KeyDeserializer + @Override + public boolean equals( final Object other ) { - private static final long serialVersionUID = 1L; - - private final Class refCls; - - public ProjectRefKeyDeserializer( final Class type ) - { - this.refCls = type; - } - - @Override - public Object deserializeKey( String key, DeserializationContext ctxt ) - throws IOException, JsonProcessingException - { - return parse( key, refCls ); - } + return getClass().equals( other.getClass() ); } } diff --git a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/SerializerIdentityUtils.java b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/SerializerIdentityUtils.java new file mode 100644 index 00000000..dde549b3 --- /dev/null +++ b/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/SerializerIdentityUtils.java @@ -0,0 +1,75 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.ident.jackson; + +import org.commonjava.maven.atlas.ident.ref.*; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +/** + * Created by jdcasey on 8/26/15. + */ +public final class SerializerIdentityUtils +{ + private SerializerIdentityUtils(){} + + public static T parse( final String value, final Class type ) + throws IOException + { + Class realType = null; + if ( ArtifactRef.class.isAssignableFrom( type ) ) + { + realType = SimpleArtifactRef.class; + } + else if ( VersionlessArtifactRef.class.isAssignableFrom( type ) ) + { + realType = SimpleVersionlessArtifactRef.class; + } + else if ( ProjectVersionRef.class.isAssignableFrom( type ) ) + { + realType = SimpleProjectVersionRef.class; + } + else if ( ProjectRef.class.isAssignableFrom( type ) ) + { + realType = SimpleProjectRef.class; + } + else + { + throw new IOException( "Cannot find acceptable deserialization target class to parse: " + type.getSimpleName() ); + } + + try + { + final Method parseMethod = realType.getMethod( "parse", String.class ); + return type.cast( parseMethod.invoke( null, value ) ); + } + catch ( final NoSuchMethodException e ) + { + throw new IOException( "Failed to lookup/invoke parse() method on " + type.getSimpleName(), e ); + } + catch ( final IllegalAccessException e ) + { + throw new IOException( "Failed to lookup/invoke parse() method on " + type.getSimpleName(), e ); + } + catch ( final InvocationTargetException e ) + { + throw new IOException( "Failed to lookup/invoke parse() method on " + type.getSimpleName(), e ); + } + } + +} diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java new file mode 100644 index 00000000..5906992c --- /dev/null +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java @@ -0,0 +1,257 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.jackson; + +import com.fasterxml.jackson.core.*; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import org.commonjava.maven.atlas.graph.rel.*; +import org.commonjava.maven.atlas.graph.util.RelationshipUtils; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.ref.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.*; + +import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.*; + +/** + * Created by jdcasey on 8/26/15. + */ +@SuppressWarnings( { "rawtypes", "unchecked" } ) +public final class ProjectRelationshipDeserializer + extends StdDeserializer +{ + private static final long serialVersionUID = 1L; + + public ProjectRelationshipDeserializer() + { + super( ProjectRelationship.class ); + } + + @Override + public T deserialize( final JsonParser jp, final DeserializationContext ctx ) + throws JsonProcessingException, IOException + { + Map ast = new HashMap(); + Map locations = new HashMap(); + + JsonToken token = jp.getCurrentToken(); + String currentField = null; + List currentArry = null; + + Logger logger = LoggerFactory.getLogger( getClass() ); + do + { + // logger.info( "Token: {}", token ); + switch ( token ) + { + case START_ARRAY: + { + // logger.info( "Starting array for field: {}", currentField ); + currentArry = new ArrayList(); + break; + } + case END_ARRAY: + // logger.info( "Ending array for field: {}", currentField ); + locations.put( currentField, jp.getCurrentLocation() ); + ast.put( currentField, currentArry ); + currentArry = null; + break; + case FIELD_NAME: + currentField = jp.getCurrentName(); + break; + case VALUE_STRING: + if ( currentArry != null ) + { + currentArry.add( jp.getText() ); + } + else + { + locations.put( currentField, jp.getCurrentLocation() ); + ast.put( currentField, jp.getText() ); + } + break; + case VALUE_NUMBER_INT: + locations.put( currentField, jp.getCurrentLocation() ); + ast.put( currentField, jp.getIntValue() ); + break; + case VALUE_NUMBER_FLOAT: + locations.put( currentField, jp.getCurrentLocation() ); + ast.put( currentField, jp.getFloatValue() ); + break; + case VALUE_TRUE: + locations.put( currentField, jp.getCurrentLocation() ); + ast.put( currentField, Boolean.TRUE ); + break; + case VALUE_FALSE: + locations.put( currentField, jp.getCurrentLocation() ); + ast.put( currentField, Boolean.FALSE ); + break; + } + + token = jp.nextToken(); + } + while ( token != JsonToken.END_OBJECT ); + + StringBuilder sb = new StringBuilder(); + sb.append( "AST is:" ); + for ( String field : ast.keySet() ) + { + Object value = ast.get( field ); + sb.append( "\n " ).append( field ).append( " = " ); + if ( value == null ) + { + sb.append( "null" ); + } + else + { + sb.append( value ).append( " (type: " ).append( value.getClass().getSimpleName() ).append( ")" ); + } + } + + logger.debug( sb.toString() ); + + final RelationshipType type = RelationshipType.getType( (String) ast.get( RELATIONSHIP_TYPE ) ); + + final String uri = (String) ast.get( POM_LOCATION_URI ); + URI pomLocation; + if ( uri == null ) + { + pomLocation = RelationshipUtils.POM_ROOT_URI; + } + else + { + try + { + pomLocation = new URI( uri ); + } + catch ( final URISyntaxException e ) + { + throw new JsonParseException( "Invalid " + POM_LOCATION_URI + ": '" + uri + "': " + e.getMessage(), + locations.get( POM_LOCATION_URI ), e ); + } + } + + Collection sources = new HashSet(); + List srcs = (List) ast.get( SOURCE_URIS ); + if ( srcs != null ) + { + for ( String u : srcs ) + { + try + { + sources.add( new URI( u ) ); + } + catch ( URISyntaxException e ) + { + throw new JsonParseException( "Failed to parse source URI: " + u, + locations.get( SOURCE_URIS ) ); + } + } + } + + String decl = (String) ast.get( DECLARING_REF ); + final ProjectVersionRef declaring = SimpleProjectVersionRef.parse( decl ); + + String tgt = (String) ast.get( TARGET_REF ); + Integer index = (Integer) ast.get( INDEX ); + if ( index == null ) + { + index = 0; + } + + // handle null implicitly by comparing to true. + boolean managed = Boolean.TRUE.equals( ast.get( MANAGED ) ); + + ProjectRelationship rel = null; + switch ( type ) + { + case DEPENDENCY: + { + final ArtifactRef target = SimpleArtifactRef.parse( tgt ); + + String scp = (String) ast.get( SCOPE ); + final DependencyScope scope; + if ( scp == null ) + { + scope = DependencyScope.compile; + } + else + { + scope = DependencyScope.getScope( scp ); + } + + rel = new SimpleDependencyRelationship( sources, pomLocation, declaring, target, scope, index, + managed ); + break; + } + case EXTENSION: + { + final ProjectVersionRef target = SimpleProjectVersionRef.parse( tgt ); + + rel = new SimpleExtensionRelationship( sources, pomLocation, declaring, target, index ); + break; + } + case PARENT: + { + final ProjectVersionRef target = SimpleProjectVersionRef.parse( tgt ); + + rel = new SimpleParentRelationship( sources, declaring, target ); + break; + } + case PLUGIN: + { + final ProjectVersionRef target = SimpleProjectVersionRef.parse( tgt ); + + Boolean report = (Boolean) ast.get( REPORTING ); + rel = new SimplePluginRelationship( sources, pomLocation, declaring, target, index, managed, + Boolean.TRUE.equals( report ) ); + break; + } + case PLUGIN_DEP: + { + String plug = (String) ast.get( PLUGIN_REF ); + if ( plug == null ) + { + throw new JsonParseException( "No plugin reference (field: " + PLUGIN_REF + + ") found in plugin-dependency relationship!", + jp.getCurrentLocation() ); + } + + final ProjectRef plugin = SimpleProjectRef.parse( plug ); + final ArtifactRef target = SimpleArtifactRef.parse( tgt ); + + rel = new SimplePluginDependencyRelationship( sources, pomLocation, declaring, plugin, target, + index, managed ); + break; + } + case BOM: + { + final ProjectVersionRef target = SimpleProjectVersionRef.parse( tgt ); + + rel = new SimpleBomRelationship( sources, pomLocation, declaring, target, index ); + break; + } + } + + return (T) rel; + } +} diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java new file mode 100644 index 00000000..14160ce0 --- /dev/null +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java @@ -0,0 +1,110 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.jackson; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.PluginRelationship; +import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; + +import java.io.IOException; +import java.net.URI; +import java.util.Iterator; +import java.util.Set; + +import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.*; + +/** + * Created by jdcasey on 8/26/15. + */ +@SuppressWarnings( "rawtypes" ) +public final class ProjectRelationshipSerializer + extends StdSerializer +{ + public ProjectRelationshipSerializer( Class cls ) + { + super( cls ); + } + + @SuppressWarnings( "incomplete-switch" ) + @Override + public void serialize( final T value, final JsonGenerator gen, final SerializerProvider provider ) + throws IOException, JsonGenerationException + { + gen.writeStartObject(); + gen.writeStringField( RELATIONSHIP_TYPE, value.getType().name() ); + gen.writeStringField( POM_LOCATION_URI, value.getPomLocation().toString() ); + + Set sources = value.getSources(); + if ( sources != null ) + { + for ( Iterator iter = sources.iterator(); iter.hasNext(); ) + { + if ( iter.next() == null ) + { + iter.remove(); + } + } + if ( !sources.isEmpty() ) + { + gen.writeArrayFieldStart( SOURCE_URIS ); + for ( URI uri : sources ) + { + if ( uri == null ) + { + continue; + } + gen.writeString( uri.toString() ); + } + gen.writeEndArray(); + } + } + provider.defaultSerializeField( DECLARING_REF, value.getDeclaring(), gen ); + provider.defaultSerializeField( TARGET_REF, value.getTarget(), gen ); + + switch ( value.getType() ) + { + case DEPENDENCY: + { + gen.writeStringField( SCOPE, ( (DependencyRelationship) value ).getScope().realName() ); + gen.writeBooleanField( MANAGED, value.isManaged() ); + break; + } + case PLUGIN_DEP: + { + provider.defaultSerializeField( PLUGIN_REF, ( (PluginDependencyRelationship) value ).getPlugin(), + gen ); + gen.writeBooleanField( MANAGED, value.isManaged() ); + break; + } + case PLUGIN: + { + + gen.writeBooleanField( MANAGED, value.isManaged() ); + gen.writeBooleanField( REPORTING, ( (PluginRelationship) value ).isReporting() ); + break; + } + } + + gen.writeNumberField( INDEX, value.getIndex() ); + gen.writeEndObject(); + } + +} diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java index 8b1ced86..9d802700 100644 --- a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java @@ -15,329 +15,63 @@ */ package org.commonjava.maven.atlas.graph.jackson; -import com.fasterxml.jackson.core.*; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.fasterxml.jackson.databind.module.SimpleModule; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; import org.commonjava.maven.atlas.graph.rel.*; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; import java.util.*; -import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.*; - public class ProjectRelationshipSerializerModule - extends SimpleModule + extends SimpleModule { private static final long serialVersionUID = 1L; - public ProjectRelationshipSerializerModule() - { - super( "ProjectRelationship Serializer" ); - addSerializer( ProjectRelationship.class, new ProjectRelationshipSerializer() ); - addDeserializer( ProjectRelationship.class, new ProjectRelationshipDeserializer() ); - } + private static final Set> REL_CLASSES; - @Override - public int hashCode() + static { - return getClass().getSimpleName().hashCode() + 17; + REL_CLASSES = Collections.unmodifiableSet( new HashSet>( + Arrays.asList( ProjectRelationship.class, BomRelationship.class, DependencyRelationship.class, + ExtensionRelationship.class, ParentRelationship.class, + PluginDependencyRelationship.class, PluginRelationship.class, + SimpleBomRelationship.class, SimpleDependencyRelationship.class, + SimpleExtensionRelationship.class, SimpleParentRelationship.class, + SimplePluginDependencyRelationship.class, SimplePluginRelationship.class ) ) ); } - @Override - public boolean equals( final Object other ) - { - return getClass().equals( other.getClass() ); - } + public static final ProjectRelationshipSerializerModule INSTANCE = new ProjectRelationshipSerializerModule(); - @SuppressWarnings( "rawtypes" ) - private static final class ProjectRelationshipSerializer - extends StdSerializer + public ProjectRelationshipSerializerModule() { - ProjectRelationshipSerializer() - { - super( ProjectRelationship.class ); - } + super( "ProjectRelationship Serializer" ); - @SuppressWarnings( "incomplete-switch" ) - @Override - public void serialize( final ProjectRelationship value, final JsonGenerator gen, - final SerializerProvider provider ) - throws IOException, JsonGenerationException + for ( Class cls : REL_CLASSES ) { - gen.writeStartObject(); - gen.writeStringField( RELATIONSHIP_TYPE, value.getType().name() ); - gen.writeStringField( POM_LOCATION_URI, value.getPomLocation().toString() ); - gen.writeArrayFieldStart( SOURCE_URIS ); - - Set sources = value.getSources(); - for ( URI uri : sources ) - { - gen.writeString( uri.toString() ); - } - gen.writeEndArray(); - provider.defaultSerializeField( DECLARING_REF, value.getDeclaring(), gen ); - provider.defaultSerializeField( TARGET_REF, value.getTarget(), gen ); - - switch ( value.getType() ) - { - case DEPENDENCY: - { - gen.writeStringField( SCOPE, ( (DependencyRelationship) value ).getScope().realName() ); - gen.writeBooleanField( MANAGED, value.isManaged() ); - break; - } - case PLUGIN_DEP: - { - provider.defaultSerializeField( PLUGIN_REF, - ( (PluginDependencyRelationship) value ).getPlugin(), gen ); - gen.writeBooleanField( MANAGED, value.isManaged() ); - break; - } - case PLUGIN: - { - - gen.writeBooleanField( MANAGED, value.isManaged() ); - gen.writeBooleanField( REPORTING, ( (PluginRelationship) value ).isReporting() ); - break; - } - } - - gen.writeNumberField( INDEX, value.getIndex() ); - gen.writeEndObject(); + register( cls ); } - } - @SuppressWarnings( {"rawtypes", "unchecked"} ) - private static final class ProjectRelationshipDeserializer - extends StdDeserializer + private void register( Class cls ) { - private static final long serialVersionUID = 1L; - - ProjectRelationshipDeserializer() - { - super( ProjectRelationship.class ); - } - - @Override - public ProjectRelationship deserialize( final JsonParser jp, final DeserializationContext ctx ) - throws JsonProcessingException, IOException - { - Map ast = new HashMap(); - Map locations = new HashMap(); - - JsonToken token = jp.getCurrentToken(); - String currentField = null; - List currentArry = null; + Logger logger = LoggerFactory.getLogger( getClass() ); + logger.debug( "Registering serializer/deserializer for: {}", cls.getSimpleName() ); - Logger logger = LoggerFactory.getLogger( getClass() ); - do - { - logger.info( "Token: {}", token ); - switch(token) - { - case START_ARRAY: - { - logger.info( "Starting array for field: {}", currentField ); - currentArry = new ArrayList(); - break; - } - case END_ARRAY: - logger.info( "Ending array for field: {}", currentField ); - locations.put( currentField, jp.getCurrentLocation() ); - ast.put(currentField, currentArry); - currentArry = null; - break; - case FIELD_NAME: - currentField = jp.getCurrentName(); - break; - case VALUE_STRING: - if ( currentArry != null ) - { - currentArry.add(jp.getText()); - } - else - { - locations.put( currentField, jp.getCurrentLocation() ); - ast.put( currentField, jp.getText() ); - } - break; - case VALUE_NUMBER_INT: - locations.put( currentField, jp.getCurrentLocation() ); - ast.put( currentField, jp.getIntValue() ); - break; - case VALUE_NUMBER_FLOAT: - locations.put( currentField, jp.getCurrentLocation() ); - ast.put( currentField, jp.getFloatValue() ); - break; - case VALUE_TRUE: - locations.put( currentField, jp.getCurrentLocation() ); - ast.put( currentField, Boolean.TRUE ); - break; - case VALUE_FALSE: - locations.put( currentField, jp.getCurrentLocation() ); - ast.put( currentField, Boolean.FALSE ); - break; - } - - token = jp.nextToken(); - } - while ( token != JsonToken.END_OBJECT ); - - StringBuilder sb = new StringBuilder(); - sb.append( "AST is:" ); - for ( String field : ast.keySet() ) - { - Object value = ast.get( field ); - sb.append( "\n " ).append(field).append( " = "); - if ( value == null ) - { - sb.append( "null"); - } - else - { - sb.append( value ).append( " (type: ").append(value.getClass().getSimpleName()).append(")"); - } - } - - logger.info(sb.toString()); - - final RelationshipType type = - RelationshipType.getType( (String) ast.get(RELATIONSHIP_TYPE) ); - - final String uri = (String) ast.get( POM_LOCATION_URI ); - URI pomLocation; - if ( uri == null ) - { - pomLocation = RelationshipUtils.POM_ROOT_URI; - } - else - { - try - { - pomLocation = new URI( uri ); - } - catch ( final URISyntaxException e ) - { - throw new JsonParseException( "Invalid " + POM_LOCATION_URI + ": '" + uri + "': " + e.getMessage(), - locations.get(POM_LOCATION_URI), e ); - } - } - - Collection sources = new HashSet(); - List srcs = (List) ast.get(SOURCE_URIS); - if ( srcs != null ) - { - for ( String u: srcs ) - { - try - { - sources.add( new URI( u ) ); - } - catch ( URISyntaxException e ) - { - throw new JsonParseException( "Failed to parse source URI: " + u, locations.get(SOURCE_URIS) ); - } - } - } - - String decl = (String) ast.get( DECLARING_REF ); - final ProjectVersionRef declaring = SimpleProjectVersionRef.parse( decl ); - - String tgt = (String) ast.get( TARGET_REF ); - Integer index = (Integer) ast.get( INDEX ); - if ( index == null ) - { - index = 0; - } - - // handle null implicitly by comparing to true. - boolean managed = Boolean.TRUE.equals( ast.get( MANAGED ) ); - - ProjectRelationship rel = null; - switch ( type ) - { - case DEPENDENCY: - { - final ArtifactRef target = SimpleArtifactRef.parse( tgt ); - - String scp = (String) ast.get(SCOPE); - final DependencyScope scope; - if ( scp == null ) - { - scope = DependencyScope.compile; - } - else - { - scope = DependencyScope.getScope( scp ); - } - - rel = new SimpleDependencyRelationship( sources, pomLocation, declaring, target, scope, index, - managed ); - break; - } - case EXTENSION: - { - final ProjectVersionRef target = SimpleProjectVersionRef.parse( tgt ); - - rel = new SimpleExtensionRelationship( sources, pomLocation, declaring, target, index ); - break; - } - case PARENT: - { - final ProjectVersionRef target = SimpleProjectVersionRef.parse( tgt ); - - rel = new SimpleParentRelationship( sources, declaring, target ); - break; - } - case PLUGIN: - { - final ProjectVersionRef target = SimpleProjectVersionRef.parse( tgt ); - - Boolean report = (Boolean) ast.get( REPORTING ); - rel = new SimplePluginRelationship( sources, pomLocation, declaring, target, index, - managed, Boolean.TRUE.equals(report) ); - break; - } - case PLUGIN_DEP: - { - String plug = (String) ast.get( PLUGIN_REF ); - if ( plug == null ) - { - throw new JsonParseException( - "No plugin reference (field: " + PLUGIN_REF + ") found in plugin-dependency relationship!", - jp.getCurrentLocation() ); - } - - final ProjectRef plugin = SimpleProjectRef.parse( plug ); - final ArtifactRef target = SimpleArtifactRef.parse( tgt ); - - rel = new SimplePluginDependencyRelationship( sources, pomLocation, declaring, plugin, target, index, - managed ); - break; - } - case BOM: - { - final ProjectVersionRef target = SimpleProjectVersionRef.parse( tgt ); + addSerializer( cls, new ProjectRelationshipSerializer( cls ) ); + addDeserializer( cls, new ProjectRelationshipDeserializer() ); + } - rel = new SimpleBomRelationship( sources, pomLocation, declaring, target, index ); - break; - } - } + @Override + public int hashCode() + { + return getClass().getSimpleName().hashCode() + 17; + } - return rel; - } + @Override + public boolean equals( final Object other ) + { + return getClass().equals( other.getClass() ); } } diff --git a/bindings/pom.xml b/bindings/pom.xml index 75f6c0de..3353726c 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -31,6 +31,10 @@ Atlas :: Maven Project-Graph :: Bindings Parent + + org.commonjava.maven.atlas + atlas-identities + org.commonjava.maven.atlas atlas-relationships-api diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnectionFactory.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnectionFactory.java index df53247d..ec463394 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnectionFactory.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnectionFactory.java @@ -15,6 +15,7 @@ */ package org.commonjava.maven.atlas.graph.spi.jung; +import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -64,7 +65,7 @@ public boolean delete( final String workspaceId ) @Override public void close() - throws RelationshipGraphConnectionException + throws IOException { } diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 3e126874..c716a5a1 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -35,6 +35,22 @@ + + org.commonjava.maven.atlas + atlas-bindings-jackson-identities + + + org.commonjava.maven.atlas + atlas-bindings-jackson-relationships + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-core + org.neo4j neo4j diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java index 3301fe91..6f1ff2b5 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java @@ -52,6 +52,7 @@ import org.slf4j.LoggerFactory; import java.io.File; +import java.io.IOException; import java.util.*; import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.*; @@ -1028,7 +1029,7 @@ Relationship getRelationship( final String relId ) @Override public synchronized void close() - throws RelationshipGraphConnectionException + throws IOException { closed = true; @@ -1046,7 +1047,7 @@ public synchronized void close() logger.info( "Waiting for shutdown..." ); if ( graph.isAvailable( 1000 * SHUTDOWN_WAIT ) ) { - throw new RelationshipGraphConnectionException( "Failed to shutdown graph: %s.", dbDir ); + throw new IOException( "Failed to shutdown graph: " + dbDir ); } graph = null; @@ -1055,7 +1056,7 @@ public synchronized void close() } catch ( final Exception e ) { - throw new RelationshipGraphConnectionException( "Failed to shutdown: " + e.getMessage(), e ); + throw new IOException( "Failed to shutdown: " + e.getMessage(), e ); } } @@ -1074,7 +1075,7 @@ public void run() { close(); } - catch ( final RelationshipGraphConnectionException e ) + catch ( final IOException e ) { // new Logger( getClass() ).debug( "Failed to shutdown graph database. Reason: {}", e, e.getMessage() ); } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java index ca8d7e21..8d35d200 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java @@ -15,6 +15,14 @@ */ package org.commonjava.maven.atlas.graph.spi.neo4j; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; +import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; +import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; +import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.File; import java.io.IOException; import java.util.Arrays; @@ -23,14 +31,6 @@ import java.util.Map; import java.util.Set; -import org.apache.commons.io.FileUtils; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.ident.util.JoinString; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class FileNeo4jConnectionFactory implements RelationshipGraphConnectionFactory { @@ -110,15 +110,15 @@ public boolean delete( final String workspaceId ) return false; } - final FileNeo4JGraphConnection connection = openConnections.remove( workspaceId ); - if ( connection != null ) - { - connection.close(); - } - boolean result = false; try { + final FileNeo4JGraphConnection connection = openConnections.remove( workspaceId ); + if ( connection != null ) + { + connection.close(); + } + FileUtils.forceDelete( db ); result = !db.exists(); } @@ -132,7 +132,7 @@ public boolean delete( final String workspaceId ) @Override public synchronized void close() - throws RelationshipGraphConnectionException + throws IOException { final Logger logger = LoggerFactory.getLogger( getClass() ); @@ -143,7 +143,7 @@ public synchronized void close() { conn.close(); } - catch ( final RelationshipGraphConnectionException e ) + catch ( final IOException e ) { failedClose.add( conn.getWorkspaceId() ); logger.error( "Failed to close: " + conn.getWorkspaceId() + ".", e ); @@ -154,7 +154,7 @@ public synchronized void close() if ( !failedClose.isEmpty() ) { - throw new RelationshipGraphConnectionException( "Failed to close: %s", new JoinString( ", ", failedClose ) ); + throw new IOException( "Failed to close: " + StringUtils.join( failedClose, ", " ) ); } } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java index 6fb5fb91..a5ce92bc 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java @@ -15,22 +15,14 @@ */ package org.commonjava.maven.atlas.graph.spi.neo4j.io; -import static org.apache.commons.lang.StringUtils.join; -import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.POM_ROOT_URI; -import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.UNKNOWN_SOURCE_URI; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.*; - +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.IOUtils; import org.commonjava.maven.atlas.graph.ViewParams; +import org.commonjava.maven.atlas.graph.jackson.ProjectRelationshipSerializerModule; import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; import org.commonjava.maven.atlas.graph.rel.PluginRelationship; @@ -38,8 +30,17 @@ import org.commonjava.maven.atlas.graph.spi.neo4j.GraphAdmin; import org.commonjava.maven.atlas.graph.spi.neo4j.GraphRelType; import org.commonjava.maven.atlas.graph.spi.neo4j.NodeType; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.*; -import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoArtifactRef; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoBomRelationship; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoDependencyRelationship; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoExtensionRelationship; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoParentRelationship; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoPluginDependencyRelationship; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoPluginRelationship; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoProjectVersionRef; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoTypeAndClassifier; +import org.commonjava.maven.atlas.ident.jackson.ProjectVersionRefSerializerModule; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; @@ -49,6 +50,25 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.apache.commons.lang.StringUtils.join; + public final class Conversions { @@ -156,8 +176,7 @@ public static int countArrayElements( final String property, final PropertyConta } final Object value = container.getProperty( property ); - if ( value.getClass() - .isArray() ) + if ( value.getClass().isArray() ) { final Object[] elements = (Object[]) value; return elements.length; @@ -188,7 +207,7 @@ public static List convertToProjects( final Iterable no } public static List> convertToRelationships( final Iterable relationships, - final ConversionCache cache ) + final ConversionCache cache ) { final List> rels = new ArrayList>(); for ( final Relationship relationship : relationships ) @@ -204,8 +223,8 @@ public static List convertToProjects( final Iterable no } public static List> convertToRelationships( final Iterable relationships, - final GraphAdmin admin, - final ConversionCache cache ) + final GraphAdmin admin, + final ConversionCache cache ) { final List> rels = new ArrayList>(); for ( final Long rid : relationships ) @@ -226,7 +245,7 @@ public static void toNodeProperties( final ProjectVersionRef ref, final Node nod Logger logger = LoggerFactory.getLogger( Conversions.class ); logger.debug( "Adding {} (type: {}) to node: {}", ref, ref.getClass().getSimpleName(), node ); - if ( !( ref instanceof NeoProjectVersionRef ) || ((NeoProjectVersionRef)ref).isDirty() ) + if ( !( ref instanceof NeoProjectVersionRef ) || ( (NeoProjectVersionRef) ref ).isDirty() ) { final String g = ref.getGroupId(); final String a = ref.getArtifactId(); @@ -254,17 +273,15 @@ public static void toNodeProperties( final ProjectVersionRef ref, final Node nod } markConnected( node, connected ); -// -// logger.debug( "groupId of {} is:\nNeoIdentityUtils: {}\nConversions: {}\nDirect access: {}", node, -// NeoIdentityUtils.getStringProperty( node, GROUP_ID, null, null ), -// getStringProperty( GROUP_ID, node ), node.hasProperty( GROUP_ID ) ? node.getProperty( GROUP_ID ) : null ); + // + // logger.debug( "groupId of {} is:\nNeoIdentityUtils: {}\nConversions: {}\nDirect access: {}", node, + // NeoIdentityUtils.getStringProperty( node, GROUP_ID, null, null ), + // getStringProperty( GROUP_ID, node ), node.hasProperty( GROUP_ID ) ? node.getProperty( GROUP_ID ) : null ); } public static boolean isAtlasType( final Relationship rel ) { - return GraphRelType.valueOf( rel.getType() - .name() ) - .isAtlasRelationship(); + return GraphRelType.valueOf( rel.getType().name() ).isAtlasRelationship(); } public static boolean isType( final Node node, final NodeType type ) @@ -310,8 +327,7 @@ public static ProjectVersionRef toProjectVersionRef( final Node node, final Conv private static boolean empty( final String val ) { - return val == null || val.trim() - .length() < 1; + return val == null || val.trim().length() < 1; } @SuppressWarnings( "incomplete-switch" ) @@ -320,10 +336,10 @@ public static void toRelationshipProperties( final ProjectRelationship rel relationship.setProperty( INDEX, rel.getIndex() ); String[] srcs = toStringArray( rel.getSources() ); Logger logger = LoggerFactory.getLogger( Conversions.class ); - logger.debug( "Storing rel: {}\nwith sources: {}\n in property: {}\nRelationship: {}", rel, Arrays.toString(srcs), SOURCE_URI, relationship ); + logger.debug( "Storing rel: {}\nwith sources: {}\n in property: {}\nRelationship: {}", rel, + Arrays.toString( srcs ), SOURCE_URI, relationship ); relationship.setProperty( SOURCE_URI, srcs ); - relationship.setProperty( POM_LOCATION_URI, rel.getPomLocation() - .toString() ); + relationship.setProperty( POM_LOCATION_URI, rel.getPomLocation().toString() ); switch ( rel.getType() ) { @@ -332,8 +348,7 @@ public static void toRelationshipProperties( final ProjectRelationship rel final DependencyRelationship specificRel = (DependencyRelationship) rel; toRelationshipProperties( (ArtifactRef) rel.getTarget(), relationship ); relationship.setProperty( IS_MANAGED, specificRel.isManaged() ); - relationship.setProperty( SCOPE, specificRel.getScope() - .realName() ); + relationship.setProperty( SCOPE, specificRel.getScope().realName() ); final Set excludes = specificRel.getExcludes(); if ( excludes != null && !excludes.isEmpty() ) @@ -346,9 +361,7 @@ public static void toRelationshipProperties( final ProjectRelationship rel sb.append( "," ); } - sb.append( exclude.getGroupId() ) - .append( ":" ) - .append( exclude.getArtifactId() ); + sb.append( exclude.getGroupId() ).append( ":" ).append( exclude.getArtifactId() ); } relationship.setProperty( EXCLUDES, sb.toString() ); @@ -417,8 +430,7 @@ public static String[] toStringArray( final Collection sources ) } } - final GraphRelType mapper = GraphRelType.valueOf( rel.getType() - .name() ); + final GraphRelType mapper = GraphRelType.valueOf( rel.getType().name() ); // LOGGER.debug( "Converting relationship of type: {} (atlas type: {})", mapper, // mapper.atlasType() ); @@ -429,7 +441,7 @@ public static String[] toStringArray( final Collection sources ) } if ( rel.getStartNode() == null || rel.getEndNode() == null || !isType( rel.getStartNode(), NodeType.PROJECT ) - || !isType( rel.getEndNode(), NodeType.PROJECT ) ) + || !isType( rel.getEndNode(), NodeType.PROJECT ) ) { return null; } @@ -439,14 +451,12 @@ public static String[] toStringArray( final Collection sources ) { case DEPENDENCY: { - result = - new NeoDependencyRelationship( rel ); + result = new NeoDependencyRelationship( rel ); break; } case PLUGIN_DEP: { - result = - new NeoPluginDependencyRelationship( rel ); + result = new NeoPluginDependencyRelationship( rel ); break; } case PLUGIN: @@ -471,8 +481,8 @@ public static String[] toStringArray( final Collection sources ) } default: { - throw new IllegalArgumentException( "I don't know how to construct the atlas relationship for type: " - + mapper.atlasType() ); + throw new IllegalArgumentException( + "I don't know how to construct the atlas relationship for type: " + mapper.atlasType() ); } } @@ -487,7 +497,32 @@ public static String[] toStringArray( final Collection sources ) public static String id( final ProjectRelationship rel ) { - return DigestUtils.shaHex( rel.toString() ); + try + { + String json = newMapper().writeValueAsString( rel ); + + // FIXME: Rookie mistake! You can't add debug info to toString() with this here. + return DigestUtils.shaHex( json ); + } + catch ( JsonProcessingException e ) + { + throw new IllegalArgumentException( "Cannot serialize relationship for ID generation: " + e.getMessage(), + e ); + } + } + + private static ObjectMapper newMapper() + { + ObjectMapper mapper = new ObjectMapper(); + mapper.registerModules( ProjectVersionRefSerializerModule.INSTANCE, + ProjectRelationshipSerializerModule.INSTANCE, + NeoSpecificProjectRelationshipSerializerModule.INSTANCE, + NeoSpecificProjectVersionRefSerializerModule.INSTANCE ); + + mapper.disable( SerializationFeature.WRITE_NULL_MAP_VALUES, SerializationFeature.WRITE_EMPTY_JSON_ARRAYS ); + mapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES ); + + return mapper; } private static ArtifactRef toArtifactRef( final ProjectVersionRef ref, final Relationship rel ) @@ -548,6 +583,10 @@ public static Set getURISetProperty( final String prop, final PropertyConta } catch ( final URISyntaxException e ) { + Logger logger = LoggerFactory.getLogger( Conversions.class ); + logger.warn( + String.format( "Failed to construct URI from: %s\nContainer: %s\nReason: %s", container, + uri, e.getMessage() ), e ); } } } @@ -1005,8 +1044,8 @@ public static ViewParams retrieveView( final Node viewNode, final ConversionCach catch ( final IOException e ) { throw new IllegalStateException( - "Cannot construct ObjectInputStream to wrap ByteArrayInputStream containing " - + data.length + " bytes!", e ); + "Cannot construct ObjectInputStream to wrap ByteArrayInputStream containing " + data.length + + " bytes!", e ); } catch ( final ClassNotFoundException e ) { @@ -1058,6 +1097,9 @@ public static long getSelectionOrigin( final long targetRid, final Node viewNode public static void setSelection( final long originRid, final long targetRid, final Node viewNode ) { + Logger logger = LoggerFactory.getLogger( Conversions.class ); + logger.info( "Setting selection. Deselecting: {} in favor of: {} (view-node: {})", originRid, targetRid, + viewNode ); viewNode.setProperty( DESELECTION_TARGET_PREFIX + originRid, targetRid ); viewNode.setProperty( SELECTION_ORIGIN_PREFIX + targetRid, originRid ); } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoSpecificProjectRelationshipSerializerModule.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoSpecificProjectRelationshipSerializerModule.java new file mode 100644 index 00000000..3b34516f --- /dev/null +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoSpecificProjectRelationshipSerializerModule.java @@ -0,0 +1,83 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.spi.neo4j.io; + +import com.fasterxml.jackson.databind.module.SimpleModule; +import org.commonjava.maven.atlas.graph.jackson.ProjectRelationshipDeserializer; +import org.commonjava.maven.atlas.graph.jackson.ProjectRelationshipSerializer; +import org.commonjava.maven.atlas.graph.rel.*; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +/** + * Created by jdcasey on 8/26/15. + */ +public class NeoSpecificProjectRelationshipSerializerModule + extends SimpleModule +{ + + private static final long serialVersionUID = 1L; + + private static final Set> REL_CLASSES; + + static + { + REL_CLASSES = Collections.unmodifiableSet( new HashSet>( + Arrays.asList( NeoBomRelationship.class, NeoDependencyRelationship.class, + NeoExtensionRelationship.class, NeoParentRelationship.class, + NeoPluginDependencyRelationship.class, NeoPluginRelationship.class ) ) ); + } + + public static final NeoSpecificProjectRelationshipSerializerModule INSTANCE = new NeoSpecificProjectRelationshipSerializerModule(); + + public NeoSpecificProjectRelationshipSerializerModule() + { + super( "ProjectRelationship Serializer" ); + + for ( Class cls : REL_CLASSES ) + { + register( cls ); + } + } + + private void register( Class cls ) + { + Logger logger = LoggerFactory.getLogger( getClass() ); + logger.debug( "Registering serializer/deserializer for: {}", cls.getSimpleName() ); + + addSerializer( cls, new ProjectRelationshipSerializer( cls ) ); + addDeserializer( cls, new ProjectRelationshipDeserializer() ); + } + + @Override + public int hashCode() + { + return getClass().getSimpleName().hashCode() + 17; + } + + @Override + public boolean equals( final Object other ) + { + return getClass().equals( other.getClass() ); + } + +} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoSpecificProjectVersionRefSerializerModule.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoSpecificProjectVersionRefSerializerModule.java new file mode 100644 index 00000000..363ed116 --- /dev/null +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoSpecificProjectVersionRefSerializerModule.java @@ -0,0 +1,95 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.spi.neo4j.io; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.KeyDeserializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoArtifactRef; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoProjectRef; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoProjectVersionRef; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoVersionlessArtifactRef; +import org.commonjava.maven.atlas.ident.jackson.ProjectRefSerializer; +import org.commonjava.maven.atlas.ident.jackson.SerializerIdentityUtils; +import org.commonjava.maven.atlas.ident.ref.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +public class NeoSpecificProjectVersionRefSerializerModule + extends SimpleModule +{ + + private static final long serialVersionUID = 1L; + + private static final Set> REF_CLASSES; + + static + { + REF_CLASSES = Collections.unmodifiableSet( new HashSet>( + Arrays.asList( NeoProjectRef.class, NeoProjectVersionRef.class, NeoArtifactRef.class, + NeoVersionlessArtifactRef.class ) ) ); + } + + public static final NeoSpecificProjectVersionRefSerializerModule INSTANCE = new NeoSpecificProjectVersionRefSerializerModule(); + + public NeoSpecificProjectVersionRefSerializerModule() + { + super( "ProjectRef (with variants) Serializer" ); + + for ( Class cls: REF_CLASSES ) + { + register( cls ); + } + } + + private void register( Class cls ) + { + Logger logger = LoggerFactory.getLogger( getClass() ); + logger.debug( "Registering {} serializers", cls.getSimpleName() ); + + addSerializer( cls, new ProjectRefSerializer( cls, false ) ); + addKeySerializer( cls, new ProjectRefSerializer( cls, true ) ); +// +// addDeserializer( cls, new ProjectRefDeserializer( cls ) ); +// addKeyDeserializer( cls, new ProjectRefKeyDeserializer( cls ) ); + } + + @Override + public int hashCode() + { + return getClass().getSimpleName().hashCode() + 17; + } + + @Override + public boolean equals( final Object other ) + { + return getClass().equals( other.getClass() ); + } + +} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java index 53bf94cf..cdd18b02 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.model; import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; @@ -8,9 +23,12 @@ import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; import org.neo4j.graphdb.Relationship; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.net.URI; import java.util.Collection; +import java.util.Collections; import java.util.Set; /** @@ -81,7 +99,7 @@ public synchronized I cloneFor( final ProjectVersionRef projectRef ) @Override public int getIndex() { - return Conversions.getIntegerProperty(Conversions.INDEX, rel); + return NeoIdentityUtils.getIntegerProperty( rel, Conversions.INDEX, null, 0 ); } @Override @@ -105,18 +123,38 @@ public ArtifactRef getTargetArtifact() @Override public boolean isManaged() { - return Conversions.getBooleanProperty( Conversions.IS_MANAGED, rel ); + return NeoIdentityUtils.getBooleanProperty( rel, Conversions.IS_MANAGED, null, false ); } @Override public Set getSources() { - return sources == null ? Conversions.getURISetProperty( Conversions.SOURCE_URI, rel, RelationshipUtils.UNKNOWN_SOURCE_URI ) : sources; + if ( sources != null ) + { + return sources; + } + + Set srcs = Conversions.getURISetProperty( Conversions.SOURCE_URI, rel, RelationshipUtils.UNKNOWN_SOURCE_URI ); + Logger logger = LoggerFactory.getLogger( getClass() ); + logger.debug("Got source URIs from relationship: {} of: {}", rel, srcs ); + + if ( srcs != null ) + { + return srcs; + } + + return Collections.emptySet(); } @Override public URI getPomLocation() { - return Conversions.getURIProperty( Conversions.POM_LOCATION_URI, rel, RelationshipUtils.POM_ROOT_URI ); + URI pl = Conversions.getURIProperty( Conversions.POM_LOCATION_URI, rel, RelationshipUtils.POM_ROOT_URI ); + if ( pl != null ) + { + return pl; + } + + return RelationshipUtils.POM_ROOT_URI; } } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java index 087ddb4e..a87a311c 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java @@ -48,7 +48,7 @@ public class NeoArtifactRef private static final long serialVersionUID = 1L; - private final NeoTypeAndClassifier tc; + private NeoTypeAndClassifier tc; private Boolean optional; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java index d4377ccf..6db7d371 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java @@ -52,7 +52,11 @@ public NeoDependencyRelationship( Relationship rel ) public final DependencyScope getScope() { final String scopeStr = Conversions.getStringProperty( Conversions.SCOPE, rel ); - return DependencyScope.getScope( scopeStr ); + Logger logger = LoggerFactory.getLogger( getClass() ); + logger.debug("Got scope from relationship: {} of: {}", rel, scopeStr ); + + DependencyScope scope = DependencyScope.getScope( scopeStr ); + return scope == null ? DependencyScope.compile : scope; } @Override @@ -86,8 +90,8 @@ public boolean equals( final Object obj ) @Override public String toString() { - return String.format( "DependencyRelationship [%s => %s (managed=%s, scope=%s, index=%s, rel=%d)]", getDeclaring(), - getTarget(), isManaged(), getScope(), getIndex(), rel.getId() ); + return String.format( "DependencyRelationship [%s => %s (managed=%s, scope=%s, index=%s)]", getDeclaring(), + getTarget(), isManaged(), getScope(), getIndex() ); } @Override diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentityUtils.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentityUtils.java index 8ce66960..cd735b40 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentityUtils.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentityUtils.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.model; import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; @@ -76,4 +91,15 @@ public static ArtifactRef newNeoArtifactRef( ProjectVersionRef ref, ArtifactRef } return new NeoArtifactRef( ref, tc, optional ); } + + public static int getIntegerProperty( PropertyContainer container, String named, Integer memVal, int defaultVal ) + { + if ( memVal != null ) + { + return memVal; + } + + Integer v = container == null ? null : Conversions.getIntegerProperty( named, container); + return v == null ? defaultVal : v; + } } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoParentRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoParentRelationship.java index 7118fc33..8a590030 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoParentRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoParentRelationship.java @@ -29,11 +29,12 @@ import java.io.Serializable; import java.net.URI; import java.util.Collection; +import java.util.Collections; import java.util.Set; public final class NeoParentRelationship - extends AbstractNeoProjectRelationship - implements Serializable, ParentRelationship + extends AbstractNeoProjectRelationship + implements Serializable, ParentRelationship { private static final long serialVersionUID = 1L; @@ -104,7 +105,7 @@ public ParentRelationship addSources( Collection sources ) { Set srcs = getSources(); boolean changed = false; - for ( URI src: sources ) + for ( URI src : sources ) { changed = srcs.add( src ) || changed; } @@ -117,4 +118,11 @@ public ParentRelationship addSources( Collection sources ) return this; } + @Override + public Set getSources() + { + return isTerminus() ? + Collections.singleton( RelationshipUtils.TERMINAL_PARENT_SOURCE_URI ) : + super.getSources(); + } } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java index d80228fb..e77fccd6 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java @@ -165,7 +165,7 @@ public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier @Override public String toString() { - return String.format( "%s:%s", getArtifactId(), getGroupId() ); + return String.format( "%s:%s", getGroupId(), getArtifactId() ); } @Override diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java index 9add7964..a1291fdf 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java @@ -15,8 +15,6 @@ */ package org.commonjava.maven.atlas.graph.spi.neo4j.model; -import static org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoIdentityUtils.getStringProperty; - import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; import org.commonjava.maven.atlas.ident.ref.*; import org.commonjava.maven.atlas.ident.util.VersionUtils; @@ -24,10 +22,9 @@ import org.commonjava.maven.atlas.ident.version.SingleVersion; import org.commonjava.maven.atlas.ident.version.VersionSpec; import org.neo4j.graphdb.Node; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import static org.apache.commons.lang.StringUtils.isEmpty; +import static org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoIdentityUtils.getStringProperty; /** * Reference to a particular release of a project (or module, in terms of Maven builds). A release may contain many artifacts (see {@link NeoArtifactRef}). @@ -116,9 +113,6 @@ public static ProjectVersionRef parse( final String gav ) @Override public ProjectVersionRef asProjectVersionRef() { - Logger logger = LoggerFactory.getLogger( getClass() ); - logger.debug("Trying to create new ProjectVersionRef from: {}", getClass().getSimpleName()); - return NeoProjectVersionRef.class.equals( getClass() ) ? this : new NeoProjectVersionRef( this ); diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java index c81ce001..74bc2841 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java @@ -15,7 +15,11 @@ */ package org.commonjava.maven.atlas.graph.spi.neo4j.model; -import org.commonjava.maven.atlas.ident.ref.*; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.InvalidRefException; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.TypeAndClassifier; +import org.commonjava.maven.atlas.ident.ref.VersionlessArtifactRef; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; import static org.apache.commons.lang.StringUtils.isEmpty; @@ -27,15 +31,15 @@ * @author jdcasey */ public class NeoVersionlessArtifactRef - extends NeoProjectRef + extends NeoProjectRef implements VersionlessArtifactRef { private static final long serialVersionUID = 1L; - private final TypeAndClassifier tc; + private TypeAndClassifier tc; - private final boolean optional; + private boolean optional; public NeoVersionlessArtifactRef( final ArtifactRef ref ) { @@ -61,7 +65,7 @@ public NeoVersionlessArtifactRef( final ProjectRef ref, final TypeAndClassifier public NeoVersionlessArtifactRef( final String groupId, final String artifactId, final String type, final String classifier, final boolean optional ) - throws InvalidVersionSpecificationException + throws InvalidVersionSpecificationException { super( groupId, artifactId ); this.tc = new NeoTypeAndClassifier( type, classifier ); @@ -81,8 +85,8 @@ public static VersionlessArtifactRef parse( final String spec ) if ( parts.length < 2 || isEmpty( parts[0] ) || isEmpty( parts[1] ) ) { throw new InvalidRefException( - "VersionlessArtifactRef must contain AT LEAST non-empty groupId and artifactId. (Given: '" - + spec + "')" ); + "VersionlessArtifactRef must contain AT LEAST non-empty groupId and artifactId. (Given: '" + spec + + "')" ); } final String g = parts[0]; @@ -160,7 +164,7 @@ public boolean equals( final Object obj ) { return false; } - if ( !(obj instanceof VersionlessArtifactRef) ) + if ( !( obj instanceof VersionlessArtifactRef ) ) { return false; } diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectRelationshipSerializerModuleTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectRelationshipSerializerModuleTest.java new file mode 100644 index 00000000..8e578530 --- /dev/null +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectRelationshipSerializerModuleTest.java @@ -0,0 +1,359 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.spi.neo4j.io; + +import static org.junit.Assert.*; +import static org.hamcrest.CoreMatchers.*; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import org.commonjava.maven.atlas.graph.jackson.ProjectRelationshipSerializerModule; +import org.commonjava.maven.atlas.graph.rel.BomRelationship; +import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; +import org.commonjava.maven.atlas.graph.rel.ParentRelationship; +import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.PluginRelationship; +import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleBomRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleExtensionRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; +import org.commonjava.maven.atlas.graph.rel.SimplePluginDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; +import org.commonjava.maven.atlas.graph.spi.neo4j.GraphRelType; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoBomRelationship; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoDependencyRelationship; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoExtensionRelationship; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoParentRelationship; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoPluginDependencyRelationship; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoPluginRelationship; +import org.commonjava.maven.atlas.graph.util.RelationshipUtils; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.jackson.ProjectVersionRefSerializerModule; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.neo4j.graphdb.GraphDatabaseService; +import org.neo4j.graphdb.Node; +import org.neo4j.graphdb.Relationship; +import org.neo4j.graphdb.Transaction; +import org.neo4j.graphdb.factory.GraphDatabaseFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * Created by jdcasey on 8/26/15. + */ +public class NeoProjectRelationshipSerializerModuleTest +{ + private static final String WORKSPACE = "workspace"; + + private static final URI TEST_URI; + + static + { + URI u; + try + { + u = new URI( "test:location" ); + } + catch ( URISyntaxException e ) + { + Logger logger = LoggerFactory.getLogger( NeoProjectRelationshipSerializerModuleTest.class ); + logger.error( "Failed to construct test URI", e ); + u = null; + } + + TEST_URI = u; + } + + @Rule + public TemporaryFolder temp = new TemporaryFolder(); + + private ObjectMapper mapper; + + private GraphDatabaseService graph; + + @Before + public void before() + throws Exception + { + mapper = new ObjectMapper(); + mapper.registerModules( ProjectVersionRefSerializerModule.INSTANCE, + NeoSpecificProjectVersionRefSerializerModule.INSTANCE, + ProjectRelationshipSerializerModule.INSTANCE, + NeoSpecificProjectRelationshipSerializerModule.INSTANCE ); + + mapper.setSerializationInclusion( JsonInclude.Include.NON_EMPTY ); + mapper.configure( JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT, true ); + + mapper.enable( SerializationFeature.INDENT_OUTPUT, SerializationFeature.USE_EQUALITY_FOR_OBJECT_ID ); + + mapper.enable( MapperFeature.AUTO_DETECT_FIELDS ); + // disable( MapperFeature.AUTO_DETECT_GETTERS ); + + mapper.disable( SerializationFeature.WRITE_NULL_MAP_VALUES, SerializationFeature.WRITE_EMPTY_JSON_ARRAYS ); + + mapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES ); + + graph = new GraphDatabaseFactory().newEmbeddedDatabase( temp.newFolder( "db" ).getAbsolutePath() ); + } + + @After + public void after() + { + if ( graph != null ) + { + graph.shutdown(); + } + } + + @Test + public void roundTripParentRelationship() + throws Exception + { + ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); + + ParentRelationship rel = + new SimpleParentRelationship( pvr ); + + String json = mapper.writeValueAsString( rel ); + + Relationship r = store( rel ); + + NeoParentRelationship result = new NeoParentRelationship( r ); + + String njson = mapper.writeValueAsString( result ); + + assertThat( njson, equalTo( json ) ); + + ParentRelationship deser = mapper.readValue( njson, ParentRelationship.class ); + assertThat( deser, equalTo( rel ) ); + } + + @Test + public void roundTripDependencyRelationship() + throws Exception + { + ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); + ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); + + DependencyRelationship rel = new SimpleDependencyRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2.asJarArtifact(), + DependencyScope.compile, 0, false ); + + String json = mapper.writeValueAsString( rel ); + + Relationship r = store( rel ); + + NeoDependencyRelationship result = new NeoDependencyRelationship( r ); + + String njson = mapper.writeValueAsString( result ); + + assertThat( njson, equalTo( json ) ); + + DependencyRelationship deser = mapper.readValue( njson, DependencyRelationship.class ); + assertThat( deser, equalTo( rel ) ); + } + + private Relationship store( ProjectRelationship rel ) + { + Relationship r; + Transaction tx = graph.beginTx(); + try + { + Node start = graph.createNode(); + Conversions.toNodeProperties( rel.getDeclaring(), start, true ); + Node end = graph.createNode(); + Conversions.toNodeProperties( rel.getTarget(), end, false ); + + r = start.createRelationshipTo( end, GraphRelType.map( rel.getType(), rel.isManaged() ) ); + Conversions.toRelationshipProperties( rel, r ); + + tx.success(); + } + finally + { + tx.finish(); + } + + return r; + } + + @Test + public void roundTripExtensionRelationship() + throws Exception + { + ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); + ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); + + ExtensionRelationship rel = new SimpleExtensionRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0 ); + + String json = mapper.writeValueAsString( rel ); + + Relationship r = store( rel ); + + NeoExtensionRelationship result = new NeoExtensionRelationship( r ); + + String njson = mapper.writeValueAsString( result ); + + assertThat( njson, equalTo( json ) ); + + ExtensionRelationship deser = mapper.readValue( njson, ExtensionRelationship.class ); + assertThat( deser, equalTo( rel ) ); + } + + @Test + public void roundTripBomRelationship() + throws Exception + { + ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); + ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); + + BomRelationship rel = new SimpleBomRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0 ); + + String json = mapper.writeValueAsString( rel ); + + Relationship r = store( rel ); + + NeoBomRelationship result = new NeoBomRelationship( r ); + + String njson = mapper.writeValueAsString( result ); + + assertThat( njson, equalTo( json ) ); + + BomRelationship deser = mapper.readValue( njson, BomRelationship.class ); + assertThat( deser, equalTo( rel ) ); + } + + @Test + public void roundTripPluginRelationship() + throws Exception + { + ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); + ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); + + PluginRelationship rel = new SimplePluginRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0, false ); + + String json = mapper.writeValueAsString( rel ); + + Relationship r = store( rel ); + + NeoPluginRelationship result = new NeoPluginRelationship( r ); + + String njson = mapper.writeValueAsString( result ); + + assertThat( njson, equalTo( json ) ); + + PluginRelationship deser = mapper.readValue( njson, PluginRelationship.class ); + assertThat( deser, equalTo( rel ) ); + } + + @Test + public void roundTripPluginDependencyRelationship() + throws Exception + { + ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); + ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); + ProjectRef pr = new SimpleProjectRef( "org.foo", "plugin" ); + + PluginDependencyRelationship rel = new SimplePluginDependencyRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pr, pvr2.asJarArtifact(), 0, false ); + + String json = mapper.writeValueAsString( rel ); + + Relationship r = store( rel ); + + NeoPluginDependencyRelationship result = new NeoPluginDependencyRelationship( r ); + + String njson = mapper.writeValueAsString( result ); + + assertThat( njson, equalTo( json ) ); + + PluginDependencyRelationship deser = mapper.readValue( njson, PluginDependencyRelationship.class ); + assertThat( deser, equalTo( rel ) ); + } + + @Test + public void roundTripMixedList() + throws Exception + { + ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); + ProjectVersionRef dep = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); + ProjectVersionRef bom = new SimpleProjectVersionRef( "org.foo", "bom", "1.0" ); + ProjectVersionRef ext = new SimpleProjectVersionRef( "org.foo", "ext", "1.0" ); + ProjectVersionRef plug = new SimpleProjectVersionRef( "org.foo", "plug", "1.0" ); + ProjectVersionRef pdep = new SimpleProjectVersionRef( "org.foo", "pdep", "1.0" ); + ProjectVersionRef parent = new SimpleProjectVersionRef( "org.foo", "parent", "1.0" ); + ProjectRef pr = new SimpleProjectRef( "org.foo", "plugin" ); + + List> rels = Arrays.> asList( + new SimpleParentRelationship( TEST_URI, pvr, parent ), + new SimpleDependencyRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, dep.asJarArtifact(), + DependencyScope.compile, 0, false ), + new SimpleBomRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, ext, 0 ), + new SimpleExtensionRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, ext, 0 ), + new SimplePluginRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, plug, 0, false ), + new SimplePluginDependencyRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pr, + pdep.asJarArtifact(), 0, false ) ); + + String json = mapper.writeValueAsString( rels ); + + List rs = new ArrayList(); + for ( ProjectRelationship rel : rels ) + { + rs.add( store( rel ) ); + } + + int i=0; + List> nrels = Arrays.>asList( + new NeoParentRelationship( rs.get( i++ ) ), + new NeoDependencyRelationship( rs.get(i++) ), + new NeoBomRelationship( rs.get(i++) ), + new NeoExtensionRelationship( rs.get(i++) ), + new NeoPluginRelationship( rs.get(i++) ), + new NeoPluginDependencyRelationship( rs.get(i++) ) + ); + + String njson = mapper.writeValueAsString( nrels ); + + assertThat( njson, equalTo( json ) ); + + List> deser = mapper.readValue( njson, + new TypeReference>>() + { + } ); + assertThat( deser, equalTo( rels ) ); + } + +} diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectVersionRefSerializerModuleTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectVersionRefSerializerModuleTest.java new file mode 100644 index 00000000..28d61700 --- /dev/null +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectVersionRefSerializerModuleTest.java @@ -0,0 +1,201 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.spi.neo4j.io; + +import static org.junit.Assert.*; +import static org.hamcrest.CoreMatchers.*; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import org.apache.commons.io.IOUtils; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; +import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; +import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; +import org.commonjava.maven.atlas.graph.spi.neo4j.FileNeo4JGraphConnection; +import org.commonjava.maven.atlas.graph.spi.neo4j.FileNeo4jConnectionFactory; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoArtifactRef; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoProjectRef; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoProjectVersionRef; +import org.commonjava.maven.atlas.ident.jackson.ProjectVersionRefSerializerModule; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleTypeAndClassifier; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.neo4j.graphdb.GraphDatabaseService; +import org.neo4j.graphdb.Node; +import org.neo4j.graphdb.Transaction; +import org.neo4j.graphdb.factory.GraphDatabaseFactory; + +import java.io.File; +import java.io.IOException; + +import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.GA; +import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.GAV; +import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.toNodeProperties; + +/** + * Created by jdcasey on 8/26/15. + */ +public class NeoProjectVersionRefSerializerModuleTest +{ + private static final String WORKSPACE = "workspace"; + + @Rule + public TemporaryFolder temp = new TemporaryFolder(); + + private ObjectMapper mapper; + + private GraphDatabaseService graph; + + @Before + public void before() + throws Exception + { + mapper = new ObjectMapper(); + mapper.registerModules( ProjectVersionRefSerializerModule.INSTANCE, + NeoSpecificProjectVersionRefSerializerModule.INSTANCE ); + + mapper.setSerializationInclusion( JsonInclude.Include.NON_EMPTY ); + mapper.configure( JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT, true ); + + mapper.enable( SerializationFeature.INDENT_OUTPUT, SerializationFeature.USE_EQUALITY_FOR_OBJECT_ID ); + + mapper.enable( MapperFeature.AUTO_DETECT_FIELDS ); + // disable( MapperFeature.AUTO_DETECT_GETTERS ); + + mapper.disable( SerializationFeature.WRITE_NULL_MAP_VALUES, SerializationFeature.WRITE_EMPTY_JSON_ARRAYS ); + + mapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES ); + + graph = new GraphDatabaseFactory().newEmbeddedDatabase( temp.newFolder( "db" ).getAbsolutePath() ); + } + + @After + public void after() + { + if ( graph != null ) + { + graph.shutdown(); + } + } + + @Test + public void roundTripArtifactRef() + throws IOException + { + ArtifactRef aref = new SimpleArtifactRef( new SimpleProjectVersionRef( "org.foo", "bar", "1" ), + new SimpleTypeAndClassifier( "jar", null ), false ); + + String json = mapper.writeValueAsString( aref ); + + Transaction tx = graph.beginTx(); + Node node; + try + { + node = graph.createNode(); + Conversions.toNodeProperties( aref, node, true ); + tx.success(); + } + finally + { + tx.finish(); + } + + NeoArtifactRef naref = new NeoArtifactRef( node ); + String njson = mapper.writeValueAsString( naref ); + + assertThat( njson, equalTo( json ) ); + + ArtifactRef deser = mapper.readValue( njson, ArtifactRef.class ); + assertThat( deser, equalTo( aref ) ); + } + + @Test + public void roundTripProjectVersionRef() + throws IOException + { + ProjectVersionRef ref = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); + + String json = mapper.writeValueAsString( ref ); + + Transaction tx = graph.beginTx(); + Node node; + try + { + node = graph.createNode(); + Conversions.toNodeProperties( ref, node, true ); + tx.success(); + } + finally + { + tx.finish(); + } + + NeoProjectVersionRef naref = new NeoProjectVersionRef( node ); + String njson = mapper.writeValueAsString( naref ); + + assertThat( njson, equalTo( json ) ); + + ProjectVersionRef deser = mapper.readValue( njson, ProjectVersionRef.class ); + assertThat( deser, equalTo( ref ) ); + } + + @Test + public void roundTripProjectRef() + throws IOException + { + ProjectRef aref = new SimpleProjectRef( "org.foo", "bar" ); + ProjectVersionRef pvr = new SimpleProjectVersionRef( aref.getGroupId(), aref.getArtifactId(), "1" ); + + String json = mapper.writeValueAsString( aref ); + + Transaction tx = graph.beginTx(); + Node node; + try + { + node = graph.createNode(); + Conversions.toNodeProperties( pvr, node, true ); + tx.success(); + } + finally + { + tx.finish(); + } + + NeoProjectRef naref = new NeoProjectRef( node ); + String njson = mapper.writeValueAsString( naref ); + + assertThat( njson, equalTo( json ) ); + + ProjectRef deser = mapper.readValue( njson, ProjectRef.class ); + assertThat( deser, equalTo( aref ) ); + } + +} diff --git a/ftests/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/fixture/JungTCKDriver.java b/ftests/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/fixture/JungTCKDriver.java index 167f9fba..24709477 100644 --- a/ftests/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/fixture/JungTCKDriver.java +++ b/ftests/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/fixture/JungTCKDriver.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.jung.fixture; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; @@ -43,14 +58,7 @@ public void close() { if ( factory != null ) { - try - { - factory.close(); - } - catch ( RelationshipGraphConnectionException e ) - { - throw new IOException( "Failed to shutdown graph connection factory: " + e.getMessage(), e ); - } + factory.close(); } } } diff --git a/ftests/neo4j/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/NeoTCKDriver.java b/ftests/neo4j/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/NeoTCKDriver.java index fcb2d05c..42503c25 100644 --- a/ftests/neo4j/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/NeoTCKDriver.java +++ b/ftests/neo4j/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/NeoTCKDriver.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.fixture; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; @@ -43,14 +58,7 @@ public void close() { if ( factory != null ) { - try - { - factory.close(); - } - catch ( RelationshipGraphConnectionException e ) - { - throw new IOException( "Failed to shutdown graph connection factory: " + e.getMessage(), e ); - } + factory.close(); } } } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java index a22964be..73f4fa95 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.ref; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java index e7cbdcb3..4d58c697 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.ref; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java index 52e00c12..41692621 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.ref; import org.commonjava.maven.atlas.ident.version.SingleVersion; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/TypeAndClassifier.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/TypeAndClassifier.java index 9c5a1146..1f2a9700 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/TypeAndClassifier.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/TypeAndClassifier.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.ref; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java index ba437192..25641f47 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.ident.ref; /** diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java index 9498e4ad..05656a38 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java @@ -15,6 +15,8 @@ */ package org.commonjava.maven.atlas.graph; +import java.io.Closeable; +import java.io.IOException; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; @@ -31,6 +33,7 @@ import org.slf4j.LoggerFactory; public final class RelationshipGraphFactory + implements Closeable { private final Logger logger = LoggerFactory.getLogger( getClass() ); @@ -128,7 +131,7 @@ public boolean deleteWorkspace( final String workspaceId ) { connectionCache.closeNow(); } - catch ( final RelationshipGraphConnectionException ex ) + catch ( final IOException ex ) { logger.error( "Error when trying to close connection cache: {}", ex ); } @@ -151,7 +154,7 @@ private void checkClosed() } public synchronized void close() - throws RelationshipGraphException + throws IOException { closed = true; timer.cancel(); @@ -201,7 +204,7 @@ private static final class ConnectionCache } public synchronized void closeNow() - throws RelationshipGraphConnectionException + throws IOException { mapOfCaches.remove( wsid ); @@ -229,7 +232,7 @@ public void run() { closeNow(); } - catch ( final RelationshipGraphConnectionException e ) + catch ( final IOException e ) { logger.error( "Failed to close graph connection cache: " + connection, e ); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java index 20a00a5d..80bdce8e 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.rel; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java index 827be9cf..58fb0ed6 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.rel; import org.commonjava.maven.atlas.ident.DependencyScope; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java index ac5a8c08..e90685be 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.rel; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java index 1ba6655a..d0f55221 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.rel; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java index c148830d..508e2e5f 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.rel; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java index e844ff01..0b88fe10 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.rel; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java index ab4641e1..74de7792 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java @@ -15,6 +15,8 @@ */ package org.commonjava.maven.atlas.graph.spi; +import java.io.Closeable; +import java.io.IOException; import java.util.Collection; import java.util.List; import java.util.Map; @@ -33,6 +35,7 @@ import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; public interface RelationshipGraphConnection + extends Closeable { /* @@ -169,9 +172,6 @@ void traverse( RelationshipGraphTraversal traversal, ProjectVersionRef root, Rel List getPathRefs( ViewParams params, GraphPath path ); - void close() - throws RelationshipGraphConnectionException; - boolean isClosed(); String getWorkspaceId(); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionFactory.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionFactory.java index 76f901cc..a82c8dcd 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionFactory.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionFactory.java @@ -15,9 +15,12 @@ */ package org.commonjava.maven.atlas.graph.spi; +import java.io.Closeable; +import java.io.IOException; import java.util.Set; public interface RelationshipGraphConnectionFactory + extends Closeable { RelationshipGraphConnection openConnection( String workspaceId, boolean create ) @@ -32,7 +35,7 @@ boolean delete( String workspaceId ) throws RelationshipGraphConnectionException; void close() - throws RelationshipGraphConnectionException; + throws IOException; boolean exists( String workspaceId ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/testutil/TCKDriver.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/testutil/TCKDriver.java index 87cba852..6704b1e0 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/testutil/TCKDriver.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/testutil/TCKDriver.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.tck.graph.testutil; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java index 774101ab..d0f19c2b 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; import org.commonjava.maven.atlas.graph.RelationshipGraph; diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java index 946f970d..28398a38 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; import org.commonjava.maven.atlas.graph.RelationshipGraph; diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java index 0c80a12c..167af463 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; import org.commonjava.maven.atlas.graph.RelationshipGraph; diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java index 9c5fef0b..015fe2e0 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; import org.commonjava.maven.atlas.graph.RelationshipGraph; diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java index bda01167..a6e6e7e5 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; import org.commonjava.maven.atlas.graph.RelationshipGraph; diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java index 0b95a60a..a167000a 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; import org.commonjava.maven.atlas.graph.RelationshipGraph; From f755897791b7ab6ed0f93ddcf70701671af6d1ff Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 31 Aug 2015 12:24:14 -0500 Subject: [PATCH 100/240] fixing neo-specific relationship impls, and batching relationships on storage. --- .../spi/neo4j/FileNeo4JGraphConnection.java | 35 ++- .../model/AbstractNeoProjectRelationship.java | 53 ++++ .../model/NeoDependencyRelationship.java | 2 +- .../NeoPluginDependencyRelationship.java | 13 +- .../neo4j/model/NeoPluginRelationship.java | 2 +- .../graph/spi/neo4j/model/NeoProjectRef.java | 6 + .../spi/neo4j/model/NeoIdentitiesTest.java | 112 +++++++ .../NeoProjectRelationshipEqualitiesTest.java | 282 ++++++++++++++++++ .../AbstractSimpleProjectRelationship.java | 14 +- .../rel/SimpleDependencyRelationship.java | 2 +- .../SimplePluginDependencyRelationship.java | 8 +- .../graph/rel/SimplePluginRelationship.java | 2 +- .../tck/graph/batch/LargeBatchInsertTCK.java | 100 +++++++ 13 files changed, 603 insertions(+), 28 deletions(-) create mode 100644 drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java create mode 100644 drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRelationshipEqualitiesTest.java create mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java index 6f1ff2b5..721c8220 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java @@ -62,6 +62,8 @@ public class FileNeo4JGraphConnection implements Runnable, Neo4JGraphConnection { + private static final int BATCH_SIZE = 100; + private final Logger logger = LoggerFactory.getLogger( getClass() ); // private static final int ADD_BATCHSIZE = 50; @@ -510,11 +512,36 @@ public ProjectVersionRef getPathTargetRef( final GraphPath path ) final List> sorted = new ArrayList>( Arrays.asList( rels ) ); Collections.sort( sorted, RelationshipComparator.INSTANCE ); + double batches = sorted.size() < BATCH_SIZE ? 1 : Math.ceil( (double) sorted.size() / (double) BATCH_SIZE ); + logger.info( "\n\n\nProcessing {} batches of relationships ({} total relationships)\n\n\n\n", batches, sorted.size() ); + + int processed = 0; + for ( int i = 0; i < batches; i++ ) + { + logger.info( "Starting batch #{} at: {}", i, processed ); + int upper = sorted.size(); // size() is one beyond upper index. + if ( upper - processed > BATCH_SIZE ) + { + upper = processed + BATCH_SIZE; + } + + List> batch = sorted.subList( processed, upper ); + logger.info( "\n\n\nInserting relationship batch of size: {}\n\n\n\n", batch.size() ); + insertRelationshipBatch( batch, cache, createdRelationshipsMap ); + processed += batch.size(); + } + + return createdRelationshipsMap; + } + + private void insertRelationshipBatch( List> rels, ConversionCache cache, + Map> createdRelationshipsMap ) + { final Transaction tx = graph.beginTx(); try { // int txBatchCount = 0; - nextRel: for ( final ProjectRelationship rel : sorted ) + nextRel: for ( final ProjectRelationship rel : rels ) { if ( (rel instanceof AbstractNeoProjectRelationship ) && !( (AbstractNeoProjectRelationship) rel ).isDirty()) { @@ -592,7 +619,7 @@ public ProjectVersionRef getPathTargetRef( final GraphPath path ) relationship = from.createRelationshipTo( to, grt ); - // now, we set an index on the relationship of where it is in the range of ALL atlas relationships + // now, we set an index on the relationship of where it is in the range of ALL atlas relationships // for this node. ProjectRelationship.getIndex() only gives the index for that TYPE, so we can't // use it. The next value will be stored on the from node for the next go. int nodeRelIdx = Conversions.getIntegerProperty( Conversions.ATLAS_RELATIONSHIP_COUNT, from, 0 ); @@ -641,7 +668,7 @@ public ProjectVersionRef getPathTargetRef( final GraphPath path ) // We don't really need transaction here, I don't think... // but we're forced to use one to update the graph. - // So, to find a balance between memory consumed by a transaction + // So, to find a balance between memory consumed by a transaction // and speed (creating/committing txns takes time), we'll batch them. // txBatchCount++; // if ( txBatchCount >= ADD_BATCHSIZE ) @@ -660,8 +687,6 @@ public ProjectVersionRef getPathTargetRef( final GraphPath path ) { tx.finish(); } - - return createdRelationshipsMap; } @Override diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java index cdd18b02..94c2132e 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java @@ -157,4 +157,57 @@ public URI getPomLocation() return RelationshipUtils.POM_ROOT_URI; } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ( ( getDeclaring() == null ) ? 0 : getDeclaring().hashCode() ); + result = prime * result + ( ( getTarget() == null ) ? 0 : getTarget().hashCode() ); + result = prime * result + ( ( getType() == null ) ? 0 : getType().hashCode() ); + return result; + } + + @Override + public boolean equals( final Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( obj == null ) + { + return false; + } + if ( !(obj instanceof ProjectRelationship) ) + { + return false; + } + final ProjectRelationship other = (ProjectRelationship) obj; + if ( getDeclaring() == null ) + { + if ( other.getDeclaring() != null ) + { + return false; + } + } + else if ( !getDeclaring().equals( other.getDeclaring() ) ) + { + return false; + } + if ( getTarget() == null ) + { + if ( other.getTarget() != null ) + { + return false; + } + } + else if ( !getTarget().equals( other.getTarget() ) ) + { + return false; + } + return getType() == other.getType(); + } + } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java index 6db7d371..66e86fd9 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java @@ -79,7 +79,7 @@ public boolean equals( final Object obj ) { return false; } - if ( getClass() != obj.getClass() ) + if ( !( obj instanceof DependencyRelationship ) ) { return false; } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java index 8c03f642..a59266ac 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java @@ -70,26 +70,23 @@ public boolean equals( final Object obj ) { return false; } - if ( getClass() != obj.getClass() ) + if ( !(obj instanceof PluginDependencyRelationship) ) { return false; } - final NeoPluginDependencyRelationship other = (NeoPluginDependencyRelationship) obj; + final PluginDependencyRelationship other = (PluginDependencyRelationship) obj; if ( isManaged() != other.isManaged() ) { return false; } - - ProjectRef plugin = getPlugin(); - ProjectRef otherPlugin = other.getPlugin(); - if ( plugin == null ) + if ( getPlugin() == null ) { - if ( otherPlugin != null ) + if ( other.getPlugin() != null ) { return false; } } - else if ( !plugin.equals( otherPlugin ) ) + else if ( !getPlugin().equals( other.getPlugin() ) ) { return false; } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java index 04d3ab7e..72f10b71 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java @@ -68,7 +68,7 @@ public boolean equals( final Object obj ) { return false; } - if ( getClass() != obj.getClass() ) + if ( !(obj instanceof PluginRelationship) ) { return false; } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java index e77fccd6..fd79fe53 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java @@ -24,6 +24,8 @@ import org.neo4j.graphdb.Node; import org.neo4j.graphdb.PropertyContainer; import org.neo4j.graphdb.Relationship; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import static org.apache.commons.lang.StringUtils.isEmpty; @@ -90,6 +92,10 @@ public NeoProjectRef( Node container ) public NeoProjectRef( PropertyContainer container, String groupIdProperty, String artifactIdProperty ) { + Logger logger = LoggerFactory.getLogger( getClass() ); + logger.debug( "setting up project ref on container: {} with gid prop: {} and aid prop: {}", container, + groupIdProperty, artifactIdProperty ); + this.container = container; this.groupIdProperty = groupIdProperty; this.artifactIdProperty = artifactIdProperty; diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java new file mode 100644 index 00000000..8cc1f5cb --- /dev/null +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java @@ -0,0 +1,112 @@ +package org.commonjava.maven.atlas.graph.spi.neo4j.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; +import org.commonjava.maven.atlas.graph.spi.neo4j.io.NeoSpecificProjectVersionRefSerializerModule; +import org.commonjava.maven.atlas.ident.jackson.ProjectVersionRefSerializerModule; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.neo4j.graphdb.GraphDatabaseService; +import org.neo4j.graphdb.Node; +import org.neo4j.graphdb.Transaction; +import org.neo4j.graphdb.factory.GraphDatabaseFactory; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +/** + * Created by jdcasey on 8/28/15. + */ +public class NeoIdentitiesTest +{ + + private static final String WORKSPACE = "workspace"; + + @Rule + public TemporaryFolder temp = new TemporaryFolder(); + + private GraphDatabaseService graph; + + @Before + public void before() + throws Exception + { + graph = new GraphDatabaseFactory().newEmbeddedDatabase( temp.newFolder( "db" ).getAbsolutePath() ); + } + + @After + public void after() + { + if ( graph != null ) + { + graph.shutdown(); + } + } + + @Test + public void projectRefCrossImplEquality() + { + ProjectRef aref = new SimpleProjectRef( "org.foo", "bar" ); + Node node = toNode( new SimpleProjectVersionRef( aref.getGroupId(), aref.getArtifactId(), "1" ) ); + + NeoProjectRef naref = new NeoProjectRef( node ); + + assertThat( naref, equalTo( aref ) ); + } + + @Test + public void projectVersionRefCrossImplEquality() + { + ProjectVersionRef aref = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); + Node node = toNode( aref ); + + NeoProjectVersionRef naref = new NeoProjectVersionRef( node ); + + assertThat( naref, equalTo( aref ) ); + } + + @Test + public void artifactRefCrossImplEquality() + { + ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); + ArtifactRef aref = new SimpleArtifactRef( pvr, "jar", null, false ); + Node node = toNode( aref ); + + NeoArtifactRef naref = new NeoArtifactRef( node ); + + assertThat( naref, equalTo( aref ) ); + } + + private Node toNode( ProjectVersionRef pvr ) + { + Transaction tx = graph.beginTx(); + Node node; + try + { + node = graph.createNode(); + Conversions.toNodeProperties( pvr, node, true ); + tx.success(); + } + finally + { + tx.finish(); + } + + return node; + } +} diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRelationshipEqualitiesTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRelationshipEqualitiesTest.java new file mode 100644 index 00000000..66bff57b --- /dev/null +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRelationshipEqualitiesTest.java @@ -0,0 +1,282 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.spi.neo4j.model; + +import org.commonjava.maven.atlas.graph.rel.BomRelationship; +import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; +import org.commonjava.maven.atlas.graph.rel.ParentRelationship; +import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.PluginRelationship; +import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleBomRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleExtensionRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; +import org.commonjava.maven.atlas.graph.rel.SimplePluginDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; +import org.commonjava.maven.atlas.graph.spi.neo4j.GraphRelType; +import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; +import org.commonjava.maven.atlas.graph.util.RelationshipUtils; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.neo4j.graphdb.GraphDatabaseService; +import org.neo4j.graphdb.Node; +import org.neo4j.graphdb.Relationship; +import org.neo4j.graphdb.Transaction; +import org.neo4j.graphdb.factory.GraphDatabaseFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +/** + * Created by jdcasey on 8/26/15. + */ +public class NeoProjectRelationshipEqualitiesTest +{ + private static final URI TEST_URI; + + static + { + URI u; + try + { + u = new URI( "test:location" ); + } + catch ( URISyntaxException e ) + { + Logger logger = LoggerFactory.getLogger( NeoProjectRelationshipEqualitiesTest.class ); + logger.error( "Failed to construct test URI", e ); + u = null; + } + + TEST_URI = u; + } + + @Rule + public TemporaryFolder temp = new TemporaryFolder(); + + private GraphDatabaseService graph; + + @Before + public void before() + throws Exception + { + graph = new GraphDatabaseFactory().newEmbeddedDatabase( temp.newFolder( "db" ).getAbsolutePath() ); + } + + @After + public void after() + { + if ( graph != null ) + { + graph.shutdown(); + } + } + + @Test + public void parentRelationshipEq() + throws Exception + { + ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); + + ParentRelationship rel = + new SimpleParentRelationship( pvr ); + + Relationship r = store( rel ); + + NeoParentRelationship result = new NeoParentRelationship( r ); + assertThat( result, equalTo( rel ) ); + } + + @Test + public void dependencyRelationshipEq() + throws Exception + { + ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); + ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); + + DependencyRelationship rel = new SimpleDependencyRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2.asJarArtifact(), + DependencyScope.compile, 0, false ); + + Relationship r = store( rel ); + + NeoDependencyRelationship result = new NeoDependencyRelationship( r ); + assertThat( result, equalTo( rel ) ); + } + + private Relationship store( ProjectRelationship rel ) + { + Relationship r; + Transaction tx = graph.beginTx(); + try + { + Node start = graph.createNode(); + Conversions.toNodeProperties( rel.getDeclaring(), start, true ); + Node end = graph.createNode(); + Conversions.toNodeProperties( rel.getTarget(), end, false ); + + r = start.createRelationshipTo( end, GraphRelType.map( rel.getType(), rel.isManaged() ) ); + Conversions.toRelationshipProperties( rel, r ); + + tx.success(); + } + finally + { + tx.finish(); + } + + return r; + } + + @Test + public void extensionRelationshipEq() + throws Exception + { + ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); + ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); + + ExtensionRelationship rel = new SimpleExtensionRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0 ); + + Relationship r = store( rel ); + + NeoExtensionRelationship result = new NeoExtensionRelationship( r ); + assertThat( result, equalTo( rel ) ); + } + + @Test + public void bomRelationshipEq() + throws Exception + { + ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); + ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); + + BomRelationship rel = new SimpleBomRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0 ); + + Relationship r = store( rel ); + + NeoBomRelationship result = new NeoBomRelationship( r ); + assertThat( result, equalTo( rel ) ); + } + + @Test + public void pluginRelationshipEq() + throws Exception + { + ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); + ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); + + PluginRelationship rel = new SimplePluginRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0, false ); + + Relationship r = store( rel ); + + NeoPluginRelationship result = new NeoPluginRelationship( r ); + assertThat( result, equalTo( rel ) ); + } + + @Test + public void pluginDependencyRelationshipEq() + throws Exception + { + ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); + ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); + ProjectRef pr = new SimpleProjectRef( "org.foo", "plugin" ); + + PluginDependencyRelationship rel = new SimplePluginDependencyRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pr, pvr2.asJarArtifact(), 0, false ); + + Relationship r = store( rel ); + + NeoPluginDependencyRelationship result = new NeoPluginDependencyRelationship( r ); + assertThat( result, equalTo( rel ) ); + } + + @Test + public void mixedSetContains() + throws Exception + { + ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); + ProjectVersionRef dep = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); + ProjectVersionRef bom = new SimpleProjectVersionRef( "org.foo", "bom", "1.0" ); + ProjectVersionRef ext = new SimpleProjectVersionRef( "org.foo", "ext", "1.0" ); + ProjectVersionRef plug = new SimpleProjectVersionRef( "org.foo", "plug", "1.0" ); + ProjectVersionRef pdep = new SimpleProjectVersionRef( "org.foo", "pdep", "1.0" ); + ProjectVersionRef parent = new SimpleProjectVersionRef( "org.foo", "parent", "1.0" ); + ProjectRef pr = new SimpleProjectRef( "org.foo", "plugin" ); + + List> rels = Arrays.> asList( + new SimpleParentRelationship( TEST_URI, pvr, parent ), + new SimpleDependencyRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, dep.asJarArtifact(), + DependencyScope.compile, 0, false ), + new SimpleBomRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, bom, 0 ), + new SimpleExtensionRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, ext, 0 ), + new SimplePluginRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, plug, 0, false ), + new SimplePluginDependencyRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pr, + pdep.asJarArtifact(), 0, false ) ); + + List rs = new ArrayList(); + for ( ProjectRelationship rel : rels ) + { + rs.add( store( rel ) ); + } + + int i=0; + List> nrels = new ArrayList>(); + Logger logger = LoggerFactory.getLogger( getClass() ); + logger.info("Adding parent, i={}", i); + nrels.add( new NeoParentRelationship( rs.get( i++ ) ) ); + logger.info( "Adding dep, i={}", i ); + nrels.add( new NeoDependencyRelationship( rs.get( i++ ) ) ); + logger.info( "Adding bom, i={}", i ); + nrels.add( new NeoBomRelationship( rs.get( i++ ) ) ); + logger.info( "Adding ext, i={}", i ); + nrels.add( new NeoExtensionRelationship( rs.get( i++ ) ) ); + logger.info( "Adding plugin, i={}", i ); + nrels.add( new NeoPluginRelationship( rs.get( i++ ) ) ); + logger.info( "Adding plugin-dep, i={}", i ); + nrels.add( new NeoPluginDependencyRelationship( rs.get( i++ ) ) ); + logger.info( "Added all, i={}", i ); + + List> missing = new ArrayList>(); + for ( ProjectRelationship rel: nrels ) + { + if ( !rels.contains( rel ) ) + { + missing.add( rel ); + } + } + + assertThat( "Neo-specific relationships not found in original set: " + missing, missing.isEmpty(), + equalTo( true ) ); + + } + +} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java index 981d8081..3ab32d51 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java @@ -182,34 +182,34 @@ public boolean equals( final Object obj ) { return false; } - if ( getClass() != obj.getClass() ) + if ( !(obj instanceof ProjectRelationship) ) { return false; } - final AbstractSimpleProjectRelationship other = (AbstractSimpleProjectRelationship) obj; + final ProjectRelationship other = (ProjectRelationship) obj; if ( declaring == null ) { - if ( other.declaring != null ) + if ( other.getDeclaring() != null ) { return false; } } - else if ( !declaring.equals( other.declaring ) ) + else if ( !declaring.equals( other.getDeclaring() ) ) { return false; } if ( target == null ) { - if ( other.target != null ) + if ( other.getTarget() != null ) { return false; } } - else if ( !target.equals( other.target ) ) + else if ( !target.equals( other.getTarget() ) ) { return false; } - return type == other.type; + return type == other.getType(); } @Override diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java index bf174c0b..f13b2712 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java @@ -127,7 +127,7 @@ public boolean equals( final Object obj ) { return false; } - if ( getClass() != obj.getClass() ) + if ( !( obj instanceof DependencyRelationship ) ) { return false; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java index 86cde7cd..9a1de12d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java @@ -85,23 +85,23 @@ public boolean equals( final Object obj ) { return false; } - if ( getClass() != obj.getClass() ) + if ( !(obj instanceof PluginDependencyRelationship) ) { return false; } - final SimplePluginDependencyRelationship other = (SimplePluginDependencyRelationship) obj; + final PluginDependencyRelationship other = (PluginDependencyRelationship) obj; if ( isManaged() != other.isManaged() ) { return false; } if ( plugin == null ) { - if ( other.plugin != null ) + if ( other.getPlugin() != null ) { return false; } } - else if ( !plugin.equals( other.plugin ) ) + else if ( !plugin.equals( other.getPlugin() ) ) { return false; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java index 577a44be..a81f37d0 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java @@ -95,7 +95,7 @@ public boolean equals( final Object obj ) { return false; } - if ( getClass() != obj.getClass() ) + if ( !(obj instanceof PluginRelationship) ) { return false; } diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java new file mode 100644 index 00000000..618c8773 --- /dev/null +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java @@ -0,0 +1,100 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.tck.graph.batch; + +import org.commonjava.maven.atlas.graph.RelationshipGraph; +import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.util.RelationshipUtils; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; +import org.junit.Test; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.Set; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +public class LargeBatchInsertTCK + extends AbstractSPI_TCK +{ + + private static final String NAMECHARS = "abcdefghijklmnopqrstuvwxyz"; + + private Random random = new Random(); + + @Test + public void run() + throws Exception + { + final ProjectVersionRef myRef = new SimpleProjectVersionRef( "my.group", "my-artifact", "1.0" ); + List rels = new ArrayList(); + for ( int i = 0; i < 550; i++ ) + { + rels.add(new SimpleDependencyRelationship( sourceURI(), RelationshipUtils.POM_ROOT_URI, myRef, newArtifact(), + DependencyScope.compile, i, false ) ); + } + + final RelationshipGraph graph = simpleGraph( myRef ); + + graph.storeRelationships( rels ); + + Set> result = graph.getAllRelationships(); + assertThat( result.size(), equalTo( rels.size() ) ); + + for ( ProjectRelationship rel: rels ) + { + assertThat( rel + " was not returned from the graph!", result.contains( rel ), equalTo( true ) ); + } + } + + private ArtifactRef newArtifact() + { + return new SimpleArtifactRef( genName(), genName(), genNum(), "jar", null, false ); + } + + private String genName() + { + StringBuilder sb = new StringBuilder(); + for ( int i = 0; i < 10; i++ ) + { + sb.append(NAMECHARS.charAt( Math.abs( random.nextInt() ) % NAMECHARS.length() ) ); + } + + return sb.toString(); + } + + private String genNum() + { + StringBuilder sb = new StringBuilder(); + for ( int i = 0; i < 4; i++ ) + { + sb.append(Integer.toString(Math.abs( random.nextInt() ) % 10 ) ); + } + + return sb.toString(); + } +} From 173a8065a71b47bf384d0b4245a6d401de6d845f Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 31 Aug 2015 14:50:42 -0500 Subject: [PATCH 101/240] Add tunable storage batch size to neo4j driver. --- .../spi/neo4j/FileNeo4JGraphConnection.java | 13 ++++++++----- .../spi/neo4j/FileNeo4jConnectionFactory.java | 16 +++++++++++----- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java index 721c8220..9c448485 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java @@ -62,7 +62,7 @@ public class FileNeo4JGraphConnection implements Runnable, Neo4JGraphConnection { - private static final int BATCH_SIZE = 100; + static final int DEFAULT_BATCH_SIZE = 500; private final Logger logger = LoggerFactory.getLogger( getClass() ); @@ -130,15 +130,18 @@ public class FileNeo4JGraphConnection private final String workspaceId; + private int storageBatchSize = DEFAULT_BATCH_SIZE; + private final FileNeo4jConnectionFactory factory; private final File dbDir; - FileNeo4JGraphConnection( final String workspaceId, final File dbDir, final boolean useShutdownHook, + FileNeo4JGraphConnection( final String workspaceId, final File dbDir, final boolean useShutdownHook, final int storageBatchSize, final FileNeo4jConnectionFactory factory ) { this.workspaceId = workspaceId; this.dbDir = dbDir; + this.storageBatchSize = storageBatchSize; this.factory = factory; this.adminAccess = new GraphAdminImpl( this ); @@ -512,7 +515,7 @@ public ProjectVersionRef getPathTargetRef( final GraphPath path ) final List> sorted = new ArrayList>( Arrays.asList( rels ) ); Collections.sort( sorted, RelationshipComparator.INSTANCE ); - double batches = sorted.size() < BATCH_SIZE ? 1 : Math.ceil( (double) sorted.size() / (double) BATCH_SIZE ); + double batches = sorted.size() < storageBatchSize ? 1 : Math.ceil( (double) sorted.size() / (double) storageBatchSize ); logger.info( "\n\n\nProcessing {} batches of relationships ({} total relationships)\n\n\n\n", batches, sorted.size() ); int processed = 0; @@ -520,9 +523,9 @@ public ProjectVersionRef getPathTargetRef( final GraphPath path ) { logger.info( "Starting batch #{} at: {}", i, processed ); int upper = sorted.size(); // size() is one beyond upper index. - if ( upper - processed > BATCH_SIZE ) + if ( upper - processed > storageBatchSize ) { - upper = processed + BATCH_SIZE; + upper = processed + storageBatchSize; } List> batch = sorted.subList( processed, upper ); diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java index 8d35d200..5c7e3374 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java @@ -41,6 +41,15 @@ public class FileNeo4jConnectionFactory private final boolean useShutdownHook; + private int storageBatchSize = FileNeo4JGraphConnection.DEFAULT_BATCH_SIZE; + + public FileNeo4jConnectionFactory( final File dbBaseDirectory, final boolean useShutdownHook, final int storageBatchSize ) + { + this.dbBaseDirectory = dbBaseDirectory; + this.useShutdownHook = useShutdownHook; + this.storageBatchSize = storageBatchSize; + } + public FileNeo4jConnectionFactory( final File dbBaseDirectory, final boolean useShutdownHook ) { this.dbBaseDirectory = dbBaseDirectory; @@ -80,7 +89,7 @@ else if ( !db.mkdirs() ) FileNeo4JGraphConnection conn = openConnections.get( workspaceId ); if ( conn == null || !conn.isOpen() ) { - conn = new FileNeo4JGraphConnection( workspaceId, db, useShutdownHook, this ); + conn = new FileNeo4JGraphConnection( workspaceId, db, useShutdownHook, storageBatchSize, this ); openConnections.put( workspaceId, conn ); } @@ -110,7 +119,6 @@ public boolean delete( final String workspaceId ) return false; } - boolean result = false; try { final FileNeo4JGraphConnection connection = openConnections.remove( workspaceId ); @@ -120,14 +128,12 @@ public boolean delete( final String workspaceId ) } FileUtils.forceDelete( db ); - result = !db.exists(); + return !db.exists(); } catch ( final IOException e ) { throw new RelationshipGraphConnectionException( "Failed to delete: %s. Reason: %s", e, db, e.getMessage() ); } - - return result; } @Override From 586be5f8563f780fe576423c4cb9ee1ea36689b4 Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 3 Sep 2015 15:57:33 -0500 Subject: [PATCH 102/240] Fixing license header. skip ci on this one. --- .../graph/spi/neo4j/model/NeoIdentitiesTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java index 8cc1f5cb..ea66718a 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.spi.neo4j.model; import com.fasterxml.jackson.annotation.JsonInclude; From ae507dffdbbbf7442ce58065f580a26f9b2bffef Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 3 Sep 2015 16:01:29 -0500 Subject: [PATCH 103/240] [maven-release-plugin] prepare release atlas-parent-0.15.0 --- bindings/jackson-identities/pom.xml | 2 +- bindings/jackson-relationships/pom.xml | 2 +- bindings/pom.xml | 2 +- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- ftests/jung/pom.xml | 2 +- ftests/neo4j/pom.xml | 2 +- ftests/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 18 +++++++++--------- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index cbc497e5..b99acacb 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.14.3-SNAPSHOT + 0.15.0 atlas-bindings-jackson-identities diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml index 2d8e2438..3c52c44b 100644 --- a/bindings/jackson-relationships/pom.xml +++ b/bindings/jackson-relationships/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.14.3-SNAPSHOT + 0.15.0 atlas-bindings-jackson-relationships diff --git a/bindings/pom.xml b/bindings/pom.xml index 3353726c..7c69e394 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.3-SNAPSHOT + 0.15.0 atlas-bindings-parent diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index d1a14b7e..fe387b67 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.14.3-SNAPSHOT + 0.15.0 atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index c716a5a1..88351a02 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.14.3-SNAPSHOT + 0.15.0 atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 4d9a04b4..f0a452ed 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.3-SNAPSHOT + 0.15.0 atlas-drivers-parent diff --git a/ftests/jung/pom.xml b/ftests/jung/pom.xml index 982178c8..c5087dab 100644 --- a/ftests/jung/pom.xml +++ b/ftests/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.14.3-SNAPSHOT + 0.15.0 atlas-ftests-jung diff --git a/ftests/neo4j/pom.xml b/ftests/neo4j/pom.xml index 56131a05..9c524cae 100644 --- a/ftests/neo4j/pom.xml +++ b/ftests/neo4j/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.14.3-SNAPSHOT + 0.15.0 atlas-ftests-neo4j diff --git a/ftests/pom.xml b/ftests/pom.xml index 37ffaef9..0771356e 100644 --- a/ftests/pom.xml +++ b/ftests/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.3-SNAPSHOT + 0.15.0 atlas-ftests-parent diff --git a/identities/pom.xml b/identities/pom.xml index 42f7124c..3553034c 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.3-SNAPSHOT + 0.15.0 atlas-identities diff --git a/pom.xml b/pom.xml index 8c2c35e1..3086d72f 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.3-SNAPSHOT + 0.15.0 pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - HEAD + atlas-parent-0.15.0 @@ -48,37 +48,37 @@ org.commonjava.maven.atlas atlas-identities - 0.14.3-SNAPSHOT + 0.15.0 org.commonjava.maven.atlas atlas-relationships-api - 0.14.3-SNAPSHOT + 0.15.0 org.commonjava.maven.atlas atlas-bindings-jackson-identities - 0.14.3-SNAPSHOT + 0.15.0 org.commonjava.maven.atlas atlas-bindings-jackson-relationships - 0.14.3-SNAPSHOT + 0.15.0 org.commonjava.maven.atlas atlas-driver-jung - 0.14.3-SNAPSHOT + 0.15.0 org.commonjava.maven.atlas atlas-driver-neo4j-embedded - 0.14.3-SNAPSHOT + 0.15.0 org.commonjava.maven.atlas atlas-drivers-tck - 0.14.3-SNAPSHOT + 0.15.0 test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 602421e1..f0db9315 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.3-SNAPSHOT + 0.15.0 atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 876d2148..43a2cab0 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.14.3-SNAPSHOT + 0.15.0 atlas-drivers-tck From 1e24977e71f94f70abbd0d52e6ad8ba2ea4d2c6b Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 3 Sep 2015 16:01:32 -0500 Subject: [PATCH 104/240] [maven-release-plugin] prepare for next development iteration --- bindings/jackson-identities/pom.xml | 2 +- bindings/jackson-relationships/pom.xml | 2 +- bindings/pom.xml | 2 +- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- ftests/jung/pom.xml | 2 +- ftests/neo4j/pom.xml | 2 +- ftests/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 18 +++++++++--------- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index b99acacb..d814f3d4 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.15.0 + 0.16.0-SNAPSHOT atlas-bindings-jackson-identities diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml index 3c52c44b..b982d2ab 100644 --- a/bindings/jackson-relationships/pom.xml +++ b/bindings/jackson-relationships/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.15.0 + 0.16.0-SNAPSHOT atlas-bindings-jackson-relationships diff --git a/bindings/pom.xml b/bindings/pom.xml index 7c69e394..7095c5da 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.0 + 0.16.0-SNAPSHOT atlas-bindings-parent diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index fe387b67..1a249b2a 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.15.0 + 0.16.0-SNAPSHOT atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 88351a02..548f47ae 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.15.0 + 0.16.0-SNAPSHOT atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index f0a452ed..7552e6e9 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.0 + 0.16.0-SNAPSHOT atlas-drivers-parent diff --git a/ftests/jung/pom.xml b/ftests/jung/pom.xml index c5087dab..deafa950 100644 --- a/ftests/jung/pom.xml +++ b/ftests/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.15.0 + 0.16.0-SNAPSHOT atlas-ftests-jung diff --git a/ftests/neo4j/pom.xml b/ftests/neo4j/pom.xml index 9c524cae..f23d3b4a 100644 --- a/ftests/neo4j/pom.xml +++ b/ftests/neo4j/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.15.0 + 0.16.0-SNAPSHOT atlas-ftests-neo4j diff --git a/ftests/pom.xml b/ftests/pom.xml index 0771356e..5581feca 100644 --- a/ftests/pom.xml +++ b/ftests/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.0 + 0.16.0-SNAPSHOT atlas-ftests-parent diff --git a/identities/pom.xml b/identities/pom.xml index 3553034c..b1758666 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.0 + 0.16.0-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index 3086d72f..7d61ab46 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.0 + 0.16.0-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - atlas-parent-0.15.0 + HEAD @@ -48,37 +48,37 @@ org.commonjava.maven.atlas atlas-identities - 0.15.0 + 0.16.0-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.15.0 + 0.16.0-SNAPSHOT org.commonjava.maven.atlas atlas-bindings-jackson-identities - 0.15.0 + 0.16.0-SNAPSHOT org.commonjava.maven.atlas atlas-bindings-jackson-relationships - 0.15.0 + 0.16.0-SNAPSHOT org.commonjava.maven.atlas atlas-driver-jung - 0.15.0 + 0.16.0-SNAPSHOT org.commonjava.maven.atlas atlas-driver-neo4j-embedded - 0.15.0 + 0.16.0-SNAPSHOT org.commonjava.maven.atlas atlas-drivers-tck - 0.15.0 + 0.16.0-SNAPSHOT test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index f0db9315..367cc5c2 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.0 + 0.16.0-SNAPSHOT atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 43a2cab0..bae330f3 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.0 + 0.16.0-SNAPSHOT atlas-drivers-tck From 005ed8fd2ab61306a87703580b67bdb9a15e5924 Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 14 Sep 2015 15:22:58 -0500 Subject: [PATCH 105/240] use linked hashmap when accumulating traversed artifacts in order to arrive at a predictable order. --- .../atlas/graph/traverse/TransitiveDependencyTraversal.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java index 6fa6b0b1..6749eb71 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java @@ -35,7 +35,7 @@ public class TransitiveDependencyTraversal private final Logger logger = LoggerFactory.getLogger( getClass() ); - private final Map artifacts = new HashMap(); + private final Map artifacts = new LinkedHashMap(); private final Map seenArtifacts = new HashMap(); From 97fc9dbc71a26aecbd7b06ecc30eedfb47e91f70 Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 17 Sep 2015 14:48:23 -0500 Subject: [PATCH 106/240] Use StringUtils.isEmpty() instead of null check for versionString in SimpleProjectVersionRef. --- .../maven/atlas/ident/ref/SimpleProjectVersionRef.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java index fea63991..a0010020 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java @@ -15,6 +15,7 @@ */ package org.commonjava.maven.atlas.ident.ref; +import org.apache.commons.lang.StringUtils; import org.commonjava.maven.atlas.ident.util.VersionUtils; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; import org.commonjava.maven.atlas.ident.version.SingleVersion; @@ -57,10 +58,10 @@ public SimpleProjectVersionRef( final ProjectRef ref, final String versionSpec ) final String versionString ) { super( groupId, artifactId ); - if ( versionSpec == null && versionString == null ) + if ( versionSpec == null && StringUtils.isEmpty( versionString ) ) { - throw new InvalidRefException( "Version spec AND string cannot both be null for '" + groupId + ":" - + artifactId + "'" ); + throw new InvalidRefException( + "Version spec AND string cannot both be null for '" + groupId + ":" + artifactId + "'" ); } this.versionString = versionString; From 920d2eacf30fed8b40b13f3a18cc03ddd6041c7f Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 17 Sep 2015 15:00:22 -0500 Subject: [PATCH 107/240] reformat --- .../maven/atlas/ident/ref/SimpleProjectVersionRef.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java index a0010020..ef2cc955 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java @@ -61,7 +61,7 @@ public SimpleProjectVersionRef( final ProjectRef ref, final String versionSpec ) if ( versionSpec == null && StringUtils.isEmpty( versionString ) ) { throw new InvalidRefException( - "Version spec AND string cannot both be null for '" + groupId + ":" + artifactId + "'" ); + "Version spec AND string cannot both be empty for '" + groupId + ":" + artifactId + "'" ); } this.versionString = versionString; From 7ff1a934a0feb6a57f271da177f71f459fe6741d Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 18 Sep 2015 09:51:11 -0500 Subject: [PATCH 108/240] [Fixes #44] Check that directory exists before trying to send back a listing. --- .../spi/neo4j/FileNeo4jConnectionFactory.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java index 5c7e3374..f7183cd1 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java @@ -26,6 +26,7 @@ import java.io.File; import java.io.IOException; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -99,7 +100,18 @@ else if ( !db.mkdirs() ) @Override public Set listWorkspaces() { - return new HashSet( Arrays.asList( dbBaseDirectory.list() ) ); + if( !dbBaseDirectory.exists() ) + { + return Collections.emptySet(); + } + + String[] listing = dbBaseDirectory.list(); + if ( listing == null ) + { + return Collections.emptySet(); + } + + return new HashSet( Arrays.asList( listing ) ); } @Override From b0a5701a297ca7619b75432fa00b00db1ea38dcd Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 21 Sep 2015 17:27:23 -0500 Subject: [PATCH 109/240] Implement detach() for neo-specific identities and relationships to permit converting to non-db-backed instances when calculations are complete. --- .../spi/neo4j/FileNeo4JGraphConnection.java | 112 ++++++--------- .../atlas/graph/spi/neo4j/NodeToString.java | 8 +- .../atlas/graph/spi/neo4j/PathComparator.java | 3 - .../atlas/graph/spi/neo4j/RelToString.java | 9 +- .../graph/spi/neo4j/io/ConversionCache.java | 130 ------------------ .../atlas/graph/spi/neo4j/io/Conversions.java | 122 ++++++++-------- .../model/AbstractNeoProjectRelationship.java | 2 + .../graph/spi/neo4j/model/NeoArtifactRef.java | 11 +- .../spi/neo4j/model/NeoBomRelationship.java | 7 + .../model/NeoDependencyRelationship.java | 7 + .../neo4j/model/NeoExtensionRelationship.java | 7 + .../neo4j/model/NeoParentRelationship.java | 7 + .../NeoPluginDependencyRelationship.java | 7 + .../neo4j/model/NeoPluginRelationship.java | 7 + .../graph/spi/neo4j/model/NeoProjectRef.java | 9 +- .../spi/neo4j/model/NeoProjectVersionRef.java | 10 +- .../spi/neo4j/model/NeoTypeAndClassifier.java | 6 + .../model/NeoVersionlessArtifactRef.java | 11 +- .../traverse/AbstractTraverseVisitor.java | 13 -- .../spi/neo4j/traverse/AtlasCollector.java | 19 +-- .../MembershipWrappedTraversalEvaluator.java | 30 ++-- .../neo4j/traverse/PathCollectingVisitor.java | 12 +- .../traverse/RootedRelationshipsVisitor.java | 2 +- .../spi/neo4j/traverse/TraversalUtils.java | 9 +- .../spi/neo4j/update/CycleCacheUpdater.java | 16 +-- .../graph/spi/neo4j/update/ViewUpdater.java | 13 +- .../atlas/ident/ref/SimpleArtifactRef.java | 7 + .../atlas/ident/ref/SimpleProjectRef.java | 6 + .../ident/ref/SimpleProjectVersionRef.java | 7 + .../ident/ref/SimpleTypeAndClassifier.java | 6 + .../ref/SimpleVersionlessArtifactRef.java | 7 + .../AbstractSimpleProjectRelationship.java | 14 ++ .../graph/rel/SimpleBomRelationship.java | 12 ++ .../rel/SimpleDependencyRelationship.java | 13 ++ .../rel/SimpleExtensionRelationship.java | 12 ++ .../graph/rel/SimpleParentRelationship.java | 12 ++ .../SimplePluginDependencyRelationship.java | 13 ++ .../graph/rel/SimplePluginRelationship.java | 13 ++ 38 files changed, 346 insertions(+), 365 deletions(-) delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/ConversionCache.java diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java index 9c448485..39e2d027 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java @@ -23,11 +23,11 @@ import org.commonjava.maven.atlas.graph.rel.*; import org.commonjava.maven.atlas.graph.rel.RelationshipType; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.ConversionCache; import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; import org.commonjava.maven.atlas.graph.spi.neo4j.model.AbstractNeoProjectRelationship; import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoProjectVersionRef; import org.commonjava.maven.atlas.graph.spi.neo4j.traverse.*; import org.commonjava.maven.atlas.graph.spi.neo4j.update.CycleCacheUpdater; import org.commonjava.maven.atlas.graph.spi.neo4j.update.ViewUpdater; @@ -243,7 +243,7 @@ public void printStats() { final Node node = hits.next(); final Iterable relationships = node.getRelationships( Direction.OUTGOING ); - return convertToRelationships( relationships, new ConversionCache() ); + return convertToRelationships( relationships ); } return null; @@ -263,7 +263,6 @@ private synchronized void checkClosed() { checkClosed(); - final ConversionCache cache = new ConversionCache(); if ( registerView( params ) ) { final Node node = getNode( ref ); @@ -288,7 +287,7 @@ private synchronized void checkClosed() while ( hits.hasNext() ) { final Relationship r = hits.next(); - final ProjectRelationship rel = toProjectRelationship( r, cache ); + final ProjectRelationship rel = toProjectRelationship( r ); result.add( rel ); } @@ -305,7 +304,7 @@ private synchronized void checkClosed() final Node node = hits.next(); // FIXME: What if this params has a filter or mutator?? Without a root, that would be very strange... final Iterable relationships = node.getRelationships( Direction.INCOMING ); - return convertToRelationships( relationships, cache ); + return convertToRelationships( relationships ); } return null; @@ -316,29 +315,28 @@ public Set getAllProjects( final ViewParams params ) { checkClosed(); + logger.debug( "Getting all-projects for: {}", params ); - final ConversionCache cache = new ConversionCache(); if ( registerView( params ) ) { final Index cachedNodes = new ViewIndexes( graph.index(), params ).getCachedNodes(); - final IndexHits nodeHits = cachedNodes.query( NID, "*" ); final Set nodes = new HashSet(); + final IndexHits nodeHits = cachedNodes.query( NID, "*" ); while ( nodeHits.hasNext() ) { - nodes.add( toProjectVersionRef( nodeHits.next(), cache ) ); + nodes.add( toProjectVersionRef( nodeHits.next() ).detach() ); } return nodes; } // FIXME: What if this params has a filter or mutator?? Without a root, that would be very strange... - return new HashSet( convertToProjects( graph.index() - .forNodes( BY_GAV_IDX ) - .query( GAV, "*" ), cache ) ); + return new HashSet( + convertToDetachedProjects( graph.index().forNodes( BY_GAV_IDX ).query( GAV, "*" ) ) ); } - private void updateView( final ViewParams params, final ConversionCache cache ) + private void updateView( final ViewParams params ) { if ( params.getRoots() == null || params.getRoots() .isEmpty() ) @@ -362,7 +360,7 @@ private void updateView( final ViewParams params, final ConversionCache cache ) return; } - final ViewUpdater updater = new ViewUpdater( params, paramsNode, indexes, cache, adminAccess ); + final ViewUpdater updater = new ViewUpdater( params, paramsNode, indexes, adminAccess ); collectAtlasRelationships( params, updater, roots, false, Uniqueness.RELATIONSHIP_GLOBAL ); logger.debug( "Traverse complete for update of params: {}", params.getShortId() ); @@ -378,7 +376,6 @@ private void updateView( final ViewParams params, final ConversionCache cache ) { checkClosed(); - final ConversionCache cache = new ConversionCache(); if ( registerView( params ) ) { final RelationshipIndex cachedRels = new ViewIndexes( graph.index(), params ).getCachedRelationships(); @@ -387,7 +384,7 @@ private void updateView( final ViewParams params, final ConversionCache cache ) final Set> rels = new HashSet>(); while ( relHits.hasNext() ) { - rels.add( toProjectRelationship( relHits.next(), cache ) ); + rels.add( toProjectRelationship( relHits.next() ).detach() ); } return rels; @@ -398,7 +395,7 @@ private void updateView( final ViewParams params, final ConversionCache cache ) .query( RELATIONSHIP_ID, "*" ); synchronized ( hits ) { - return convertToRelationships( hits, cache ); + return convertToDetachedRelationships( hits ); } } @@ -415,8 +412,7 @@ public Map, GraphPathInfo> getPathMapTargeting( final ViewParams pa final Set endNodes = getNodes( refs ); - final ConversionCache cache = new ConversionCache(); - final PathCollectingVisitor visitor = new PathCollectingVisitor( endNodes, cache ); + final PathCollectingVisitor visitor = new PathCollectingVisitor( endNodes ); collectAtlasRelationships( params, visitor, getRoots( params ), false, Uniqueness.RELATIONSHIP_GLOBAL ); final Map, GraphPathInfo> result = new HashMap, GraphPathInfo>(); @@ -426,7 +422,7 @@ public Map, GraphPathInfo> getPathMapTargeting( final ViewParams pa for ( final Long rid : path ) { final Relationship r = graph.getRelationshipById( rid ); - info = info.getChildPathInfo( toProjectRelationship( r, cache ) ); + info = info.getChildPathInfo( toProjectRelationship( r ) ); } result.put( path, info ); @@ -459,7 +455,7 @@ public ProjectVersionRef getPathTargetRef( final GraphPath path ) final Relationship rel = graph.getRelationshipById( rid ); final Node target = rel.getEndNode(); - return toProjectVersionRef( target, null ); + return toProjectVersionRef( target ); } @Override @@ -474,14 +470,13 @@ public ProjectVersionRef getPathTargetRef( final GraphPath path ) final Set endNodes = getNodes( refs ); - final ConversionCache cache = new ConversionCache(); - final PathCollectingVisitor visitor = new PathCollectingVisitor( endNodes, cache ); + final PathCollectingVisitor visitor = new PathCollectingVisitor( endNodes ); collectAtlasRelationships( params, visitor, getRoots( params ), false, Uniqueness.RELATIONSHIP_GLOBAL ); final Set>> result = new HashSet>>(); for ( final Neo4jGraphPath path : visitor ) { - result.add( convertToRelationships( path, adminAccess, cache ) ); + result.add( convertToDetachedRelationships( path, adminAccess ) ); } return result; @@ -509,7 +504,6 @@ public ProjectVersionRef getPathTargetRef( final GraphPath path ) { checkClosed(); - final ConversionCache cache = new ConversionCache(); final Map> createdRelationshipsMap = new HashMap>(); final List> sorted = new ArrayList>( Arrays.asList( rels ) ); @@ -530,15 +524,14 @@ public ProjectVersionRef getPathTargetRef( final GraphPath path ) List> batch = sorted.subList( processed, upper ); logger.info( "\n\n\nInserting relationship batch of size: {}\n\n\n\n", batch.size() ); - insertRelationshipBatch( batch, cache, createdRelationshipsMap ); + insertRelationshipBatch( batch, createdRelationshipsMap ); processed += batch.size(); } return createdRelationshipsMap; } - private void insertRelationshipBatch( List> rels, ConversionCache cache, - Map> createdRelationshipsMap ) + private void insertRelationshipBatch( List> rels, Map> createdRelationshipsMap ) { final Transaction tx = graph.beginTx(); try @@ -664,7 +657,7 @@ private void insertRelationshipBatch( List> rels, Conv } else { - logger.debug( "== {} ({})", relationship, new RelToString( relationship, cache ) ); + logger.debug( "== {} ({})", relationship, new RelToString( relationship ) ); addToURISetProperty( rel.getSources(), SOURCE_URI, relationship ); } @@ -762,7 +755,7 @@ private Relationship select( final Relationship old, final ViewParams params, fi return graph.getRelationshipById( targetRid ); } - final ProjectRelationship oldRel = toProjectRelationship( old, null ); + final ProjectRelationship oldRel = toProjectRelationship( old ); if ( oldRel == null ) { return null; @@ -880,8 +873,6 @@ public void traverse( final RelationshipGraphTraversal traversal, final ProjectV // logger.debug( "starting traverse of: {}", net ); traversal.startTraverse( graph ); - final ConversionCache cache = new ConversionCache(); - final Node paramsNode = getViewNode( params ); @SuppressWarnings( { "rawtypes", "unchecked" } ) @@ -889,8 +880,6 @@ public void traverse( final RelationshipGraphTraversal traversal, final ProjectV new MembershipWrappedTraversalEvaluator( Collections.singleton( rootNode.getId() ), traversal, this, params, paramsNode, adminAccess, relTypes ); - checker.setConversionCache( cache ); - description = description.expand( checker ) .evaluator( checker ); @@ -905,7 +894,9 @@ public void traverse( final RelationshipGraphTraversal traversal, final ProjectV continue; } - final List> rels = convertToRelationships( path.relationships(), cache ); + final List> rels = new ArrayList>(path.length()); + rels.addAll( convertToRelationships( path.relationships() ) ); + logger.debug( "traversing path: {}", rels ); for ( final ProjectRelationship rel : rels ) { @@ -1159,7 +1150,6 @@ private Set getIndexedProjects( final ViewParams params, fina final Set result = new HashSet(); - final ConversionCache cache = new ConversionCache(); if ( registerView( params ) ) { final Index cachedNodes = new ViewIndexes( graph.index(), params ).getCachedNodes(); @@ -1171,7 +1161,7 @@ private Set getIndexedProjects( final ViewParams params, fina if ( cacheHits.hasNext() ) { logger.debug( "Including: {}", node ); - result.add( toProjectVersionRef( node, cache ) ); + result.add( toProjectVersionRef( node ) ); } } } @@ -1180,7 +1170,7 @@ private Set getIndexedProjects( final ViewParams params, fina for ( final Node node : hits ) { logger.debug( "Including: {}", node ); - result.add( toProjectVersionRef( node, cache ) ); + result.add( toProjectVersionRef( node ) ); } } @@ -1343,8 +1333,6 @@ public Set getCycles( final ViewParams params ) return null; } - final ConversionCache cache = new ConversionCache(); - final Transaction tx = graph.beginTx(); Node paramsNode; try @@ -1370,7 +1358,7 @@ public Set getCycles( final ViewParams params ) // } logger.info( "Traversing graph to find cycles for params {}", params.getShortId() ); - final CycleCacheUpdater cycleUpdater = new CycleCacheUpdater( params, paramsNode, adminAccess, cache ); + final CycleCacheUpdater cycleUpdater = new CycleCacheUpdater( params, paramsNode, adminAccess ); // NOTE: Changing this means some cases of morphing filters/mutators may NOT report correct results. // collectAtlasRelationships( params, cycleUpdater, nodes, false, global ? Uniqueness.RELATIONSHIP_GLOBAL : Uniqueness.RELATIONSHIP_PATH ); collectAtlasRelationships( params, cycleUpdater, nodes, false, Uniqueness.RELATIONSHIP_GLOBAL ); @@ -1409,12 +1397,8 @@ public Set getCycles( final ViewParams params ) final List> cycle = new ArrayList>( cyclicPath.length() + 1 ); for ( final long id : cyclicPath.getRelationshipIds() ) { - ProjectRelationship rel = cache.getRelationship( id ); - if ( rel == null ) - { - final Relationship r = graph.getRelationshipById( id ); - rel = toProjectRelationship( r, cache ); - } + final Relationship r = graph.getRelationshipById( id ); + ProjectRelationship rel = toProjectRelationship( r ); cycle.add( rel ); } @@ -1706,7 +1690,6 @@ public Set getProjectsWithMetadata( final ViewParams params, .forNodes( METADATA_INDEX_PREFIX + key ) .query( GAV, "*" ); - final ConversionCache cache = new ConversionCache(); if ( registerView( params ) ) { final Index cachedNodes = new ViewIndexes( graph.index(), params ).getCachedNodes(); @@ -1717,7 +1700,7 @@ public Set getProjectsWithMetadata( final ViewParams params, if ( cachedNodes.get( NID, node.getId() ) .hasNext() ) { - result.add( toProjectVersionRef( node, cache ) ); + result.add( toProjectVersionRef( node ) ); } } @@ -1725,7 +1708,7 @@ public Set getProjectsWithMetadata( final ViewParams params, } else { - return new HashSet( convertToProjects( nodes, cache ) ); + return new HashSet( convertToProjects( nodes ) ); } } @@ -1793,12 +1776,11 @@ public void addDisconnectedProject( final ProjectVersionRef ref ) { final Set> result = new HashSet>(); - final ConversionCache cache = new ConversionCache(); for ( final Relationship r : relationships ) { - if ( TraversalUtils.acceptedInView( r, params, cache ) ) + if ( TraversalUtils.acceptedInView( r, params ) ) { - final ProjectRelationship rel = toProjectRelationship( r, cache ); + final ProjectRelationship rel = toProjectRelationship( r ); if ( rel != null ) { result.add( rel ); @@ -1853,16 +1835,15 @@ public void addDisconnectedProject( final ProjectVersionRef ref ) final Iterable relationships = node.getRelationships( Direction.INCOMING, grts.toArray( new GraphRelType[grts.size()] ) ); - final ConversionCache cache = new ConversionCache(); if ( relationships != null ) { final Set> result = new HashSet>(); for ( final Relationship r : relationships ) { logger.debug( "Examining relationship: {}", r ); - if ( TraversalUtils.acceptedInView( r, params, cache ) ) + if ( TraversalUtils.acceptedInView( r, params ) ) { - final ProjectRelationship rel = toProjectRelationship( r, cache ); + final ProjectRelationship rel = toProjectRelationship( r ); if ( rel != null ) { result.add( rel ); @@ -1883,7 +1864,7 @@ public Set getProjectsMatching( final ViewParams params, fina .forNodes( BY_GA_IDX ) .query( GA, projectRef.asProjectRef() .toString() ); - return new HashSet( convertToProjects( hits, new ConversionCache() ) ); + return new HashSet( convertToProjects( hits ) ); } @Override @@ -1955,7 +1936,6 @@ public ProjectVersionRef getManagedTargetFor( final ProjectVersionRef target, fi // logger.info( "Searching for managed override of: {} in: {}", target, path ); final Neo4jGraphPath neopath = (Neo4jGraphPath) path; - final ConversionCache cache = new ConversionCache(); for ( final Long id : neopath ) { final Relationship r = graph.getRelationshipById( id ); @@ -1970,9 +1950,9 @@ public ProjectVersionRef getManagedTargetFor( final ProjectVersionRef target, fi if ( hits != null && hits.hasNext() ) { final Relationship hit = hits.next(); - final ProjectVersionRef ref = toProjectVersionRef( hit.getEndNode(), cache ); + final ProjectVersionRef ref = toProjectVersionRef( hit.getEndNode() ); - logger.debug( "[MUTATION] {} => {} (via: {})", target, ref, new RelToString( hit, cache ) ); + logger.debug( "[MUTATION] {} => {} (via: {})", target, ref, new RelToString( hit ) ); return ref; } @@ -2006,10 +1986,8 @@ public List getPathRefs( final ViewParams params, final Graph + ". This is not a Neo4jGraphPathKey instance!" ); } - final ConversionCache cache = new ConversionCache(); - final Neo4jGraphPath gp = (Neo4jGraphPath) path; - final List> rels = convertToRelationships( gp, adminAccess, cache ); + final List> rels = convertToRelationships( gp, adminAccess ); final List refs = new ArrayList( rels.size() + 2 ); for ( final ProjectRelationship rel : rels ) { @@ -2025,7 +2003,7 @@ public List getPathRefs( final ViewParams params, final Graph if ( refs.isEmpty() ) { final Node node = graph.getNodeById( gp.getStartNodeId() ); - final ProjectVersionRef ref = toProjectVersionRef( node, cache ); + final ProjectVersionRef ref = toProjectVersionRef( node ); if ( ref != null ) { refs.add( ref ); @@ -2119,7 +2097,7 @@ public boolean registerView( final ViewParams params ) return false; } - updateView( params, new ConversionCache() ); + updateView( params ); return true; } @@ -2296,8 +2274,6 @@ private void updateCaches( final Map> newRelatio final IndexHits hits = confIdx.query( VIEW_ID, "*" ); - final ConversionCache cache = new ConversionCache(); - Transaction tx = graph.beginTx(); try { @@ -2313,7 +2289,7 @@ private void updateCaches( final Map> newRelatio for ( final Node paramsNode : hits ) { - final ViewParams params = Conversions.retrieveView( paramsNode, cache, adminAccess ); + final ViewParams params = Conversions.retrieveView( paramsNode, adminAccess ); logger.debug( "Updating params: {} ({})", params.getShortId(), paramsNode ); // if ( params == null || params.getShortId() @@ -2342,7 +2318,7 @@ private void updateCaches( final Map> newRelatio } final ViewIndexes vi = new ViewIndexes( graph.index(), params ); - final ViewUpdater vu = new ViewUpdater( params, paramsNode, vi, cache, adminAccess ); + final ViewUpdater vu = new ViewUpdater( params, paramsNode, vi, adminAccess ); vu.cacheRoots( getRoots( params, false ) ); if ( vu.processAddedRelationships( newRelationships ) ) { diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeToString.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeToString.java index 9877c85e..eeba6ba8 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeToString.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeToString.java @@ -15,7 +15,6 @@ */ package org.commonjava.maven.atlas.graph.spi.neo4j; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.ConversionCache; import org.neo4j.graphdb.Node; import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.toProjectVersionRef; @@ -27,16 +26,13 @@ public class NodeToString { private final Node node; - private final ConversionCache cache; - - public NodeToString( Node node, ConversionCache cache ) + public NodeToString( Node node ) { this.node = node; - this.cache = cache; } public String toString() { - return toProjectVersionRef( node, cache ).toString(); + return toProjectVersionRef( node ).toString(); } } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java index 9661cd6b..08aa6643 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java @@ -16,7 +16,6 @@ package org.commonjava.maven.atlas.graph.spi.neo4j; import org.commonjava.maven.atlas.graph.rel.RelationshipPathComparator; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.ConversionCache; import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; import org.neo4j.graphdb.Path; import org.neo4j.graphdb.Relationship; @@ -34,8 +33,6 @@ public final class PathComparator private final RelationshipPathComparator pathComparator = RelationshipPathComparator.INSTANCE; - private final ConversionCache cache = new ConversionCache(); - private PathComparator() { } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelToString.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelToString.java index ac915c14..cf4253c2 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelToString.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelToString.java @@ -15,8 +15,6 @@ */ package org.commonjava.maven.atlas.graph.spi.neo4j; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.ConversionCache; import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; import org.neo4j.graphdb.Relationship; @@ -27,16 +25,13 @@ public class RelToString { private Relationship rel; - private final ConversionCache cache; - - public RelToString( Relationship rel, ConversionCache cache ) + public RelToString( Relationship rel ) { this.rel = rel; - this.cache = cache; } public String toString() { - return Conversions.toProjectRelationship( rel, cache ).toString(); + return Conversions.toProjectRelationship( rel ).toString(); } } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/ConversionCache.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/ConversionCache.java deleted file mode 100644 index 0e1c1729..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/ConversionCache.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.io; - -import org.apache.commons.codec.digest.DigestUtils; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Relationship; - -import java.lang.ref.WeakReference; -import java.util.HashMap; -import java.util.Map; - -public class ConversionCache -{ - - private Map>> relationships; - - private Map> gavs; - - private Map> serializedObjects; - - public ProjectRelationship getRelationship( final Relationship rel ) - { - return getRelationship( rel.getId() ); - } - - public ProjectRelationship getRelationship( final long rid ) - { - if ( relationships == null ) - { - return null; - } - - final WeakReference> reference = relationships.get( rid ); - if ( reference == null ) - { - return null; - } - - return reference.get(); - } - - public void cache( final Relationship rel, final ProjectRelationship r ) - { - if ( relationships == null ) - { - relationships = new HashMap>>(); - } - - relationships.put( rel.getId(), new WeakReference>( r ) ); - } - - public ProjectVersionRef getProjectVersionRef( final Node node ) - { - return getProjectVersionRef( node.getId() ); - } - - public ProjectVersionRef getProjectVersionRef( final long nid ) - { - if ( gavs == null ) - { - return null; - } - - final WeakReference reference = gavs.get( nid ); - if ( reference == null ) - { - return null; - } - - return reference.get(); - } - - public void cache( final Node node, final ProjectVersionRef ref ) - { - if ( gavs == null ) - { - gavs = new HashMap>(); - } - - gavs.put( node.getId(), new WeakReference( ref ) ); - } - - public T getSerializedObject( final byte[] data, final Class type ) - { - if ( serializedObjects != null ) - { - final String key = DigestUtils.shaHex( data ); - final WeakReference reference = serializedObjects.get( key ); - if ( reference == null ) - { - return null; - } - - final Object value = reference.get(); - if ( value != null ) - { - return type.cast( value ); - } - } - - return null; - } - - public void cache( final byte[] data, final Object value ) - { - if ( serializedObjects == null ) - { - serializedObjects = new HashMap>(); - } - - final String key = DigestUtils.shaHex( data ); - serializedObjects.put( key, new WeakReference( value ) ); - } -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java index a5ce92bc..702ed05a 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java @@ -30,6 +30,7 @@ import org.commonjava.maven.atlas.graph.spi.neo4j.GraphAdmin; import org.commonjava.maven.atlas.graph.spi.neo4j.GraphRelType; import org.commonjava.maven.atlas.graph.spi.neo4j.NodeType; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.AbstractNeoProjectRelationship; import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoArtifactRef; import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoBomRelationship; @@ -185,7 +186,7 @@ public static int countArrayElements( final String property, final PropertyConta return 1; } - public static List convertToProjects( final Iterable nodes, final ConversionCache cache ) + public static List convertToDetachedProjects( final Iterable nodes ) { final List refs = new ArrayList(); for ( final Node node : nodes ) @@ -200,19 +201,54 @@ public static List convertToProjects( final Iterable no continue; } - refs.add( Conversions.toProjectVersionRef( node, cache ) ); + refs.add( Conversions.toProjectVersionRef( node ).detach() ); } return refs; } - public static List> convertToRelationships( final Iterable relationships, - final ConversionCache cache ) + public static List convertToProjects( final Iterable nodes ) + { + final List refs = new ArrayList(); + for ( final Node node : nodes ) + { + if ( node.getId() == 0 ) + { + continue; + } + + if ( !Conversions.isType( node, NodeType.PROJECT ) ) + { + continue; + } + + refs.add( Conversions.toProjectVersionRef( node ) ); + } + + return refs; + } + + public static List> convertToDetachedRelationships( Iterable relationships ) { final List> rels = new ArrayList>(); for ( final Relationship relationship : relationships ) { - final ProjectRelationship rel = Conversions.toProjectRelationship( relationship, cache ); + final AbstractNeoProjectRelationship rel = Conversions.toProjectRelationship( relationship ); + if ( rel != null ) + { + rels.add( rel.detach() ); + } + } + + return rels; + } + + public static List> convertToRelationships( final Iterable relationships ) + { + final List> rels = new ArrayList>(); + for ( final Relationship relationship : relationships ) + { + final AbstractNeoProjectRelationship rel = Conversions.toProjectRelationship( relationship ); if ( rel != null ) { rels.add( rel ); @@ -222,15 +258,31 @@ public static List convertToProjects( final Iterable no return rels; } - public static List> convertToRelationships( final Iterable relationships, - final GraphAdmin admin, - final ConversionCache cache ) + public static List> convertToDetachedRelationships( final Iterable relationships, + final GraphAdmin admin ) { final List> rels = new ArrayList>(); for ( final Long rid : relationships ) { final Relationship relationship = admin.getRelationship( rid ); - final ProjectRelationship rel = Conversions.toProjectRelationship( relationship, cache ); + final ProjectRelationship rel = toProjectRelationship( relationship ).detach(); + if ( rel != null ) + { + rels.add( rel ); + } + } + + return rels; + } + + public static List> convertToRelationships( final Iterable relationships, + final GraphAdmin admin ) + { + final List> rels = new ArrayList>(); + for ( final Long rid : relationships ) + { + final Relationship relationship = admin.getRelationship( rid ); + final AbstractNeoProjectRelationship rel = toProjectRelationship( relationship ); if ( rel != null ) { rels.add( rel ); @@ -295,33 +347,19 @@ public static boolean isType( final Node node, final NodeType type ) // return toProjectVersionRef( node, null ); // } - public static ProjectVersionRef toProjectVersionRef( final Node node, final ConversionCache cache ) + public static NeoProjectVersionRef toProjectVersionRef( final Node node ) { if ( node == null ) { return null; } - if ( cache != null ) - { - final ProjectVersionRef ref = cache.getProjectVersionRef( node ); - if ( ref != null ) - { - return ref; - } - } - if ( !isType( node, NodeType.PROJECT ) ) { throw new IllegalArgumentException( "Node " + node.getId() + " is not a project reference." ); } - final ProjectVersionRef result = new NeoProjectVersionRef( node ); - if ( cache != null ) - { - cache.cache( node, result ); - } - + final NeoProjectVersionRef result = new NeoProjectVersionRef( node ); return result; } @@ -414,22 +452,13 @@ public static String[] toStringArray( final Collection sources ) // return toProjectRelationship( rel, null ); // } - public static ProjectRelationship toProjectRelationship( final Relationship rel, final ConversionCache cache ) + public static AbstractNeoProjectRelationship toProjectRelationship( final Relationship rel ) { if ( rel == null ) { return null; } - if ( cache != null ) - { - final ProjectRelationship r = cache.getRelationship( rel ); - if ( r != null ) - { - return r; - } - } - final GraphRelType mapper = GraphRelType.valueOf( rel.getType().name() ); // LOGGER.debug( "Converting relationship of type: {} (atlas type: {})", mapper, @@ -446,7 +475,7 @@ public static String[] toStringArray( final Collection sources ) return null; } - ProjectRelationship result = null; + AbstractNeoProjectRelationship result = null; switch ( mapper.atlasType() ) { case DEPENDENCY: @@ -486,11 +515,6 @@ public static String[] toStringArray( final Collection sources ) } } - if ( result != null && cache != null ) - { - cache.cache( rel, result ); - } - // LOGGER.debug( "Returning project relationship: {}", result ); return result; } @@ -1010,7 +1034,7 @@ public static void storeView( final ViewParams params, final Node viewNode ) // return retrieveView( viewNode, null, driver ); // } - public static ViewParams retrieveView( final Node viewNode, final ConversionCache cache, final GraphAdmin maint ) + public static ViewParams retrieveView( final Node viewNode, final GraphAdmin maint ) { if ( !viewNode.hasProperty( VIEW_DATA ) ) { @@ -1019,26 +1043,12 @@ public static ViewParams retrieveView( final Node viewNode, final ConversionCach final byte[] data = (byte[]) viewNode.getProperty( VIEW_DATA ); - if ( cache != null ) - { - final ViewParams view = cache.getSerializedObject( data, ViewParams.class ); - if ( view != null ) - { - return view; - } - } - ObjectInputStream ois = null; try { ois = new ObjectInputStream( new ByteArrayInputStream( data ) ); final ViewParams view = (ViewParams) ois.readObject(); - if ( cache != null ) - { - cache.cache( data, view ); - } - return view; } catch ( final IOException e ) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java index 94c2132e..ccdc6f41 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java @@ -210,4 +210,6 @@ else if ( !getTarget().equals( other.getTarget() ) ) return getType() == other.getType(); } + public abstract I detach(); + } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java index a87a311c..a120b24b 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java @@ -20,6 +20,7 @@ import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.InvalidRefException; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.TypeAndClassifier; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; import org.commonjava.maven.atlas.ident.version.SingleVersion; @@ -41,8 +42,8 @@ * * @author jdcasey */ -public class NeoArtifactRef - extends NeoProjectVersionRef +public class NeoArtifactRef + extends NeoProjectVersionRef implements Serializable, ArtifactRef { @@ -250,4 +251,10 @@ public boolean isDirty() { return super.isDirty() || optional != null || tc.isDirty(); } + + @Override + public T detach() + { + return (T) new SimpleArtifactRef( this ); + } } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoBomRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoBomRelationship.java index 66b8ba8a..b9e8b993 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoBomRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoBomRelationship.java @@ -18,6 +18,7 @@ import org.commonjava.maven.atlas.graph.rel.AbstractSimpleProjectRelationship; import org.commonjava.maven.atlas.graph.rel.BomRelationship; import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.graph.rel.SimpleBomRelationship; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; import org.neo4j.graphdb.Relationship; @@ -95,4 +96,10 @@ public String toString() { return String.format( "BomRelationship [%s => %s, rel=%d]", getDeclaring(), getTarget(), rel.getId() ); } + + @Override + public BomRelationship detach() + { + return new SimpleBomRelationship( this ); + } } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java index 66e86fd9..71d6fc11 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java @@ -19,6 +19,7 @@ import org.commonjava.maven.atlas.graph.rel.BomRelationship; import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; import org.commonjava.maven.atlas.ident.DependencyScope; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; @@ -87,6 +88,12 @@ public boolean equals( final Object obj ) return isManaged() == other.isManaged(); } + @Override + public DependencyRelationship detach() + { + return new SimpleDependencyRelationship( this ); + } + @Override public String toString() { diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoExtensionRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoExtensionRelationship.java index 4afc51dd..2ae012f5 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoExtensionRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoExtensionRelationship.java @@ -19,6 +19,7 @@ import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.graph.rel.SimpleExtensionRelationship; import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; @@ -60,6 +61,12 @@ public ArtifactRef getTargetArtifact() return getTarget().asJarArtifact(); } + @Override + public ExtensionRelationship detach() + { + return new SimpleExtensionRelationship( this ); + } + @Override public ExtensionRelationship selectDeclaring( final ProjectVersionRef ref ) { diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoParentRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoParentRelationship.java index 8a590030..9a8af8e4 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoParentRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoParentRelationship.java @@ -19,6 +19,7 @@ import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; import org.commonjava.maven.atlas.graph.rel.ParentRelationship; import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; @@ -125,4 +126,10 @@ public Set getSources() Collections.singleton( RelationshipUtils.TERMINAL_PARENT_SOURCE_URI ) : super.getSources(); } + + @Override + public ParentRelationship detach() + { + return new SimpleParentRelationship( this ); + } } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java index a59266ac..2819c535 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java @@ -19,6 +19,7 @@ import org.commonjava.maven.atlas.graph.rel.ParentRelationship; import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.graph.rel.SimplePluginDependencyRelationship; import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectRef; @@ -93,6 +94,12 @@ else if ( !getPlugin().equals( other.getPlugin() ) ) return true; } + @Override + public PluginDependencyRelationship detach() + { + return new SimplePluginDependencyRelationship( this ); + } + @Override public String toString() { diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java index 72f10b71..5ff0b608 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java @@ -19,6 +19,7 @@ import org.commonjava.maven.atlas.graph.rel.ParentRelationship; import org.commonjava.maven.atlas.graph.rel.PluginRelationship; import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; @@ -76,6 +77,12 @@ public boolean equals( final Object obj ) return isManaged() == other.isManaged(); } + @Override + public PluginRelationship detach() + { + return new SimplePluginRelationship( this ); + } + @Override public String toString() { diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java index fd79fe53..d97e5681 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java @@ -19,6 +19,8 @@ import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; import org.commonjava.maven.atlas.ident.ref.InvalidRefException; import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; import org.commonjava.maven.atlas.ident.ref.TypeAndClassifier; import org.commonjava.maven.atlas.ident.ref.VersionlessArtifactRef; import org.neo4j.graphdb.Node; @@ -34,7 +36,7 @@ * * @author jdcasey */ -public class NeoProjectRef +public class NeoProjectRef implements ProjectRef { @@ -253,4 +255,9 @@ public boolean isDirty() { return groupId != null || artifactId != null; } + + public T detach() + { + return (T) new SimpleProjectRef( this ); + } } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java index a1291fdf..5b020f52 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java @@ -34,8 +34,8 @@ * * @author jdcasey */ -public class NeoProjectVersionRef - extends NeoProjectRef +public class NeoProjectVersionRef + extends NeoProjectRef implements ProjectVersionRef { @@ -368,4 +368,10 @@ public boolean isDirty() { return super.isDirty() || versionString != null; } + + @Override + public T detach() + { + return (T) new SimpleProjectVersionRef( this ); + } } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoTypeAndClassifier.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoTypeAndClassifier.java index 0c6b1dc6..aa32cf62 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoTypeAndClassifier.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoTypeAndClassifier.java @@ -16,6 +16,7 @@ package org.commonjava.maven.atlas.graph.spi.neo4j.model; import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; +import org.commonjava.maven.atlas.ident.ref.SimpleTypeAndClassifier; import org.commonjava.maven.atlas.ident.ref.TypeAndClassifier; import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Relationship; @@ -154,4 +155,9 @@ public boolean isDirty() return type != null || classifier != null; } + public TypeAndClassifier detach() + { + return new SimpleTypeAndClassifier( this ); + } + } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java index 74bc2841..fcc1103d 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java @@ -18,6 +18,7 @@ import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.InvalidRefException; import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.maven.atlas.ident.ref.SimpleVersionlessArtifactRef; import org.commonjava.maven.atlas.ident.ref.TypeAndClassifier; import org.commonjava.maven.atlas.ident.ref.VersionlessArtifactRef; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; @@ -30,8 +31,8 @@ * * @author jdcasey */ -public class NeoVersionlessArtifactRef - extends NeoProjectRef +public class NeoVersionlessArtifactRef + extends NeoProjectRef implements VersionlessArtifactRef { @@ -234,4 +235,10 @@ public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier return super.asVersionlessArtifactRef( tc, optional ); } + + @Override + public T detach() + { + return (T) new SimpleVersionlessArtifactRef( this ); + } } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AbstractTraverseVisitor.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AbstractTraverseVisitor.java index fb6dadd9..35e7cb27 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AbstractTraverseVisitor.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AbstractTraverseVisitor.java @@ -16,7 +16,6 @@ package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.ConversionCache; import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; import org.neo4j.graphdb.Path; @@ -26,18 +25,6 @@ public abstract class AbstractTraverseVisitor implements TraverseVisitor { - private ConversionCache conversionCache; - - public void setConversionCache( final ConversionCache conversionCache ) - { - this.conversionCache = conversionCache; - } - - public ConversionCache getConversionCache() - { - return conversionCache; - } - @Override public void configure( final AtlasCollector collector ) { diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java index 4624b9c3..94bfd037 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java @@ -15,7 +15,6 @@ */ package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.GAV; import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.toProjectRelationship; import static org.commonjava.maven.atlas.graph.spi.neo4j.traverse.TraversalUtils.accepted; @@ -30,10 +29,8 @@ import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; import org.commonjava.maven.atlas.graph.spi.neo4j.GraphAdmin; import org.commonjava.maven.atlas.graph.spi.neo4j.GraphRelType; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.ConversionCache; import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoProjectVersionRef; import org.commonjava.maven.atlas.graph.spi.neo4j.update.CycleCacheUpdater; import org.commonjava.maven.atlas.ident.util.JoinString; import org.neo4j.graphdb.Direction; @@ -59,8 +56,6 @@ public final class AtlasCollector private ViewParams view; - private ConversionCache cache = new ConversionCache(); - private TraverseVisitor visitor; private GraphAdmin admin; @@ -110,11 +105,6 @@ public void setUseSelections( final boolean useSelections ) this.useSelections = useSelections; } - public void setConversionCache( final ConversionCache cache ) - { - this.cache = cache; - } - @Override @SuppressWarnings( "rawtypes" ) public final Iterable expand( final Path path, final BranchState state ) @@ -142,7 +132,7 @@ public final Iterable expand( final Path path, final BranchState s for ( final Long rid : graphPath ) { final Relationship r = admin.getRelationship( rid ); - pathInfo = pathInfo.getChildPathInfo( toProjectRelationship( r, cache ) ); + pathInfo = pathInfo.getChildPathInfo( toProjectRelationship( r ) ); } logger.debug( "For {}, using pathInfo: {}", graphPath, pathInfo ); @@ -221,7 +211,7 @@ public final Iterable expand( final Path path, final BranchState s continue; } - if ( !accepted( selected, view, cache ) ) + if ( !accepted( selected, view ) ) { logger.debug( "{} NOT accepted, likely due to incompatible POM location or source URI. Path: {}", r, path ); @@ -236,7 +226,7 @@ public final Iterable expand( final Path path, final BranchState s logger.debug( "After selection, using child relationship: {}", r ); } - final ProjectRelationship rel = toProjectRelationship( r, cache ); + final ProjectRelationship rel = toProjectRelationship( r ); final Neo4jGraphPath nextPath = new Neo4jGraphPath( graphPath, r ); final GraphPathInfo nextPathInfo = pathInfo.getChildPathInfo( rel ); @@ -269,7 +259,7 @@ private Object wrap( final Relationship r ) @Override public String toString() { - return r + " " + String.valueOf( toProjectRelationship( r, cache ) ); + return r + " " + String.valueOf( toProjectRelationship( r ) ); } }; } @@ -286,7 +276,6 @@ public PathExpander reverse() final AtlasCollector collector = new AtlasCollector( visitor, startNodes, connection, view, viewNode, admin, types, direction.reverse() ); - collector.setConversionCache( cache ); collector.setUseSelections( useSelections ); return collector; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java index efa14eec..a498bd88 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java @@ -17,6 +17,7 @@ import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.toProjectRelationship; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; @@ -29,7 +30,6 @@ import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; import org.commonjava.maven.atlas.graph.spi.neo4j.GraphAdmin; import org.commonjava.maven.atlas.graph.spi.neo4j.GraphRelType; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.ConversionCache; import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; import org.commonjava.maven.atlas.graph.traverse.RelationshipGraphTraversal; @@ -58,8 +58,6 @@ public class MembershipWrappedTraversalEvaluator private final ViewParams view; - private ConversionCache cache = new ConversionCache(); - private final GraphAdmin admin; private final Node viewNode; @@ -94,11 +92,6 @@ private MembershipWrappedTraversalEvaluator( final MembershipWrappedTraversalEva this.reversedExpander = reversedExpander; } - public void setConversionCache( final ConversionCache cache ) - { - this.cache = cache; - } - @Override public Evaluation evaluate( final Path path ) { @@ -113,9 +106,11 @@ public Evaluation evaluate( final Path path ) if ( roots == null || roots.isEmpty() || roots.contains( path.startNode() .getId() ) ) { - final ProjectRelationship lastRel = Conversions.toProjectRelationship( rel, cache ); + final ProjectRelationship lastRel = Conversions.toProjectRelationship( rel ); + + final List> relPath = new ArrayList>(path.length()); + relPath.addAll( Conversions.convertToRelationships( path.relationships() ) ); - final List> relPath = Conversions.convertToRelationships( path.relationships(), cache ); if ( relPath.indexOf( lastRel ) == relPath.size() - 1 ) { // logger.warn( "\n\n\n\n\nREMOVING last-relationship: {} from path!\n\n\n\n\n" ); @@ -157,7 +152,7 @@ public Iterable expand( final Path path, final BranchState for ( final Long rid : graphPath ) { final Relationship r = admin.getRelationship( rid ); - pathInfo = pathInfo.getChildPathInfo( toProjectRelationship( r, cache ) ); + pathInfo = pathInfo.getChildPathInfo( toProjectRelationship( r ) ); } GraphRelType[] childTypes = types; @@ -209,7 +204,7 @@ public Iterable expand( final Path path, final BranchState } // logger.info( "Attempting to expand: {}", r ); - final ProjectRelationship projectRel = Conversions.toProjectRelationship( r, cache ); + final ProjectRelationship projectRel = Conversions.toProjectRelationship( r ); logger.debug( "Pre-checking relationship {} for expansion using filter: {}", projectRel, traversal ); if ( traversal.preCheck( projectRel, rels ) ) @@ -229,16 +224,11 @@ public Iterable expand( final Path path, final BranchState private List> getPathRelationships( final Path path ) { - List> rels; + List> rels = new ArrayList>(path.length()); final Iterable rs = path.relationships(); - if ( rs == null ) - { - // logger.info( "Constructing empty relationship list for filter." ); - rels = Collections.emptyList(); - } - else + if ( rs != null ) { - rels = Conversions.convertToRelationships( rs, cache ); + rels.addAll( Conversions.convertToRelationships( rs ) ); // logger.info( "Got relationship list {} entries long for filter", rels.size() ); } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathCollectingVisitor.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathCollectingVisitor.java index f098a200..3166a1ba 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathCollectingVisitor.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathCollectingVisitor.java @@ -20,7 +20,6 @@ import java.util.Set; import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.ConversionCache; import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Path; @@ -34,12 +33,9 @@ public class PathCollectingVisitor private final Set paths = new HashSet(); - private final ConversionCache cache; - - public PathCollectingVisitor( final Set ends, final ConversionCache cache ) + public PathCollectingVisitor( final Set ends ) { this.ends = ends; - this.cache = cache; } public Set getPaths() @@ -59,12 +55,6 @@ public boolean includeChildren( final Path path, final Neo4jGraphPath graphPath, return true; } - @Override - public void configure( final AtlasCollector collector ) - { - collector.setConversionCache( cache ); - } - @Override public Iterator iterator() { diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/RootedRelationshipsVisitor.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/RootedRelationshipsVisitor.java index 17dba560..55c6d182 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/RootedRelationshipsVisitor.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/RootedRelationshipsVisitor.java @@ -63,7 +63,7 @@ public boolean includeChildren( final Path path, final Neo4jGraphPath graphPath, } else { - found.add( Conversions.toProjectRelationship( r, getConversionCache() ) ); + found.add( Conversions.toProjectRelationship( r ) ); } } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java index c032a498..cf619c52 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java @@ -32,7 +32,6 @@ import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.graph.rel.RelationshipType; import org.commonjava.maven.atlas.graph.spi.neo4j.GraphRelType; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.ConversionCache; import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.neo4j.graphdb.Relationship; import org.slf4j.Logger; @@ -70,14 +69,14 @@ private TraversalUtils() // return true; // } - public static boolean acceptedInView( final Relationship r, final ViewParams view, final ConversionCache cache ) + public static boolean acceptedInView( final Relationship r, final ViewParams view ) { - return accepted( r, view, cache ); + return accepted( r, view ); } - public static boolean accepted( final Relationship r, final ViewParams view, final ConversionCache cache ) + public static boolean accepted( final Relationship r, final ViewParams view ) { - final ProjectRelationship rel = toProjectRelationship( r, cache ); + final ProjectRelationship rel = toProjectRelationship( r ); debug( "Checking relationship for acceptance: {} ({})", r, rel ); diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java index bdb03e45..ad08c938 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java @@ -26,7 +26,6 @@ import org.commonjava.maven.atlas.graph.model.EProjectCycle; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.graph.spi.neo4j.GraphAdmin; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.ConversionCache; import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; @@ -46,8 +45,6 @@ public class CycleCacheUpdater private final Logger logger = LoggerFactory.getLogger( getClass() ); - private final ConversionCache cache; - private final Node viewNode; final Set cycles = new HashSet(); @@ -56,13 +53,11 @@ public class CycleCacheUpdater private final GraphAdmin admin; - public CycleCacheUpdater( final ViewParams view, final Node viewNode, final GraphAdmin admin, - final ConversionCache cache ) + public CycleCacheUpdater( final ViewParams view, final Node viewNode, final GraphAdmin admin ) { this.view = view; this.viewNode = viewNode; this.admin = admin; - this.cache = cache; } @Override @@ -96,7 +91,8 @@ private void addCycleInternal( final CyclePath cyclicPath, final Relationship in logger.debug( "Adding cycle: {} (via: {})", cyclicPath, injector ); Conversions.storeCachedCyclePath( cyclicPath, viewNode ); - final List> cycle = Conversions.convertToRelationships( cyclicPath, admin, cache ); + final List> cycle = new ArrayList>(cyclicPath.length()); + cycle.addAll( Conversions.convertToRelationships( cyclicPath, admin ) ); logger.info( "CYCLES += {\n {}\n}", new JoinString( "\n ", cycle ) ); cycles.add( new EProjectCycle( cycle ) ); @@ -191,12 +187,6 @@ public static CyclePath getTerminatingCycle( final Neo4jGraphPath graphPath, fin return null; } - @Override - public void configure( final AtlasCollector collector ) - { - collector.setConversionCache( cache ); - } - public int getCycleCount() { return cycles.size(); diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java index 43eeffd7..46b245d4 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java @@ -28,7 +28,6 @@ import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.graph.spi.neo4j.GraphAdmin; import org.commonjava.maven.atlas.graph.spi.neo4j.ViewIndexes; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.ConversionCache; import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; @@ -52,8 +51,6 @@ public class ViewUpdater private final Node viewNode; - private final ConversionCache cache; - private final GraphAdmin admin; private final CycleCacheUpdater cycleUpdater; @@ -63,25 +60,22 @@ public class ViewUpdater private Node stopNode; public ViewUpdater( final ViewParams view, final Node viewNode, final ViewIndexes indexes, - final ConversionCache cache, final GraphAdmin admin ) + final GraphAdmin admin ) { this.viewNode = viewNode; this.indexes = indexes; - this.cache = cache; this.admin = admin; - this.cycleUpdater = new CycleCacheUpdater( view, viewNode, admin, cache ); + this.cycleUpdater = new CycleCacheUpdater( view, viewNode, admin ); } public ViewUpdater( final Node stopNode, final ViewParams view, final Node viewNode, final ViewIndexes indexes, - final ConversionCache cache, final GraphAdmin admin ) { this.stopNode = stopNode; this.viewNode = viewNode; this.indexes = indexes; - this.cache = cache; this.admin = admin; - this.cycleUpdater = new CycleCacheUpdater( view, viewNode, admin, cache ); + this.cycleUpdater = new CycleCacheUpdater( view, viewNode, admin ); } public void cacheRoots( final Set roots ) @@ -148,7 +142,6 @@ public void includingChild( final Relationship child, final Neo4jGraphPath child @Override public void configure( final AtlasCollector collector ) { - collector.setConversionCache( cache ); cycleUpdater.configure( collector ); } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRef.java index 85f94757..eba20137 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRef.java @@ -77,6 +77,13 @@ public SimpleArtifactRef( final String groupId, final String artifactId, final S this.optional = optional; } + public SimpleArtifactRef( ArtifactRef ref ) + { + super( ref ); + this.tc = ref.getTypeAndClassifier(); + this.optional = ref.isOptional(); + } + @Override public String toString() { diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectRef.java index d6301af8..c5fbceaa 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectRef.java @@ -46,6 +46,12 @@ public SimpleProjectRef( final String groupId, final String artifactId ) this.artifactId = artifactId; } + public SimpleProjectRef( ProjectRef ref ) + { + this.groupId = ref.getGroupId(); + this.artifactId = ref.getArtifactId(); + } + public static ProjectRef parse( final String ga ) { final String[] parts = ga.split( ":" ); diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java index ef2cc955..8e6bae5a 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java @@ -79,6 +79,13 @@ public SimpleProjectVersionRef( final String groupId, final String artifactId, f this( groupId, artifactId, null, versionString ); } + public SimpleProjectVersionRef( ProjectVersionRef ref ) + { + super( ref ); + this.versionSpec = ref.getVersionSpecRaw(); + this.versionString = ref.getVersionStringRaw(); + } + public static ProjectVersionRef parse( final String gav ) { final String[] parts = gav.split( ":" ); diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleTypeAndClassifier.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleTypeAndClassifier.java index 83c4289b..3db0756b 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleTypeAndClassifier.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleTypeAndClassifier.java @@ -42,6 +42,12 @@ public SimpleTypeAndClassifier() this( null, null ); } + public SimpleTypeAndClassifier( TypeAndClassifier typeAndClassifier ) + { + this.type = typeAndClassifier.getType(); + this.classifier = typeAndClassifier.getClassifier(); + } + @Override public String getType() { diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleVersionlessArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleVersionlessArtifactRef.java index 6022d9d6..61cb5184 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleVersionlessArtifactRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleVersionlessArtifactRef.java @@ -67,6 +67,13 @@ public SimpleVersionlessArtifactRef( final String groupId, final String artifact this.optional = optional; } + public SimpleVersionlessArtifactRef( VersionlessArtifactRef ref ) + { + super( ref ); + this.tc = ref.getTypeAndClassifier(); + this.optional = ref.isOptional(); + } + @Override public String toString() { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java index 3ab32d51..7c7ff84d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java @@ -17,6 +17,7 @@ import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import java.io.Serializable; import java.lang.reflect.Constructor; @@ -127,6 +128,19 @@ protected AbstractSimpleProjectRelationship( final Collection sources, fina this.managed = managed; } + public AbstractSimpleProjectRelationship( ProjectRelationship relationship ) + { + this.sources.addAll( relationship.getSources() ); + this.declaring = new SimpleProjectVersionRef( relationship.getDeclaring() ); + this.pomLocation = relationship.getPomLocation(); + this.index = relationship.getIndex(); + this.managed = relationship.isManaged(); + this.type = relationship.getType(); + this.target = cloneTarget( relationship.getTarget() ); + } + + protected abstract T cloneTarget( T target ); + @Override public final boolean isManaged() { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleBomRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleBomRelationship.java index 8b5b6375..42cd3376 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleBomRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleBomRelationship.java @@ -21,6 +21,7 @@ import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; /** NOTE: BOM relationships are actually marked as concrete. * This may be somewhat counter-intuitive, but they are structural (like a parent POM). @@ -69,6 +70,17 @@ public SimpleBomRelationship( final URI source, final URI pomLocation, final Pro super( source, pomLocation, RelationshipType.BOM, d, t, index, false ); } + public SimpleBomRelationship( BomRelationship relationship ) + { + super( relationship ); + } + + @Override + protected ProjectVersionRef cloneTarget( ProjectVersionRef target ) + { + return new SimpleProjectVersionRef( target ); + } + @Override public ArtifactRef getTargetArtifact() { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java index f13b2712..8f50b3f2 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java @@ -76,6 +76,13 @@ public SimpleDependencyRelationship( final Collection sources, final URI po this.excludes = new HashSet( Arrays.asList( excludes ) ); } + public SimpleDependencyRelationship( DependencyRelationship relationship ) + { + super( relationship ); + this.scope = relationship.getScope(); + this.excludes = new HashSet( relationship.getExcludes() ); + } + @Override public final DependencyScope getScope() { @@ -142,6 +149,12 @@ public String toString() getTarget(), isManaged(), scope, getIndex() ); } + @Override + protected ArtifactRef cloneTarget( ArtifactRef target ) + { + return new SimpleArtifactRef( target ); + } + @Override public ArtifactRef getTargetArtifact() { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java index 251910e6..1c06f618 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java @@ -19,6 +19,7 @@ import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import java.io.Serializable; import java.net.URI; @@ -57,12 +58,23 @@ public SimpleExtensionRelationship( final Collection sources, final Project super( sources, RelationshipUtils.POM_ROOT_URI, RelationshipType.EXTENSION, declaring, target, index ); } + public SimpleExtensionRelationship( ExtensionRelationship relationship ) + { + super( relationship ); + } + @Override public String toString() { return String.format( "ExtensionRelationship [%s => %s (index=%s)]", getDeclaring(), getTarget(), getIndex() ); } + @Override + protected ProjectVersionRef cloneTarget( ProjectVersionRef target ) + { + return new SimpleProjectVersionRef( target ); + } + @Override public ArtifactRef getTargetArtifact() { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java index 5d9ab264..3da379c3 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java @@ -19,6 +19,7 @@ import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import java.io.Serializable; import java.net.URI; @@ -63,12 +64,23 @@ public SimpleParentRelationship( final Collection sources, final ProjectVer super( sources, RelationshipType.PARENT, declaring, target, 0 ); } + public SimpleParentRelationship( ParentRelationship relationship ) + { + super( relationship ); + } + @Override public String toString() { return String.format( "ParentRelationship [%s => %s]", getDeclaring(), getTarget() ); } + @Override + protected ProjectVersionRef cloneTarget( ProjectVersionRef target ) + { + return new SimpleProjectVersionRef( target ); + } + @Override public ArtifactRef getTargetArtifact() { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java index 9a1de12d..15c985a3 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java @@ -19,6 +19,7 @@ import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; import java.io.Serializable; import java.net.URI; @@ -58,6 +59,12 @@ public SimplePluginDependencyRelationship( final Collection sources, final this.plugin = plugin; } + public SimplePluginDependencyRelationship( PluginDependencyRelationship relationship ) + { + super( relationship ); + this.plugin = new SimpleProjectRef( relationship.getPlugin() ); + } + @Override public final ProjectRef getPlugin() { @@ -115,6 +122,12 @@ public String toString() plugin, getTarget(), isManaged(), getIndex() ); } + @Override + protected ArtifactRef cloneTarget( ArtifactRef target ) + { + return new SimpleArtifactRef( target ); + } + @Override public ArtifactRef getTargetArtifact() { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java index a81f37d0..619df042 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java @@ -23,6 +23,7 @@ import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; public final class SimplePluginRelationship extends AbstractSimpleProjectRelationship @@ -69,6 +70,12 @@ public SimplePluginRelationship( final Collection sources, final URI pomLoc this.reporting = reporting; } + public SimplePluginRelationship( PluginRelationship relationship ) + { + super( relationship ); + this.reporting = relationship.isReporting(); + } + @Override public final boolean isReporting() { @@ -110,6 +117,12 @@ public String toString() isManaged(), getIndex() ); } + @Override + protected ProjectVersionRef cloneTarget( ProjectVersionRef target ) + { + return new SimpleProjectVersionRef( target ); + } + @Override public ArtifactRef getTargetArtifact() { From f5cfaa217ea9819957f131e06f69cae3ff792670 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 22 Sep 2015 12:11:46 -0500 Subject: [PATCH 110/240] adding artifact ref creation to ArtifactPathInfo --- .../maven/atlas/ident/util/ArtifactPathInfo.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java index 47b29948..a0b4b9cc 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java @@ -15,7 +15,9 @@ */ package org.commonjava.maven.atlas.ident.util; +import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; import org.commonjava.maven.atlas.ident.version.part.SnapshotPart; @@ -257,4 +259,9 @@ public ProjectVersionRef getProjectId() return new SimpleProjectVersionRef( getGroupId(), getArtifactId(), getVersion() ); } + public ArtifactRef getArtifact() + { + return new SimpleArtifactRef( getGroupId(), getArtifactId(), getVersion(), getType(), getClassifier(), false ); + } + } From 84a27f3a4be3f8e01be6df9b308f8c870f5234ee Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Wed, 30 Sep 2015 13:57:48 +0200 Subject: [PATCH 111/240] Ensure having only 1 instance of ManagedDependencyMutator The class has only 2 fields - longId and shortId, both made of the class name. So there is no point in creating more than 1 instance. --- .../org/commonjava/maven/atlas/graph/ViewParams.java | 6 +++--- .../atlas/graph/mutate/ManagedDependencyMutator.java | 9 +++++++++ .../RelationshipGraph_StoreAndVerifyInView_TCK.java | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java index d9178866..cc72c2bd 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java @@ -155,7 +155,7 @@ public ViewParams( final String workspaceId, final ProjectRelationshipFilter fil public GraphMutator getMutator() { - return mutator == null ? new ManagedDependencyMutator() : mutator; + return mutator == null ? ManagedDependencyMutator.INSTANCE : mutator; } public ProjectRelationshipFilter getFilter() @@ -449,7 +449,7 @@ public Builder( final String workspaceId, final ProjectVersionRef... roots ) this.properties = new HashMap(); this.selections = new HashMap(); this.filter = AnyFilter.INSTANCE; - this.mutator = new ManagedDependencyMutator(); + this.mutator = ManagedDependencyMutator.INSTANCE; } public Builder( final String workspaceId, final Collection roots ) @@ -461,7 +461,7 @@ public Builder( final String workspaceId, final Collection ro this.properties = new HashMap(); this.selections = new HashMap(); this.filter = AnyFilter.INSTANCE; - this.mutator = new ManagedDependencyMutator(); + this.mutator = ManagedDependencyMutator.INSTANCE; } public Builder( final ViewParams params ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java index 4dffc1b1..0230b173 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java @@ -27,8 +27,17 @@ public class ManagedDependencyMutator implements GraphMutator { + public static final ManagedDependencyMutator INSTANCE = new ManagedDependencyMutator(); + private static final long serialVersionUID = 1L; + /** + * Hidden constructor. + */ + private ManagedDependencyMutator() + { + } + @Override public ProjectRelationship selectFor( final ProjectRelationship rel, final GraphPath path, final RelationshipGraphConnection connection, final ViewParams params ) diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java index 30019ca3..53d864fc 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java @@ -53,7 +53,7 @@ public void run() final ProjectVersionRef d2 = new SimpleProjectVersionRef( "g", "d2", "2" ); final RelationshipGraph graph = - openGraph( new ViewParams( newWorkspaceId(), new DependencyFilter(), new ManagedDependencyMutator(), gav ), + openGraph( new ViewParams( newWorkspaceId(), new DependencyFilter(), ManagedDependencyMutator.INSTANCE, gav ), true ); /* @formatter:off */ From 39275c242d43a9388c8985c22c1284f59b4b5d63 Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 30 Sep 2015 16:24:46 +0100 Subject: [PATCH 112/240] [maven-release-plugin] prepare release atlas-parent-0.15.1 --- bindings/jackson-identities/pom.xml | 2 +- bindings/jackson-relationships/pom.xml | 2 +- bindings/pom.xml | 2 +- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- ftests/jung/pom.xml | 2 +- ftests/neo4j/pom.xml | 2 +- ftests/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 18 +++++++++--------- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index d814f3d4..02a8f10f 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.16.0-SNAPSHOT + 0.15.1 atlas-bindings-jackson-identities diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml index b982d2ab..1e9df8df 100644 --- a/bindings/jackson-relationships/pom.xml +++ b/bindings/jackson-relationships/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.16.0-SNAPSHOT + 0.15.1 atlas-bindings-jackson-relationships diff --git a/bindings/pom.xml b/bindings/pom.xml index 7095c5da..9cf29b32 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.0-SNAPSHOT + 0.15.1 atlas-bindings-parent diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index 1a249b2a..61e027f5 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.16.0-SNAPSHOT + 0.15.1 atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 548f47ae..33e4e02a 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.16.0-SNAPSHOT + 0.15.1 atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 7552e6e9..6d003d93 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.0-SNAPSHOT + 0.15.1 atlas-drivers-parent diff --git a/ftests/jung/pom.xml b/ftests/jung/pom.xml index deafa950..b69fc73f 100644 --- a/ftests/jung/pom.xml +++ b/ftests/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.16.0-SNAPSHOT + 0.15.1 atlas-ftests-jung diff --git a/ftests/neo4j/pom.xml b/ftests/neo4j/pom.xml index f23d3b4a..df0b72ff 100644 --- a/ftests/neo4j/pom.xml +++ b/ftests/neo4j/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.16.0-SNAPSHOT + 0.15.1 atlas-ftests-neo4j diff --git a/ftests/pom.xml b/ftests/pom.xml index 5581feca..18c83983 100644 --- a/ftests/pom.xml +++ b/ftests/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.0-SNAPSHOT + 0.15.1 atlas-ftests-parent diff --git a/identities/pom.xml b/identities/pom.xml index b1758666..6e281056 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.0-SNAPSHOT + 0.15.1 atlas-identities diff --git a/pom.xml b/pom.xml index 7d61ab46..8a0b6ab1 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.0-SNAPSHOT + 0.15.1 pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - HEAD + atlas-parent-0.15.1 @@ -48,37 +48,37 @@ org.commonjava.maven.atlas atlas-identities - 0.16.0-SNAPSHOT + 0.15.1 org.commonjava.maven.atlas atlas-relationships-api - 0.16.0-SNAPSHOT + 0.15.1 org.commonjava.maven.atlas atlas-bindings-jackson-identities - 0.16.0-SNAPSHOT + 0.15.1 org.commonjava.maven.atlas atlas-bindings-jackson-relationships - 0.16.0-SNAPSHOT + 0.15.1 org.commonjava.maven.atlas atlas-driver-jung - 0.16.0-SNAPSHOT + 0.15.1 org.commonjava.maven.atlas atlas-driver-neo4j-embedded - 0.16.0-SNAPSHOT + 0.15.1 org.commonjava.maven.atlas atlas-drivers-tck - 0.16.0-SNAPSHOT + 0.15.1 test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 367cc5c2..107322ab 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.0-SNAPSHOT + 0.15.1 atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index bae330f3..50d9bb6c 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.0-SNAPSHOT + 0.15.1 atlas-drivers-tck From f789ab8b4b02094f25a7411cbd518403fe37aa3f Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 30 Sep 2015 16:24:52 +0100 Subject: [PATCH 113/240] [maven-release-plugin] prepare for next development iteration --- bindings/jackson-identities/pom.xml | 2 +- bindings/jackson-relationships/pom.xml | 2 +- bindings/pom.xml | 2 +- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- ftests/jung/pom.xml | 2 +- ftests/neo4j/pom.xml | 2 +- ftests/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 18 +++++++++--------- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 02a8f10f..4c11c2af 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.15.1 + 0.15.2-SNAPSHOT atlas-bindings-jackson-identities diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml index 1e9df8df..adc317dd 100644 --- a/bindings/jackson-relationships/pom.xml +++ b/bindings/jackson-relationships/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.15.1 + 0.15.2-SNAPSHOT atlas-bindings-jackson-relationships diff --git a/bindings/pom.xml b/bindings/pom.xml index 9cf29b32..81f6bb65 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.1 + 0.15.2-SNAPSHOT atlas-bindings-parent diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index 61e027f5..433d3f69 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.15.1 + 0.15.2-SNAPSHOT atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 33e4e02a..d49d252b 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.15.1 + 0.15.2-SNAPSHOT atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 6d003d93..31a047f5 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.1 + 0.15.2-SNAPSHOT atlas-drivers-parent diff --git a/ftests/jung/pom.xml b/ftests/jung/pom.xml index b69fc73f..23e83a6a 100644 --- a/ftests/jung/pom.xml +++ b/ftests/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.15.1 + 0.15.2-SNAPSHOT atlas-ftests-jung diff --git a/ftests/neo4j/pom.xml b/ftests/neo4j/pom.xml index df0b72ff..6d4faeb4 100644 --- a/ftests/neo4j/pom.xml +++ b/ftests/neo4j/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.15.1 + 0.15.2-SNAPSHOT atlas-ftests-neo4j diff --git a/ftests/pom.xml b/ftests/pom.xml index 18c83983..c4c2960f 100644 --- a/ftests/pom.xml +++ b/ftests/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.1 + 0.15.2-SNAPSHOT atlas-ftests-parent diff --git a/identities/pom.xml b/identities/pom.xml index 6e281056..40c3c9d1 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.1 + 0.15.2-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index 8a0b6ab1..b2fe9276 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.1 + 0.15.2-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - atlas-parent-0.15.1 + HEAD @@ -48,37 +48,37 @@ org.commonjava.maven.atlas atlas-identities - 0.15.1 + 0.15.2-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.15.1 + 0.15.2-SNAPSHOT org.commonjava.maven.atlas atlas-bindings-jackson-identities - 0.15.1 + 0.15.2-SNAPSHOT org.commonjava.maven.atlas atlas-bindings-jackson-relationships - 0.15.1 + 0.15.2-SNAPSHOT org.commonjava.maven.atlas atlas-driver-jung - 0.15.1 + 0.15.2-SNAPSHOT org.commonjava.maven.atlas atlas-driver-neo4j-embedded - 0.15.1 + 0.15.2-SNAPSHOT org.commonjava.maven.atlas atlas-drivers-tck - 0.15.1 + 0.15.2-SNAPSHOT test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 107322ab..0afef04b 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.1 + 0.15.2-SNAPSHOT atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 50d9bb6c..041f04f3 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.1 + 0.15.2-SNAPSHOT atlas-drivers-tck From 211845d231f4afa31f2b248a499880559378aa16 Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 9 Oct 2015 10:40:07 -0500 Subject: [PATCH 114/240] [maven-release-plugin] prepare release atlas-parent-0.15.2 --- bindings/jackson-identities/pom.xml | 2 +- bindings/jackson-relationships/pom.xml | 2 +- bindings/pom.xml | 2 +- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- ftests/jung/pom.xml | 2 +- ftests/neo4j/pom.xml | 2 +- ftests/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 18 +++++++++--------- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 4c11c2af..103681d3 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.15.2-SNAPSHOT + 0.15.2 atlas-bindings-jackson-identities diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml index adc317dd..6f8f9e26 100644 --- a/bindings/jackson-relationships/pom.xml +++ b/bindings/jackson-relationships/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.15.2-SNAPSHOT + 0.15.2 atlas-bindings-jackson-relationships diff --git a/bindings/pom.xml b/bindings/pom.xml index 81f6bb65..63a802f8 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.2-SNAPSHOT + 0.15.2 atlas-bindings-parent diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index 433d3f69..9f1017e4 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.15.2-SNAPSHOT + 0.15.2 atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index d49d252b..15aeca0d 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.15.2-SNAPSHOT + 0.15.2 atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 31a047f5..5e230dac 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.2-SNAPSHOT + 0.15.2 atlas-drivers-parent diff --git a/ftests/jung/pom.xml b/ftests/jung/pom.xml index 23e83a6a..2fe8e9ed 100644 --- a/ftests/jung/pom.xml +++ b/ftests/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.15.2-SNAPSHOT + 0.15.2 atlas-ftests-jung diff --git a/ftests/neo4j/pom.xml b/ftests/neo4j/pom.xml index 6d4faeb4..94cad2e0 100644 --- a/ftests/neo4j/pom.xml +++ b/ftests/neo4j/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.15.2-SNAPSHOT + 0.15.2 atlas-ftests-neo4j diff --git a/ftests/pom.xml b/ftests/pom.xml index c4c2960f..d503e8e5 100644 --- a/ftests/pom.xml +++ b/ftests/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.2-SNAPSHOT + 0.15.2 atlas-ftests-parent diff --git a/identities/pom.xml b/identities/pom.xml index 40c3c9d1..bf8b96c6 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.2-SNAPSHOT + 0.15.2 atlas-identities diff --git a/pom.xml b/pom.xml index b2fe9276..2de037cb 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.2-SNAPSHOT + 0.15.2 pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - HEAD + atlas-parent-0.15.2 @@ -48,37 +48,37 @@ org.commonjava.maven.atlas atlas-identities - 0.15.2-SNAPSHOT + 0.15.2 org.commonjava.maven.atlas atlas-relationships-api - 0.15.2-SNAPSHOT + 0.15.2 org.commonjava.maven.atlas atlas-bindings-jackson-identities - 0.15.2-SNAPSHOT + 0.15.2 org.commonjava.maven.atlas atlas-bindings-jackson-relationships - 0.15.2-SNAPSHOT + 0.15.2 org.commonjava.maven.atlas atlas-driver-jung - 0.15.2-SNAPSHOT + 0.15.2 org.commonjava.maven.atlas atlas-driver-neo4j-embedded - 0.15.2-SNAPSHOT + 0.15.2 org.commonjava.maven.atlas atlas-drivers-tck - 0.15.2-SNAPSHOT + 0.15.2 test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 0afef04b..9b1ebc55 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.2-SNAPSHOT + 0.15.2 atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 041f04f3..7f1fbc51 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.2-SNAPSHOT + 0.15.2 atlas-drivers-tck From f8c5735c3d3597c4229509de9c48598094557bc4 Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 9 Oct 2015 10:40:10 -0500 Subject: [PATCH 115/240] [maven-release-plugin] prepare for next development iteration --- bindings/jackson-identities/pom.xml | 2 +- bindings/jackson-relationships/pom.xml | 2 +- bindings/pom.xml | 2 +- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- ftests/jung/pom.xml | 2 +- ftests/neo4j/pom.xml | 2 +- ftests/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 18 +++++++++--------- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 103681d3..285180f4 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.15.2 + 0.15.3-SNAPSHOT atlas-bindings-jackson-identities diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml index 6f8f9e26..e7dd9838 100644 --- a/bindings/jackson-relationships/pom.xml +++ b/bindings/jackson-relationships/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.15.2 + 0.15.3-SNAPSHOT atlas-bindings-jackson-relationships diff --git a/bindings/pom.xml b/bindings/pom.xml index 63a802f8..69c91eee 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.2 + 0.15.3-SNAPSHOT atlas-bindings-parent diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index 9f1017e4..c119eea2 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.15.2 + 0.15.3-SNAPSHOT atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 15aeca0d..d876ade9 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.15.2 + 0.15.3-SNAPSHOT atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 5e230dac..b0601e2d 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.2 + 0.15.3-SNAPSHOT atlas-drivers-parent diff --git a/ftests/jung/pom.xml b/ftests/jung/pom.xml index 2fe8e9ed..c432619c 100644 --- a/ftests/jung/pom.xml +++ b/ftests/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.15.2 + 0.15.3-SNAPSHOT atlas-ftests-jung diff --git a/ftests/neo4j/pom.xml b/ftests/neo4j/pom.xml index 94cad2e0..f294562f 100644 --- a/ftests/neo4j/pom.xml +++ b/ftests/neo4j/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.15.2 + 0.15.3-SNAPSHOT atlas-ftests-neo4j diff --git a/ftests/pom.xml b/ftests/pom.xml index d503e8e5..9eb88ef4 100644 --- a/ftests/pom.xml +++ b/ftests/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.2 + 0.15.3-SNAPSHOT atlas-ftests-parent diff --git a/identities/pom.xml b/identities/pom.xml index bf8b96c6..f5ee1622 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.2 + 0.15.3-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index 2de037cb..34d8474a 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.2 + 0.15.3-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - atlas-parent-0.15.2 + HEAD @@ -48,37 +48,37 @@ org.commonjava.maven.atlas atlas-identities - 0.15.2 + 0.15.3-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.15.2 + 0.15.3-SNAPSHOT org.commonjava.maven.atlas atlas-bindings-jackson-identities - 0.15.2 + 0.15.3-SNAPSHOT org.commonjava.maven.atlas atlas-bindings-jackson-relationships - 0.15.2 + 0.15.3-SNAPSHOT org.commonjava.maven.atlas atlas-driver-jung - 0.15.2 + 0.15.3-SNAPSHOT org.commonjava.maven.atlas atlas-driver-neo4j-embedded - 0.15.2 + 0.15.3-SNAPSHOT org.commonjava.maven.atlas atlas-drivers-tck - 0.15.2 + 0.15.3-SNAPSHOT test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 9b1ebc55..068b1ae5 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.2 + 0.15.3-SNAPSHOT atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 7f1fbc51..9158d0e8 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.2 + 0.15.3-SNAPSHOT atlas-drivers-tck From db6e887167332245d61c92459763c1745fdf5530 Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Wed, 21 Oct 2015 10:08:57 +0200 Subject: [PATCH 116/240] Fix NPE when trying to close an already closed connection cache The connection field is null when the connection cache is closed and it is handled in closeNow() method, but was not in startCloseTimer(). --- .../maven/atlas/graph/RelationshipGraphFactory.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java index 05656a38..39bfad3d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java @@ -26,6 +26,7 @@ import java.util.Timer; import java.util.TimerTask; +import org.apache.commons.lang.StringUtils; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; @@ -240,8 +241,16 @@ public void run() } }; - logger.info( "Starting close-cache countdown for: {} ({}ms)", connection.getWorkspaceId(), - CLOSE_WAIT_TIMEOUT ); + if ( connection == null ) + { + logger.warn( "Attempt to close an already closed ConnectionCache. Called from:\n {}", + StringUtils.join( (new Exception()).getStackTrace(), "\n " ) ); + } + else + { + logger.info( "Starting close-cache countdown for: {} ({}ms)", + connection.getWorkspaceId(), CLOSE_WAIT_TIMEOUT ); + } timer.schedule( closeTimer, CLOSE_WAIT_TIMEOUT ); } From 6254c16c727ca78f2500274d425e737c262dd612 Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Fri, 23 Oct 2015 14:30:18 +0200 Subject: [PATCH 117/240] Fix #52: OverlappingFileLockException when urlmap and paths are triggered sequentially Try to create the graph database connection 3 times with 5s delays when OverlappingFileLockException is the root cause of caught exception. --- .../spi/neo4j/FileNeo4jConnectionFactory.java | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java index f7183cd1..f7ede2c1 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java @@ -20,11 +20,14 @@ import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; +import org.neo4j.kernel.StoreLockException; +import org.neo4j.kernel.lifecycle.LifecycleException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; +import java.nio.channels.OverlappingFileLockException; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -42,6 +45,8 @@ public class FileNeo4jConnectionFactory private final boolean useShutdownHook; + private final Logger logger = LoggerFactory.getLogger( getClass() ); + private int storageBatchSize = FileNeo4JGraphConnection.DEFAULT_BATCH_SIZE; public FileNeo4jConnectionFactory( final File dbBaseDirectory, final boolean useShutdownHook, final int storageBatchSize ) @@ -90,7 +95,40 @@ else if ( !db.mkdirs() ) FileNeo4JGraphConnection conn = openConnections.get( workspaceId ); if ( conn == null || !conn.isOpen() ) { - conn = new FileNeo4JGraphConnection( workspaceId, db, useShutdownHook, storageBatchSize, this ); + conn = null; + int attempt = 0; + + while ( conn == null ) + { + attempt++; + try + { + conn = new FileNeo4JGraphConnection( workspaceId, db, useShutdownHook, storageBatchSize, this ); + } + catch ( RuntimeException ex ) + { + if ( ex.getCause() instanceof LifecycleException + && ex.getCause().getCause() instanceof StoreLockException + && ex.getCause().getCause().getCause() instanceof OverlappingFileLockException + && attempt < 3 ) + { + logger.warn( "Tried to connect to DB which is not closed (yet). {} Retrying in 5s.", ex.toString() ); + try + { + Thread.sleep(5000); + } + catch ( InterruptedException ez ) + { + logger.error( "The wait delay was interrupted.", ex ); + } + } + else + { + throw ex; + } + } + } + openConnections.put( workspaceId, conn ); } From cb7d1c7630c631c2f7e730f1d9280bab28cd5916 Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Thu, 19 Nov 2015 00:55:56 +0100 Subject: [PATCH 118/240] Add inherited and mixin fields to relationships --- .../ProjectRelationshipDeserializer.java | 12 +- .../ProjectRelationshipSerializer.java | 6 +- .../graph/jackson/SerializationConstants.java | 4 + ...ojectRelationshipSerializerModuleTest.java | 2 +- .../atlas/graph/spi/neo4j/io/Conversions.java | 10 +- .../model/AbstractNeoProjectRelationship.java | 22 ++- .../model/NeoDependencyRelationship.java | 6 +- ...ojectRelationshipSerializerModuleTest.java | 22 +-- .../NeoProjectRelationshipEqualitiesTest.java | 22 +-- .../model/EProjectDirectRelationships.java | 22 +-- .../AbstractSimpleProjectRelationship.java | 56 +++++-- .../atlas/graph/rel/ProjectRelationship.java | 4 + .../graph/rel/SimpleBomRelationship.java | 50 +++--- .../rel/SimpleDependencyRelationship.java | 34 ++-- .../rel/SimpleExtensionRelationship.java | 37 +++-- .../graph/rel/SimpleParentRelationship.java | 16 +- .../SimplePluginDependencyRelationship.java | 32 ++-- .../graph/rel/SimplePluginRelationship.java | 40 ++--- .../atlas/graph/util/RelationshipUtils.java | 146 ++++++++++-------- .../graph/EProjectRelationshipsTest.java | 10 +- .../graph/filter/DependencyFilterTest.java | 2 +- .../rel/RelationshipPathComparatorTest.java | 6 +- .../tck/graph/batch/LargeBatchInsertTCK.java | 2 +- .../cycle/CycleDetection_BackToRootTCK.java | 6 +- .../CycleDetection_BetweenDepLevelsTCK.java | 6 +- .../CycleDetection_FilterRemovesCycleTCK.java | 10 +- ...CycleDetection_IntroduceToExistingTCK.java | 8 +- .../CycleDetection_RootDependentTCK.java | 10 +- ...pGraph_NullPathOnTargetExprVersionTCK.java | 2 +- ...ionshipGraph_StoreAndVerifyInView_TCK.java | 4 +- .../graph/selection/SubGraphSelectionTCK.java | 4 +- ...SubGraphSelection_ContextualToViewTCK.java | 4 +- ...stryTraversal_IgnoreNonParentRels_TCK.java | 12 +- ...ndencyBuildOrderIgnoringPluginPathTCK.java | 8 +- .../DependencyExcludesBuildOrderTCK.java | 6 +- .../ParentDependencyBuildOrderTCK.java | 4 +- .../RuntimeDependencyBuildOrderTCK.java | 12 +- .../SimpleDependencyBuildOrderTCK.java | 4 +- .../SimpleEverythingBuildOrderTCK.java | 8 +- ...sitiveDependencyTraversal_DepOfDepTCK.java | 6 +- ...pendencyTraversal_DepOfDep_ExtMgmtTCK.java | 4 +- ...veDependencyTraversal_PreferDirectTCK.java | 8 +- ...iveDependencyTraversal_PreferLocalTCK.java | 4 +- 43 files changed, 390 insertions(+), 303 deletions(-) diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java index 5906992c..946461a5 100644 --- a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java @@ -180,6 +180,8 @@ public T deserialize( final JsonParser jp, final DeserializationContext ctx ) // handle null implicitly by comparing to true. boolean managed = Boolean.TRUE.equals( ast.get( MANAGED ) ); + boolean inherited = Boolean.TRUE.equals( ast.get( INHERITED ) ); + boolean mixin = Boolean.TRUE.equals( ast.get( MIXIN ) ); ProjectRelationship rel = null; switch ( type ) @@ -200,14 +202,14 @@ public T deserialize( final JsonParser jp, final DeserializationContext ctx ) } rel = new SimpleDependencyRelationship( sources, pomLocation, declaring, target, scope, index, - managed ); + managed, inherited ); break; } case EXTENSION: { final ProjectVersionRef target = SimpleProjectVersionRef.parse( tgt ); - rel = new SimpleExtensionRelationship( sources, pomLocation, declaring, target, index ); + rel = new SimpleExtensionRelationship( sources, pomLocation, declaring, target, index, inherited ); break; } case PARENT: @@ -223,7 +225,7 @@ public T deserialize( final JsonParser jp, final DeserializationContext ctx ) Boolean report = (Boolean) ast.get( REPORTING ); rel = new SimplePluginRelationship( sources, pomLocation, declaring, target, index, managed, - Boolean.TRUE.equals( report ) ); + Boolean.TRUE.equals( report ), inherited ); break; } case PLUGIN_DEP: @@ -240,14 +242,14 @@ public T deserialize( final JsonParser jp, final DeserializationContext ctx ) final ArtifactRef target = SimpleArtifactRef.parse( tgt ); rel = new SimplePluginDependencyRelationship( sources, pomLocation, declaring, plugin, target, - index, managed ); + index, managed, inherited ); break; } case BOM: { final ProjectVersionRef target = SimpleProjectVersionRef.parse( tgt ); - rel = new SimpleBomRelationship( sources, pomLocation, declaring, target, index ); + rel = new SimpleBomRelationship( sources, pomLocation, declaring, target, index, inherited, mixin ); break; } } diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java index 14160ce0..5d645147 100644 --- a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java @@ -38,7 +38,7 @@ public final class ProjectRelationshipSerializer extends StdSerializer { - public ProjectRelationshipSerializer( Class cls ) + public ProjectRelationshipSerializer( final Class cls ) { super( cls ); } @@ -51,6 +51,7 @@ public void serialize( final T value, final JsonGenerator gen, final SerializerP gen.writeStartObject(); gen.writeStringField( RELATIONSHIP_TYPE, value.getType().name() ); gen.writeStringField( POM_LOCATION_URI, value.getPomLocation().toString() ); + gen.writeBooleanField( INHERITED, value.isInherited() ); Set sources = value.getSources(); if ( sources != null ) @@ -81,6 +82,9 @@ public void serialize( final T value, final JsonGenerator gen, final SerializerP switch ( value.getType() ) { + case BOM: + gen.writeBooleanField( MIXIN, value.isMixin() ); + break; case DEPENDENCY: { gen.writeStringField( SCOPE, ( (DependencyRelationship) value ).getScope().realName() ); diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java index 86893b6a..92235a17 100644 --- a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java @@ -42,8 +42,12 @@ private SerializationConstants() public static final String INDEX = "idx"; + public static final String INHERITED = "inherited"; + public static final String MANAGED = "managed"; + public static final String MIXIN = "mixin"; + public static final String REPORTING = "reporting"; public static final String SCOPE = "scope"; diff --git a/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java b/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java index 3ee0a34e..92447035 100644 --- a/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java +++ b/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java @@ -82,7 +82,7 @@ public void roundTrip_SimpleConcreteDependency() new SimpleDependencyRelationship( URI.create( "some:test:location" ), RelationshipUtils.POM_ROOT_URI, new SimpleProjectVersionRef( "org.foo", "bar", "1" ), new SimpleProjectVersionRef( "org.foo", "dep", "1.1" ).asJarArtifact(), - DependencyScope.compile, 0, false ); + DependencyScope.compile, 0, false, false ); String json = mapper.writeValueAsString( rel ); System.out.println( json ); diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java index 702ed05a..7dcb6b2d 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java @@ -91,6 +91,10 @@ public final class Conversions public static final String IS_MANAGED = "managed"; + public static final String IS_INHERITED = "inherited"; + + public static final String IS_MIXIN = "mixin"; + public static final String PLUGIN_GROUP_ID = "plugin_groupId"; public static final String PLUGIN_ARTIFACT_ID = "plugin_artifactId"; @@ -228,7 +232,7 @@ public static List convertToProjects( final Iterable return refs; } - public static List> convertToDetachedRelationships( Iterable relationships ) + public static List> convertToDetachedRelationships( final Iterable relationships ) { final List> rels = new ArrayList>(); for ( final Relationship relationship : relationships ) @@ -378,9 +382,13 @@ public static void toRelationshipProperties( final ProjectRelationship rel Arrays.toString( srcs ), SOURCE_URI, relationship ); relationship.setProperty( SOURCE_URI, srcs ); relationship.setProperty( POM_LOCATION_URI, rel.getPomLocation().toString() ); + relationship.setProperty( IS_INHERITED, rel.isInherited() ); switch ( rel.getType() ) { + case BOM: + relationship.setProperty( IS_MIXIN, rel.isMixin() ); + break; case DEPENDENCY: { final DependencyRelationship specificRel = (DependencyRelationship) rel; diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java index ccdc6f41..aa4d905b 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java @@ -49,13 +49,13 @@ public abstract class AbstractNeoProjectRelationship sources; - protected AbstractNeoProjectRelationship( Relationship rel, RelationshipType type ) + protected AbstractNeoProjectRelationship( final Relationship rel, final RelationshipType type ) { this.rel = rel; this.type = type; } - protected R cloneDirtyState( R old ) + protected R cloneDirtyState( final R old ) { this.dirty = old.isDirty(); this.declaring = old.declaring; @@ -64,21 +64,21 @@ protected R cloneDirtyState( R old ) return (R) this; } - protected R withDeclaring( ProjectVersionRef declaring ) + protected R withDeclaring( final ProjectVersionRef declaring ) { this.declaring = declaring; this.dirty = true; return (R) this; } - protected R withTarget( T target ) + protected R withTarget( final T target ) { this.target = target; this.dirty = true; return (R) this; } - protected R withSources( Set sources ) + protected R withSources( final Set sources ) { this.sources = sources; this.dirty = true; @@ -126,6 +126,18 @@ public boolean isManaged() return NeoIdentityUtils.getBooleanProperty( rel, Conversions.IS_MANAGED, null, false ); } + @Override + public boolean isInherited() + { + return NeoIdentityUtils.getBooleanProperty( rel, Conversions.IS_INHERITED, null, false ); + } + + @Override + public boolean isMixin() + { + return NeoIdentityUtils.getBooleanProperty( rel, Conversions.IS_MIXIN, null, false ); + } + @Override public Set getSources() { diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java index 71d6fc11..77ba30e3 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java @@ -44,7 +44,7 @@ public final class NeoDependencyRelationship private static final long serialVersionUID = 1L; - public NeoDependencyRelationship( Relationship rel ) + public NeoDependencyRelationship( final Relationship rel ) { super(rel, RelationshipType.DEPENDENCY); } @@ -152,7 +152,7 @@ public DependencyRelationship selectTarget( final ProjectVersionRef ref ) } @Override - public DependencyRelationship addSource( URI source ) + public DependencyRelationship addSource( final URI source ) { Set sources = getSources(); if ( sources.add( source ) ) @@ -164,7 +164,7 @@ public DependencyRelationship addSource( URI source ) } @Override - public DependencyRelationship addSources( Collection sources ) + public DependencyRelationship addSources( final Collection sources ) { Set srcs = getSources(); boolean changed = false; diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectRelationshipSerializerModuleTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectRelationshipSerializerModuleTest.java index 8e578530..6f9372d0 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectRelationshipSerializerModuleTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectRelationshipSerializerModuleTest.java @@ -171,7 +171,7 @@ public void roundTripDependencyRelationship() ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); DependencyRelationship rel = new SimpleDependencyRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2.asJarArtifact(), - DependencyScope.compile, 0, false ); + DependencyScope.compile, 0, false, false ); String json = mapper.writeValueAsString( rel ); @@ -187,7 +187,7 @@ public void roundTripDependencyRelationship() assertThat( deser, equalTo( rel ) ); } - private Relationship store( ProjectRelationship rel ) + private Relationship store( final ProjectRelationship rel ) { Relationship r; Transaction tx = graph.beginTx(); @@ -218,7 +218,7 @@ public void roundTripExtensionRelationship() ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); - ExtensionRelationship rel = new SimpleExtensionRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0 ); + ExtensionRelationship rel = new SimpleExtensionRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0, false ); String json = mapper.writeValueAsString( rel ); @@ -241,7 +241,7 @@ public void roundTripBomRelationship() ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); - BomRelationship rel = new SimpleBomRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0 ); + BomRelationship rel = new SimpleBomRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0, false, false ); String json = mapper.writeValueAsString( rel ); @@ -264,7 +264,7 @@ public void roundTripPluginRelationship() ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); - PluginRelationship rel = new SimplePluginRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0, false ); + PluginRelationship rel = new SimplePluginRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0, false, false ); String json = mapper.writeValueAsString( rel ); @@ -288,7 +288,7 @@ public void roundTripPluginDependencyRelationship() ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); ProjectRef pr = new SimpleProjectRef( "org.foo", "plugin" ); - PluginDependencyRelationship rel = new SimplePluginDependencyRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pr, pvr2.asJarArtifact(), 0, false ); + PluginDependencyRelationship rel = new SimplePluginDependencyRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pr, pvr2.asJarArtifact(), 0, false, false ); String json = mapper.writeValueAsString( rel ); @@ -320,12 +320,12 @@ public void roundTripMixedList() List> rels = Arrays.> asList( new SimpleParentRelationship( TEST_URI, pvr, parent ), new SimpleDependencyRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, dep.asJarArtifact(), - DependencyScope.compile, 0, false ), - new SimpleBomRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, ext, 0 ), - new SimpleExtensionRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, ext, 0 ), - new SimplePluginRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, plug, 0, false ), + DependencyScope.compile, 0, false, false ), + new SimpleBomRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, ext, 0, false, false ), + new SimpleExtensionRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, ext, 0, false ), + new SimplePluginRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, plug, 0, false, false ), new SimplePluginDependencyRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pr, - pdep.asJarArtifact(), 0, false ) ); + pdep.asJarArtifact(), 0, false, false ) ); String json = mapper.writeValueAsString( rels ); diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRelationshipEqualitiesTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRelationshipEqualitiesTest.java index 66bff57b..e5764d83 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRelationshipEqualitiesTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRelationshipEqualitiesTest.java @@ -126,7 +126,7 @@ public void dependencyRelationshipEq() ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); DependencyRelationship rel = new SimpleDependencyRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2.asJarArtifact(), - DependencyScope.compile, 0, false ); + DependencyScope.compile, 0, false, false ); Relationship r = store( rel ); @@ -134,7 +134,7 @@ public void dependencyRelationshipEq() assertThat( result, equalTo( rel ) ); } - private Relationship store( ProjectRelationship rel ) + private Relationship store( final ProjectRelationship rel ) { Relationship r; Transaction tx = graph.beginTx(); @@ -165,7 +165,7 @@ public void extensionRelationshipEq() ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); - ExtensionRelationship rel = new SimpleExtensionRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0 ); + ExtensionRelationship rel = new SimpleExtensionRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0, false ); Relationship r = store( rel ); @@ -180,7 +180,7 @@ public void bomRelationshipEq() ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); - BomRelationship rel = new SimpleBomRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0 ); + BomRelationship rel = new SimpleBomRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0, false, false ); Relationship r = store( rel ); @@ -195,7 +195,7 @@ public void pluginRelationshipEq() ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); - PluginRelationship rel = new SimplePluginRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0, false ); + PluginRelationship rel = new SimplePluginRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0, false, false ); Relationship r = store( rel ); @@ -211,7 +211,7 @@ public void pluginDependencyRelationshipEq() ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); ProjectRef pr = new SimpleProjectRef( "org.foo", "plugin" ); - PluginDependencyRelationship rel = new SimplePluginDependencyRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pr, pvr2.asJarArtifact(), 0, false ); + PluginDependencyRelationship rel = new SimplePluginDependencyRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pr, pvr2.asJarArtifact(), 0, false, false ); Relationship r = store( rel ); @@ -235,12 +235,12 @@ public void mixedSetContains() List> rels = Arrays.> asList( new SimpleParentRelationship( TEST_URI, pvr, parent ), new SimpleDependencyRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, dep.asJarArtifact(), - DependencyScope.compile, 0, false ), - new SimpleBomRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, bom, 0 ), - new SimpleExtensionRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, ext, 0 ), - new SimplePluginRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, plug, 0, false ), + DependencyScope.compile, 0, false, false ), + new SimpleBomRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, bom, 0, false, false ), + new SimpleExtensionRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, ext, 0, false ), + new SimplePluginRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, plug, 0, false, false ), new SimplePluginDependencyRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pr, - pdep.asJarArtifact(), 0, false ) ); + pdep.asJarArtifact(), 0, false, false ) ); List rs = new ArrayList(); for ( ProjectRelationship rel : rels ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java index 2f6b205d..84d8f88c 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java @@ -132,9 +132,10 @@ public final Map> getPlug return pluginDependencies; } - public final List getPluginDependencies( final ProjectVersionRef plugin, final boolean managed ) + public final List getPluginDependencies( final ProjectVersionRef plugin, final boolean managed, + final boolean inherited ) { - final PluginRelationship pr = new SimplePluginRelationship( source, getProjectRef(), plugin, 0, managed ); + final PluginRelationship pr = new SimplePluginRelationship( source, getProjectRef(), plugin, 0, managed, inherited ); return pluginDependencies.get( pr ); } @@ -446,10 +447,11 @@ public int getNextPluginIndex( final boolean managed ) return managed ? managedPlugins.size() : plugins.size(); } - public int getNextPluginDependencyIndex( final ProjectVersionRef plugin, final boolean managed ) + public int getNextPluginDependencyIndex( final ProjectVersionRef plugin, final boolean managed, + final boolean inherited ) { final List list = - pluginDependencies.get( new SimplePluginRelationship( source, ref, plugin, 0, managed ) ); + pluginDependencies.get( new SimplePluginRelationship( source, ref, plugin, 0, managed, inherited ) ); return list == null ? 0 : list.size(); } @@ -464,26 +466,26 @@ public int getNextExtensionIndex() } public Builder withDependency( final ProjectVersionRef ref, final String type, final String classifier, final DependencyScope scope, - final boolean managed ) + final boolean managed, final boolean inherited ) { withDependencies( new SimpleDependencyRelationship( source, ref, new SimpleArtifactRef( ref, type, classifier, false ), scope, - getNextDependencyIndex( managed ), managed ) ); + getNextDependencyIndex( managed ), managed, inherited ) ); return this; } - public Builder withPlugin( final ProjectVersionRef ref, final boolean managed ) + public Builder withPlugin( final ProjectVersionRef ref, final boolean managed, final boolean inherited ) { - withPlugins( new SimplePluginRelationship( source, ref, ref, getNextPluginIndex( managed ), managed ) ); + withPlugins( new SimplePluginRelationship( source, ref, ref, getNextPluginIndex( managed ), managed, inherited ) ); return this; } - public Builder withExtension( final ProjectVersionRef ref ) + public Builder withExtension( final ProjectVersionRef ref, final boolean inherited ) { withExtensions( new SimpleExtensionRelationship( source, RelationshipUtils.POM_ROOT_URI, ref, ref, - getNextExtensionIndex() ) ); + getNextExtensionIndex(), inherited ) ); return this; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java index 7c7ff84d..5b2fbbe2 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java @@ -44,6 +44,10 @@ public abstract class AbstractSimpleProjectRelationship cloneCtor; @@ -52,54 +56,58 @@ public abstract class AbstractSimpleProjectRelationship sources, final RelationshipType type, - final ProjectVersionRef declaring, final T target, final int index ) + final ProjectVersionRef declaring, final T target, final int index, + final boolean inherited, final boolean mixin ) { - this( sources, POM_ROOT_URI, type, declaring, target, index, false ); + this( sources, POM_ROOT_URI, type, declaring, target, index, false, inherited, mixin ); } protected AbstractSimpleProjectRelationship( final URI source, final RelationshipType type, final ProjectVersionRef declaring, final T target, final int index, - final boolean managed ) + final boolean managed, final boolean inherited, final boolean mixin ) { - this( Collections.singleton( source ), POM_ROOT_URI, type, declaring, target, index, managed ); + this( Collections.singleton( source ), POM_ROOT_URI, type, declaring, target, index, managed, inherited, mixin ); } protected AbstractSimpleProjectRelationship( final Collection sources, final RelationshipType type, final ProjectVersionRef declaring, final T target, final int index, - final boolean managed ) + final boolean managed, final boolean inherited, final boolean mixin ) { - this( sources, POM_ROOT_URI, type, declaring, target, index, managed ); + this( sources, POM_ROOT_URI, type, declaring, target, index, managed, inherited, mixin ); } protected AbstractSimpleProjectRelationship( final URI source, final URI pomLocation, final RelationshipType type, - final ProjectVersionRef declaring, final T target, final int index ) + final ProjectVersionRef declaring, final T target, final int index, + final boolean inherited, final boolean mixin ) { - this( Collections.singleton( source ), pomLocation, type, declaring, target, index, false ); + this( Collections.singleton( source ), pomLocation, type, declaring, target, index, false, inherited, mixin ); } protected AbstractSimpleProjectRelationship( final Collection sources, final URI pomLocation, final RelationshipType type, final ProjectVersionRef declaring, - final T target, final int index ) + final T target, final int index, final boolean inherited, final boolean mixin ) { - this( sources, pomLocation, type, declaring, target, index, false ); + this( sources, pomLocation, type, declaring, target, index, false, inherited, mixin ); } protected AbstractSimpleProjectRelationship( final URI source, final URI pomLocation, final RelationshipType type, final ProjectVersionRef declaring, final T target, final int index, - final boolean managed ) + final boolean managed, final boolean inherited, final boolean mixin ) { - this( Collections.singleton( source ), pomLocation, type, declaring, target, index, managed ); + this( Collections.singleton( source ), pomLocation, type, declaring, target, index, managed, inherited, mixin ); } protected AbstractSimpleProjectRelationship( final Collection sources, final URI pomLocation, final RelationshipType type, final ProjectVersionRef declaring, - final T target, final int index, final boolean managed ) + final T target, final int index, final boolean managed, + final boolean inherited, final boolean mixin ) { if ( sources == null ) { @@ -126,15 +134,19 @@ protected AbstractSimpleProjectRelationship( final Collection sources, fina this.target = target; this.index = index; this.managed = managed; + this.inherited = inherited; + this.mixin = mixin; } - public AbstractSimpleProjectRelationship( ProjectRelationship relationship ) + public AbstractSimpleProjectRelationship( final ProjectRelationship relationship ) { this.sources.addAll( relationship.getSources() ); this.declaring = new SimpleProjectVersionRef( relationship.getDeclaring() ); this.pomLocation = relationship.getPomLocation(); this.index = relationship.getIndex(); this.managed = relationship.isManaged(); + this.inherited = relationship.isInherited(); + this.mixin = relationship.isMixin(); this.type = relationship.getType(); this.target = cloneTarget( relationship.getTarget() ); } @@ -147,6 +159,18 @@ public final boolean isManaged() return managed; } + @Override + public final boolean isInherited() + { + return inherited; + } + + @Override + public final boolean isMixin() + { + return mixin; + } + @Override public final int getIndex() { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ProjectRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ProjectRelationship.java index ab697880..eedeec5d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ProjectRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ProjectRelationship.java @@ -56,4 +56,8 @@ public interface ProjectRelationship, T exte URI getPomLocation(); + boolean isInherited(); + + boolean isMixin(); + } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleBomRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleBomRelationship.java index 42cd3376..a739588a 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleBomRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleBomRelationship.java @@ -35,48 +35,48 @@ public class SimpleBomRelationship private static final long serialVersionUID = 1L; public SimpleBomRelationship( final Collection sources, final ProjectVersionRef d, final ProjectVersionRef t, - final int index ) + final int index, final boolean inherited, final boolean mixin ) { - // BOMs are actually marked as concrete...somewhat counter-intuitive, - // but they're structural, so managed isn't quite correct (despite + // BOMs are actually marked as concrete...somewhat counter-intuitive, + // but they're structural, so managed isn't quite correct (despite // Maven's unfortunate choice for location). - super( sources, RelationshipType.BOM, d, t, index, false ); + super( sources, RelationshipType.BOM, d, t, index, false, inherited, mixin ); } public SimpleBomRelationship( final URI source, final ProjectVersionRef d, final ProjectVersionRef t, - final int index ) + final int index, final boolean inherited, final boolean mixin ) { - // BOMs are actually marked as concrete...somewhat counter-intuitive, - // but they're structural, so managed isn't quite correct (despite + // BOMs are actually marked as concrete...somewhat counter-intuitive, + // but they're structural, so managed isn't quite correct (despite // Maven's unfortunate choice for location). - super( source, RelationshipType.BOM, d, t, index, false ); + super( source, RelationshipType.BOM, d, t, index, false, inherited, mixin ); } public SimpleBomRelationship( final Collection sources, final URI pomLocation, final ProjectVersionRef d, - final ProjectVersionRef t, final int index ) + final ProjectVersionRef t, final int index, final boolean inherited, final boolean mixin ) { - // BOMs are actually marked as concrete...somewhat counter-intuitive, - // but they're structural, so managed isn't quite correct (despite + // BOMs are actually marked as concrete...somewhat counter-intuitive, + // but they're structural, so managed isn't quite correct (despite // Maven's unfortunate choice for location). - super( sources, pomLocation, RelationshipType.BOM, d, t, index, false ); + super( sources, pomLocation, RelationshipType.BOM, d, t, index, false, inherited, mixin ); } public SimpleBomRelationship( final URI source, final URI pomLocation, final ProjectVersionRef d, - final ProjectVersionRef t, final int index ) + final ProjectVersionRef t, final int index, final boolean inherited, final boolean mixin ) { - // BOMs are actually marked as concrete...somewhat counter-intuitive, - // but they're structural, so managed isn't quite correct (despite + // BOMs are actually marked as concrete...somewhat counter-intuitive, + // but they're structural, so managed isn't quite correct (despite // Maven's unfortunate choice for location). - super( source, pomLocation, RelationshipType.BOM, d, t, index, false ); + super( source, pomLocation, RelationshipType.BOM, d, t, index, false, inherited, mixin ); } - public SimpleBomRelationship( BomRelationship relationship ) + public SimpleBomRelationship( final BomRelationship relationship ) { super( relationship ); } @Override - protected ProjectVersionRef cloneTarget( ProjectVersionRef target ) + protected ProjectVersionRef cloneTarget( final ProjectVersionRef target ) { return new SimpleProjectVersionRef( target ); } @@ -92,7 +92,7 @@ public BomRelationship selectDeclaring( final ProjectVersionRef ref ) { final ProjectVersionRef t = getTarget(); - return new SimpleBomRelationship( getSources(), ref, t, getIndex() ); + return new SimpleBomRelationship( getSources(), ref, t, getIndex(), isInherited(), isMixin() ); } @Override @@ -100,31 +100,31 @@ public BomRelationship selectTarget( final ProjectVersionRef ref ) { final ProjectVersionRef d = getDeclaring(); - return new SimpleBomRelationship( getSources(), d, ref, getIndex() ); + return new SimpleBomRelationship( getSources(), d, ref, getIndex(), isInherited(), isMixin() ); } @Override public BomRelationship cloneFor( final ProjectVersionRef declaring ) { - return new SimpleBomRelationship( getSources(), getPomLocation(), declaring, getTarget(), getIndex() ); + return new SimpleBomRelationship( getSources(), getPomLocation(), declaring, getTarget(), getIndex(), isInherited(), isMixin() ); } @Override - public BomRelationship addSource( URI source ) + public BomRelationship addSource( final URI source ) { Set srcs = getSources(); srcs.add( source ); return new SimpleBomRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), - getIndex() ); + getIndex(), isInherited(), isMixin() ); } @Override - public BomRelationship addSources( Collection sources ) + public BomRelationship addSources( final Collection sources ) { Set srcs = getSources(); srcs.addAll( sources ); return new SimpleBomRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), - getIndex() ); + getIndex(), isInherited(), isMixin() ); } @Override diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java index 8f50b3f2..4da4f8ce 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java @@ -41,27 +41,27 @@ public final class SimpleDependencyRelationship public SimpleDependencyRelationship( final URI source, final ProjectVersionRef declaring, final ArtifactRef target, final DependencyScope scope, final int index, final boolean managed, - final ProjectRef... excludes ) + final boolean inherited, final ProjectRef... excludes ) { - super( source, RelationshipType.DEPENDENCY, declaring, target, index, managed ); + super( source, RelationshipType.DEPENDENCY, declaring, target, index, managed, inherited, false ); this.scope = scope == null ? DependencyScope.compile : scope; this.excludes = new HashSet( Arrays.asList( excludes ) ); } public SimpleDependencyRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, final ArtifactRef target, final DependencyScope scope, final int index, - final boolean managed, final ProjectRef... excludes ) + final boolean managed, final boolean inherited, final ProjectRef... excludes ) { - super( source, pomLocation, RelationshipType.DEPENDENCY, declaring, target, index, managed ); + super( source, pomLocation, RelationshipType.DEPENDENCY, declaring, target, index, managed, inherited, false ); this.scope = scope == null ? DependencyScope.compile : scope; this.excludes = new HashSet( Arrays.asList( excludes ) ); } public SimpleDependencyRelationship( final Collection sources, final ProjectVersionRef declaring, final ArtifactRef target, final DependencyScope scope, final int index, - final boolean managed, final ProjectRef... excludes ) + final boolean managed, final boolean inherited, final ProjectRef... excludes ) { - super( sources, RelationshipType.DEPENDENCY, declaring, target, index, managed ); + super( sources, RelationshipType.DEPENDENCY, declaring, target, index, managed, inherited, false ); this.scope = scope == null ? DependencyScope.compile : scope; this.excludes = new HashSet( Arrays.asList( excludes ) ); } @@ -69,14 +69,14 @@ public SimpleDependencyRelationship( final Collection sources, final Projec public SimpleDependencyRelationship( final Collection sources, final URI pomLocation, final ProjectVersionRef declaring, final ArtifactRef target, final DependencyScope scope, final int index, final boolean managed, - final ProjectRef... excludes ) + final boolean inherited, final ProjectRef... excludes ) { - super( sources, pomLocation, RelationshipType.DEPENDENCY, declaring, target, index, managed ); + super( sources, pomLocation, RelationshipType.DEPENDENCY, declaring, target, index, managed, inherited, false ); this.scope = scope == null ? DependencyScope.compile : scope; this.excludes = new HashSet( Arrays.asList( excludes ) ); } - public SimpleDependencyRelationship( DependencyRelationship relationship ) + public SimpleDependencyRelationship( final DependencyRelationship relationship ) { super( relationship ); this.scope = relationship.getScope(); @@ -93,25 +93,25 @@ public final DependencyScope getScope() public synchronized DependencyRelationship cloneFor( final ProjectVersionRef projectRef ) { return new SimpleDependencyRelationship( getSources(), getPomLocation(), projectRef, getTarget(), scope, getIndex(), - isManaged() ); + isManaged(), isInherited() ); } @Override - public DependencyRelationship addSource( URI source ) + public DependencyRelationship addSource( final URI source ) { Set srcs = getSources(); srcs.add( source ); return new SimpleDependencyRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), scope, getIndex(), - isManaged() ); + isManaged(), isInherited() ); } @Override - public DependencyRelationship addSources( Collection sources ) + public DependencyRelationship addSources( final Collection sources ) { Set srcs = getSources(); srcs.addAll( sources ); return new SimpleDependencyRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), scope, getIndex(), - isManaged() ); + isManaged(), isInherited() ); } @Override @@ -150,7 +150,7 @@ public String toString() } @Override - protected ArtifactRef cloneTarget( ArtifactRef target ) + protected ArtifactRef cloneTarget( final ArtifactRef target ) { return new SimpleArtifactRef( target ); } @@ -174,7 +174,7 @@ public DependencyRelationship selectDeclaring( final ProjectVersionRef ref ) Set var = getExcludes(); return new SimpleDependencyRelationship( getSources(), getPomLocation(), ref, t, getScope(), getIndex(), isManaged(), - var.toArray( new ProjectRef[var.size()] ) ); + isInherited(), var.toArray( new ProjectRef[var.size()] ) ); } @Override @@ -188,7 +188,7 @@ public DependencyRelationship selectTarget( final ProjectVersionRef ref ) Set var = getExcludes(); return new SimpleDependencyRelationship( getSources(), getPomLocation(), d, t, getScope(), getIndex(), isManaged(), - var.toArray( new ProjectRef[var.size()] ) ); + isInherited(), var.toArray( new ProjectRef[var.size()] ) ); } @Override diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java index 1c06f618..1f61cff3 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java @@ -34,31 +34,33 @@ public final class SimpleExtensionRelationship private static final long serialVersionUID = 1L; public SimpleExtensionRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, - final ProjectVersionRef target, final int index ) + final ProjectVersionRef target, final int index, final boolean inherited ) { - super( source, pomLocation, RelationshipType.EXTENSION, declaring, target, index ); + super( source, pomLocation, RelationshipType.EXTENSION, declaring, target, index, inherited, false ); } public SimpleExtensionRelationship( final Collection sources, final URI pomLocation, final ProjectVersionRef declaring, final ProjectVersionRef target, - final int index ) + final int index, final boolean inherited ) { - super( sources, pomLocation, RelationshipType.EXTENSION, declaring, target, index ); + super( sources, pomLocation, RelationshipType.EXTENSION, declaring, target, index, inherited, false ); } public SimpleExtensionRelationship( final URI source, final ProjectVersionRef declaring, - final ProjectVersionRef target, final int index ) + final ProjectVersionRef target, final int index, + final boolean inherited ) { - super( source, RelationshipUtils.POM_ROOT_URI, RelationshipType.EXTENSION, declaring, target, index ); + super( source, RelationshipUtils.POM_ROOT_URI, RelationshipType.EXTENSION, declaring, target, index, inherited, false ); } public SimpleExtensionRelationship( final Collection sources, final ProjectVersionRef declaring, - final ProjectVersionRef target, final int index ) + final ProjectVersionRef target, final int index, + final boolean inherited ) { - super( sources, RelationshipUtils.POM_ROOT_URI, RelationshipType.EXTENSION, declaring, target, index ); + super( sources, RelationshipUtils.POM_ROOT_URI, RelationshipType.EXTENSION, declaring, target, index, inherited, false ); } - public SimpleExtensionRelationship( ExtensionRelationship relationship ) + public SimpleExtensionRelationship( final ExtensionRelationship relationship ) { super( relationship ); } @@ -70,7 +72,7 @@ public String toString() } @Override - protected ProjectVersionRef cloneTarget( ProjectVersionRef target ) + protected ProjectVersionRef cloneTarget( final ProjectVersionRef target ) { return new SimpleProjectVersionRef( target ); } @@ -86,7 +88,8 @@ public ExtensionRelationship selectDeclaring( final ProjectVersionRef ref ) { final ProjectVersionRef t = getTarget(); - return new SimpleExtensionRelationship( getSources(), getPomLocation(), ref, t, getIndex() ); + // TODO + return new SimpleExtensionRelationship( getSources(), getPomLocation(), ref, t, getIndex(), isInherited() ); } @Override @@ -94,28 +97,28 @@ public ExtensionRelationship selectTarget( final ProjectVersionRef ref ) { final ProjectVersionRef d = getDeclaring(); - return new SimpleExtensionRelationship( getSources(), getPomLocation(), d, ref, getIndex() ); + return new SimpleExtensionRelationship( getSources(), getPomLocation(), d, ref, getIndex(), isInherited() ); } @Override public ExtensionRelationship cloneFor( final ProjectVersionRef declaring ) { - return new SimpleExtensionRelationship( getSources(), getPomLocation(), declaring, getTarget(), getIndex() ); + return new SimpleExtensionRelationship( getSources(), getPomLocation(), declaring, getTarget(), getIndex(), isInherited() ); } @Override - public ExtensionRelationship addSource( URI source ) + public ExtensionRelationship addSource( final URI source ) { Set srcs = getSources(); srcs.add( source ); - return new SimpleExtensionRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), getIndex() ); + return new SimpleExtensionRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), getIndex(), isInherited() ); } @Override - public ExtensionRelationship addSources( Collection sources ) + public ExtensionRelationship addSources( final Collection sources ) { Set srcs = getSources(); srcs.addAll( sources ); - return new SimpleExtensionRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), getIndex() ); + return new SimpleExtensionRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), getIndex(), isInherited() ); } } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java index 3da379c3..3a1d13d6 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java @@ -38,7 +38,7 @@ public final class SimpleParentRelationship */ public SimpleParentRelationship( final ProjectVersionRef declaring ) { - super( RelationshipUtils.TERMINAL_PARENT_SOURCE_URI, RelationshipType.PARENT, declaring, declaring, 0 ); + super( RelationshipUtils.TERMINAL_PARENT_SOURCE_URI, RelationshipType.PARENT, declaring, declaring, 0, false, false ); } /** @@ -49,22 +49,22 @@ public SimpleParentRelationship( final ProjectVersionRef declaring ) @Deprecated public SimpleParentRelationship( final URI unused, final ProjectVersionRef declaring ) { - super( RelationshipUtils.TERMINAL_PARENT_SOURCE_URI, RelationshipType.PARENT, declaring, declaring, 0 ); + super( RelationshipUtils.TERMINAL_PARENT_SOURCE_URI, RelationshipType.PARENT, declaring, declaring, 0, false, false ); } public SimpleParentRelationship( final URI source, final ProjectVersionRef declaring, final ProjectVersionRef target ) { - super( source, RelationshipType.PARENT, declaring, target, 0 ); + super( source, RelationshipType.PARENT, declaring, target, 0, false, false ); } public SimpleParentRelationship( final Collection sources, final ProjectVersionRef declaring, final ProjectVersionRef target ) { - super( sources, RelationshipType.PARENT, declaring, target, 0 ); + super( sources, RelationshipType.PARENT, declaring, target, 0, false, false ); } - public SimpleParentRelationship( ParentRelationship relationship ) + public SimpleParentRelationship( final ParentRelationship relationship ) { super( relationship ); } @@ -76,7 +76,7 @@ public String toString() } @Override - protected ProjectVersionRef cloneTarget( ProjectVersionRef target ) + protected ProjectVersionRef cloneTarget( final ProjectVersionRef target ) { return new SimpleProjectVersionRef( target ); } @@ -115,7 +115,7 @@ public ParentRelationship cloneFor( final ProjectVersionRef declaring ) } @Override - public ParentRelationship addSource( URI source ) + public ParentRelationship addSource( final URI source ) { Set srcs = getSources(); srcs.add( source ); @@ -123,7 +123,7 @@ public ParentRelationship addSource( URI source ) } @Override - public ParentRelationship addSources( Collection sources ) + public ParentRelationship addSources( final Collection sources ) { Set srcs = getSources(); srcs.addAll( sources ); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java index 15c985a3..f0826bfd 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java @@ -37,29 +37,31 @@ public final class SimplePluginDependencyRelationship public SimplePluginDependencyRelationship( final URI source, final ProjectVersionRef declaring, final ProjectRef plugin, final ArtifactRef target, final int index, - final boolean managed ) + final boolean managed, final boolean inherited ) { - super( source, RelationshipType.PLUGIN_DEP, declaring, target, index, managed ); + super( source, RelationshipType.PLUGIN_DEP, declaring, target, index, managed, inherited, false ); this.plugin = plugin; } public SimplePluginDependencyRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, final ProjectRef plugin, - final ArtifactRef target, final int index, final boolean managed ) + final ArtifactRef target, final int index, final boolean managed, + final boolean inherited ) { - super( source, pomLocation, RelationshipType.PLUGIN_DEP, declaring, target, index, managed ); + super( source, pomLocation, RelationshipType.PLUGIN_DEP, declaring, target, index, managed, inherited, false ); this.plugin = plugin; } public SimplePluginDependencyRelationship( final Collection sources, final URI pomLocation, final ProjectVersionRef declaring, final ProjectRef plugin, - final ArtifactRef target, final int index, final boolean managed ) + final ArtifactRef target, final int index, final boolean managed, + final boolean inherited ) { - super( sources, pomLocation, RelationshipType.PLUGIN_DEP, declaring, target, index, managed ); + super( sources, pomLocation, RelationshipType.PLUGIN_DEP, declaring, target, index, managed, inherited, false ); this.plugin = plugin; } - public SimplePluginDependencyRelationship( PluginDependencyRelationship relationship ) + public SimplePluginDependencyRelationship( final PluginDependencyRelationship relationship ) { super( relationship ); this.plugin = new SimpleProjectRef( relationship.getPlugin() ); @@ -123,7 +125,7 @@ public String toString() } @Override - protected ArtifactRef cloneTarget( ArtifactRef target ) + protected ArtifactRef cloneTarget( final ArtifactRef target ) { return new SimpleArtifactRef( target ); } @@ -140,7 +142,7 @@ public PluginDependencyRelationship selectDeclaring( final ProjectVersionRef ref final ArtifactRef t = getTarget(); return new SimplePluginDependencyRelationship( getSources(), getPomLocation(), ref, getPlugin(), t, getIndex(), - isManaged() ); + isManaged(), isInherited() ); } @Override @@ -153,31 +155,31 @@ public PluginDependencyRelationship selectTarget( final ProjectVersionRef ref ) t.getClassifier(), t.isOptional() ) ); return new SimplePluginDependencyRelationship( getSources(), getPomLocation(), d, getPlugin(), t, getIndex(), - isManaged() ); + isManaged(), isInherited() ); } @Override public synchronized PluginDependencyRelationship cloneFor( final ProjectVersionRef projectRef ) { return new SimplePluginDependencyRelationship( getSources(), getPomLocation(), projectRef, plugin, getTarget(), - getIndex(), isManaged() ); + getIndex(), isManaged(), isInherited() ); } @Override - public PluginDependencyRelationship addSource( URI source ) + public PluginDependencyRelationship addSource( final URI source ) { Set srcs = getSources(); srcs.add( source ); return new SimplePluginDependencyRelationship( srcs, getPomLocation(), getDeclaring(), plugin, getTarget(), - getIndex(), isManaged() ); + getIndex(), isManaged(), isInherited() ); } @Override - public PluginDependencyRelationship addSources( Collection sources ) + public PluginDependencyRelationship addSources( final Collection sources ) { Set srcs = getSources(); srcs.addAll( sources ); return new SimplePluginDependencyRelationship( srcs, getPomLocation(), getDeclaring(), plugin, getTarget(), - getIndex(), isManaged() ); + getIndex(), isManaged(), isInherited() ); } } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java index 619df042..a19fafe4 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java @@ -35,42 +35,44 @@ public final class SimplePluginRelationship private final boolean reporting; public SimplePluginRelationship( final URI source, final ProjectVersionRef declaring, - final ProjectVersionRef target, final int index, final boolean managed ) + final ProjectVersionRef target, final int index, final boolean managed, + final boolean inherited ) { - this( source, declaring, target, index, managed, false ); + this( source, declaring, target, index, managed, false, inherited ); } public SimplePluginRelationship( final URI source, final ProjectVersionRef declaring, final ProjectVersionRef target, final int index, final boolean managed, - final boolean reporting ) + final boolean reporting, final boolean inherited ) { - super( source, RelationshipType.PLUGIN, declaring, target, index, managed ); + super( source, RelationshipType.PLUGIN, declaring, target, index, managed, inherited, false ); this.reporting = reporting; } public SimplePluginRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, - final ProjectVersionRef target, final int index, final boolean managed ) + final ProjectVersionRef target, final int index, final boolean managed, + final boolean inherited ) { - this( source, pomLocation, declaring, target, index, managed, false ); + this( source, pomLocation, declaring, target, index, managed, false, inherited ); } public SimplePluginRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, final ProjectVersionRef target, final int index, final boolean managed, - final boolean reporting ) + final boolean reporting, final boolean inherited ) { - super( source, pomLocation, RelationshipType.PLUGIN, declaring, target, index, managed ); + super( source, pomLocation, RelationshipType.PLUGIN, declaring, target, index, managed, inherited, false ); this.reporting = reporting; } public SimplePluginRelationship( final Collection sources, final URI pomLocation, final ProjectVersionRef declaring, final ProjectVersionRef target, final int index, - final boolean managed, final boolean reporting ) + final boolean managed, final boolean reporting, final boolean inherited ) { - super( sources, pomLocation, RelationshipType.PLUGIN, declaring, target, index, managed ); + super( sources, pomLocation, RelationshipType.PLUGIN, declaring, target, index, managed, inherited, false ); this.reporting = reporting; } - public SimplePluginRelationship( PluginRelationship relationship ) + public SimplePluginRelationship( final PluginRelationship relationship ) { super( relationship ); this.reporting = relationship.isReporting(); @@ -118,7 +120,7 @@ public String toString() } @Override - protected ProjectVersionRef cloneTarget( ProjectVersionRef target ) + protected ProjectVersionRef cloneTarget( final ProjectVersionRef target ) { return new SimpleProjectVersionRef( target ); } @@ -134,7 +136,7 @@ public PluginRelationship selectDeclaring( final ProjectVersionRef ref ) { final ProjectVersionRef t = getTarget(); - return new SimplePluginRelationship( getSources(), getPomLocation(), ref, t, getIndex(), isManaged(), isReporting() ); + return new SimplePluginRelationship( getSources(), getPomLocation(), ref, t, getIndex(), isManaged(), isReporting(), isInherited() ); } @Override @@ -142,31 +144,31 @@ public PluginRelationship selectTarget( final ProjectVersionRef ref ) { final ProjectVersionRef d = getDeclaring(); - return new SimplePluginRelationship( getSources(), getPomLocation(), d, ref, getIndex(), isManaged(), isReporting() ); + return new SimplePluginRelationship( getSources(), getPomLocation(), d, ref, getIndex(), isManaged(), isReporting(), isInherited() ); } @Override public synchronized PluginRelationship cloneFor( final ProjectVersionRef projectRef ) { return new SimplePluginRelationship( getSources(), getPomLocation(), projectRef, getTarget(), getIndex(), - isManaged(), reporting ); + isManaged(), reporting, isInherited() ); } @Override - public PluginRelationship addSource( URI source ) + public PluginRelationship addSource( final URI source ) { Set srcs = getSources(); srcs.add( source ); return new SimplePluginRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), getIndex(), - isManaged(), reporting ); + isManaged(), reporting, isInherited() ); } @Override - public PluginRelationship addSources( Collection sources ) + public PluginRelationship addSources( final Collection sources ) { Set srcs = getSources(); srcs.addAll( sources ); return new SimplePluginRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), getIndex(), - isManaged(), reporting ); + isManaged(), reporting, isInherited() ); } } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java index e25c3da5..08488b01 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java @@ -280,209 +280,229 @@ public static Set gavs( final Collection getRelationshipTypes( final ProjectRelationshipFilter filter ) diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java index 81355a60..c34d69e0 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java @@ -62,20 +62,20 @@ public void builderWith2Dependencies2PluginsAParentAndAnExtension() final DependencyRelationship papi = new SimpleDependencyRelationship( source, p, new SimpleArtifactRef( "org.apache.maven", "maven-plugin-api", "3.0.3", null, null, false ), DependencyScope.compile, - idx++, false ); + idx++, false, false ); final DependencyRelationship art = new SimpleDependencyRelationship( source, p, new SimpleArtifactRef( "org.apache.maven", "maven-artifact", "3.0.3", null, null, false ), DependencyScope.compile, - idx++, false ); + idx++, false, false ); final PluginRelationship jarp = new SimplePluginRelationship( source, p, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-jar-plugin", - "2.2" ), pidx++, false ); + "2.2" ), pidx++, false, false ); final PluginRelationship comp = new SimplePluginRelationship( source, p, new SimpleProjectVersionRef( "org.apache.maven.plugins", - "maven-compiler-plugin", "2.3.2" ), pidx++, false ); + "maven-compiler-plugin", "2.3.2" ), pidx++, false, false ); final ExtensionRelationship wag = new SimpleExtensionRelationship( source, p, new SimpleProjectVersionRef( "org.apache.maven.wagon", - "wagon-provider-webdav", "1.0" ), 0 ); + "wagon-provider-webdav", "1.0" ), 0, false ); prb.withParent( parentRel ); prb.withDependencies( papi, art ); diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java index 3283378f..97fb5a8c 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java @@ -50,7 +50,7 @@ public void rejectTestScopeForRuntimeFilter() final DependencyRelationship rel = new SimpleDependencyRelationship( testURI(), new SimpleProjectVersionRef( "g", "a", "1" ), new SimpleArtifactRef( "g", "b", "2", "jar", null, false ), DependencyScope.test, 0, - false ); + false, false ); assertThat( filter.accept( rel ), equalTo( false ) ); } diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparatorTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparatorTest.java index f560131b..13651e2a 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparatorTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparatorTest.java @@ -57,8 +57,8 @@ public void sortParentDependencyPathAheadOfDirectDependency() final ProjectVersionRef dep = projectVersion( "org.group", "dep-1", "1.0" ); final URI source = testURI(); - rels.add( dependency( source, root, dep, 0 ) ); - rels.add( dependency( source, dep, projectVersion( "org.foo", "bar", "1.0" ), 0 ) ); + rels.add( dependency( source, root, dep, 0, false ) ); + rels.add( dependency( source, dep, projectVersion( "org.foo", "bar", "1.0" ), 0, false ) ); paths.add( rels ); @@ -67,7 +67,7 @@ public void sortParentDependencyPathAheadOfDirectDependency() final ProjectVersionRef parent = projectVersion( "group.id", "parent", "1" ); rels.add( new SimpleParentRelationship( source, root, parent ) ); - rels.add( dependency( source, parent, "org.foo", "bar", "1.1.1", 0 ) ); + rels.add( dependency( source, parent, "org.foo", "bar", "1.1.1", 0, false ) ); paths.add( rels ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java index 618c8773..a852378d 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java @@ -55,7 +55,7 @@ public void run() for ( int i = 0; i < 550; i++ ) { rels.add(new SimpleDependencyRelationship( sourceURI(), RelationshipUtils.POM_ROOT_URI, myRef, newArtifact(), - DependencyScope.compile, i, false ) ); + DependencyScope.compile, i, false, false ) ); } final RelationshipGraph graph = simpleGraph( myRef ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BackToRootTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BackToRootTCK.java index 97c62c8d..a6afe4de 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BackToRootTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BackToRootTCK.java @@ -55,9 +55,9 @@ public void run() final RelationshipGraph graph = simpleGraph( project ); /* @formatter:off */ - graph.storeRelationships( new SimpleDependencyRelationship( source, project, dep.asJarArtifact(), null, 0, false ), - new SimpleDependencyRelationship( source, dep, dep2.asJarArtifact(), null, 0, false ), - new SimpleDependencyRelationship( source, dep2, project.asJarArtifact(), null, 0, false ) ); + graph.storeRelationships( new SimpleDependencyRelationship( source, project, dep.asJarArtifact(), null, 0, false, false ), + new SimpleDependencyRelationship( source, dep, dep2.asJarArtifact(), null, 0, false, false ), + new SimpleDependencyRelationship( source, dep2, project.asJarArtifact(), null, 0, false, false ) ); /* @formatter:on */ // final EProjectGraph graph = getManager().getGraph( session, project ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java index ff5723e7..d04ac2b3 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java @@ -56,9 +56,9 @@ public void run() /* @formatter:off */ final Set> rejected = graph.storeRelationships( - new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null, false ), null, 0, false ), - new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null, false ), null, 0, false ), - new SimpleDependencyRelationship( source, dep2, new SimpleArtifactRef( dep, null, null, false ), null, 0, false ) ); + new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null, false ), null, 0, false, false ), + new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null, false ), null, 0, false, false ), + new SimpleDependencyRelationship( source, dep2, new SimpleArtifactRef( dep, null, null, false ), null, 0, false, false ) ); /* @formatter:on */ assertThat( rejected, notNullValue() ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java index 3c32be4b..b75ede46 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java @@ -60,11 +60,11 @@ public void run() /* @formatter:off */ // a --> b --> c --> a // d --> e --> c --> a --> b --> c - graph.storeRelationships( new SimpleDependencyRelationship( source, a, new SimpleArtifactRef( b, null, null, false ), null, 0, false ), - new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( a, null, null, false ), null, 0, false ), - new SimplePluginRelationship( source, b, c, 0, false ), - new SimpleDependencyRelationship( source, d, new SimpleArtifactRef( e, null, null, false ), null, 0, false ), - new SimpleDependencyRelationship( source, e, new SimpleArtifactRef( c, null, null, false ), null, 0, false ) ); + graph.storeRelationships( new SimpleDependencyRelationship( source, a, new SimpleArtifactRef( b, null, null, false ), null, 0, false, false ), + new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( a, null, null, false ), null, 0, false, false ), + new SimplePluginRelationship( source, b, c, 0, false, false ), + new SimpleDependencyRelationship( source, d, new SimpleArtifactRef( e, null, null, false ), null, 0, false, false ), + new SimpleDependencyRelationship( source, e, new SimpleArtifactRef( c, null, null, false ), null, 0, false, false ) ); /* @formatter:on */ final RelationshipGraph graph2 = diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java index fe3e1d11..199938dd 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java @@ -55,10 +55,10 @@ public void run() final RelationshipGraph graph = simpleGraph( project ); /* @formatter:off */ - graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null, false ), null, 0, false ), - new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null, false ), null, 0, false ) ); - - final boolean introduces = graph.introducesCycle( new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( project, null, null, false ), null, 0, false ) ); + graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null, false ), null, 0, false, false ), + new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null, false ), null, 0, false, false ) ); + + final boolean introduces = graph.introducesCycle( new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( project, null, null, false ), null, 0, false, false ) ); /* @formatter:on */ assertThat( introduces, equalTo( true ) ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java index fb2a5ae2..29233605 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java @@ -58,11 +58,11 @@ public void run() /* @formatter:off */ // a --> b --> c --> a // d --> e --> c --> a --> b --> c - graph.storeRelationships( new SimpleDependencyRelationship( source, a, new SimpleArtifactRef( b, null, null, false ), null, 0, false ), - new SimpleDependencyRelationship( source, b, new SimpleArtifactRef( c, null, null, false ), null, 0, false ), - new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( a, null, null, false ), null, 0, false ), - new SimpleDependencyRelationship( source, d, new SimpleArtifactRef( e, null, null, false ), null, 0, false ), - new SimpleDependencyRelationship( source, e, new SimpleArtifactRef( c, null, null, false ), null, 0, false ) ); + graph.storeRelationships( new SimpleDependencyRelationship( source, a, new SimpleArtifactRef( b, null, null, false ), null, 0, false, false ), + new SimpleDependencyRelationship( source, b, new SimpleArtifactRef( c, null, null, false ), null, 0, false, false ), + new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( a, null, null, false ), null, 0, false, false ), + new SimpleDependencyRelationship( source, d, new SimpleArtifactRef( e, null, null, false ), null, 0, false, false ), + new SimpleDependencyRelationship( source, e, new SimpleArtifactRef( c, null, null, false ), null, 0, false, false ) ); /* @formatter:on */ final RelationshipGraph graph2 = diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_NullPathOnTargetExprVersionTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_NullPathOnTargetExprVersionTCK.java index 5bcb42ea..66e5820b 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_NullPathOnTargetExprVersionTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_NullPathOnTargetExprVersionTCK.java @@ -52,7 +52,7 @@ public void run() final URI src = new URI( "test:source-uri" ); final ProjectRelationship rel = - new SimpleDependencyRelationship( src, from, to.asArtifactRef( "jar", null ), DependencyScope.compile, 0, false ); + new SimpleDependencyRelationship( src, from, to.asArtifactRef( "jar", null ), DependencyScope.compile, 0, false, false ); final RelationshipGraph graph = simpleGraph( from ); final GraphPath path = graph.createPath( rel ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java index 53d864fc..87a07690 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java @@ -60,9 +60,9 @@ public void run() graph.storeRelationships( new SimpleParentRelationship(src, gav), new SimpleDependencyRelationship(src, gav, d1.asArtifactRef("jar", - null), DependencyScope.compile, 0, true), + null), DependencyScope.compile, 0, true, false ), new SimpleDependencyRelationship(src, gav, d2.asArtifactRef("jar", - null), DependencyScope.compile, 1, true)); + null), DependencyScope.compile, 1, true, false )); /* @formatter:on */ graph.containsGraph( gav ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java index b0f06aba..99480bbe 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java @@ -52,8 +52,8 @@ public void run() final RelationshipGraph graph = simpleGraph( project ); /* @formatter:off */ - graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false ), - new SimpleDependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false ) ); + graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false, false ), + new SimpleDependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false, false ) ); /* @formatter:on */ Set variables = graph.getVariableSubgraphs(); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelection_ContextualToViewTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelection_ContextualToViewTCK.java index 79ba471b..63303026 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelection_ContextualToViewTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelection_ContextualToViewTCK.java @@ -49,8 +49,8 @@ public void run() final RelationshipGraph graph = simpleGraph( project ); /* @formatter:off */ - graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false ), - new SimpleDependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false ) ); + graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false, false ), + new SimpleDependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false, false ) ); /* @formatter:on */ Set variables = graph.getVariableSubgraphs(); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java index 5ca224ea..d29523cc 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java @@ -49,13 +49,13 @@ public void run() /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( source, myRef, parentRef ), - new SimpleDependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "foo", "1.0" ), null, null, false ), null, 0, false ), - new SimpleDependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "bar", "1.2.1" ), null, null, false ), null, 1, false ), - new SimplePluginRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.5.1" ), 0, false ), - new SimplePluginRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins","maven-jar-plugin", "2.2" ), 1, false ), - new SimpleExtensionRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.5.1" ), 0 ), + new SimpleDependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "foo", "1.0" ), null, null, false ), null, 0, false, false ), + new SimpleDependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "bar", "1.2.1" ), null, null, false ), null, 1, false, false ), + new SimplePluginRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.5.1" ), 0, false, false ), + new SimplePluginRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins","maven-jar-plugin", "2.2" ), 1, false, false ), + new SimpleExtensionRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.5.1" ), 0, false ), new SimpleParentRelationship( source, parentRef, grandRef ), - new SimpleDependencyRelationship( source, parentRef, new SimpleProjectVersionRef( "other.group", "utils", "3-1" ).asJarArtifact(), null, 0, false ) + new SimpleDependencyRelationship( source, parentRef, new SimpleProjectVersionRef( "other.group", "utils", "3-1" ).asJarArtifact(), null, 0, false, false ) ); /* @formatter:on */ diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java index d0f19c2b..7bcfd344 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java @@ -64,10 +64,10 @@ public void run() /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( source, c ), - new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false ), - new SimplePluginRelationship( source, c, pb, 0, false ), - new SimpleDependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false ), - new SimpleDependencyRelationship( source, b, a.asJarArtifact(), null, 0, false ) + new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false ), + new SimplePluginRelationship( source, c, pb, 0, false, false ), + new SimpleDependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false, false ), + new SimpleDependencyRelationship( source, b, a.asJarArtifact(), null, 0, false, false ) ); /* @formatter:on */ diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java index 28398a38..35527d55 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java @@ -61,9 +61,9 @@ public void run() /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( c ), - new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, d ), - new SimpleDependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false ), - new SimpleDependencyRelationship( source, b, d.asJarArtifact(), DependencyScope.runtime, 1, false ) + new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false, d ), + new SimpleDependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false, false ), + new SimpleDependencyRelationship( source, b, d.asJarArtifact(), DependencyScope.runtime, 1, false, false ) ); /* @formatter:on */ diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java index 167af463..cd376373 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java @@ -65,8 +65,8 @@ public void run() /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( source, c ), new SimpleParentRelationship( source, b, p ), - new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false ), - new SimpleDependencyRelationship( source, b, a.asJarArtifact(), null, 0, false ) + new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false ), + new SimpleDependencyRelationship( source, b, a.asJarArtifact(), null, 0, false, false ) ); /* @formatter:on */ diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java index 015fe2e0..d2dcf467 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java @@ -66,12 +66,12 @@ public void run() /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( source, c ), - new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false ), - new SimpleDependencyRelationship( source, c, d.asJarArtifact(), DependencyScope.test, 1, false ), - new SimplePluginRelationship( source, c, pb, 0, false ), - new SimpleDependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false ), - new SimpleDependencyRelationship( source, d, e.asJarArtifact(), DependencyScope.runtime, 0, false ), - new SimpleDependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false ) + new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false ), + new SimpleDependencyRelationship( source, c, d.asJarArtifact(), DependencyScope.test, 1, false, false ), + new SimplePluginRelationship( source, c, pb, 0, false, false ), + new SimpleDependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false, false ), + new SimpleDependencyRelationship( source, d, e.asJarArtifact(), DependencyScope.runtime, 0, false, false ), + new SimpleDependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false, false ) ); /* @formatter:on */ diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java index a6e6e7e5..2f1df275 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java @@ -59,8 +59,8 @@ public void run() final RelationshipGraph graph = simpleGraph( c ); /* @formatter:off */ - graph.storeRelationships( new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( b, null, null, false ), null, 0, false ), - new SimpleDependencyRelationship( source, b, new SimpleArtifactRef( a, null, null, false ), null, 0, false ) ); + graph.storeRelationships( new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( b, null, null, false ), null, 0, false, false ), + new SimpleDependencyRelationship( source, b, new SimpleArtifactRef( a, null, null, false ), null, 0, false, false ) ); /* @formatter:on */ assertThat( graph.getAllRelationships() diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java index a167000a..48a9cf07 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java @@ -66,10 +66,10 @@ public void run() /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( source, c ), - new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false ), - new SimplePluginRelationship( source, c, pb, 0, false ), - new SimpleDependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false ), - new SimpleDependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false ) + new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false ), + new SimplePluginRelationship( source, c, pb, 0, false, false ), + new SimpleDependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false, false ), + new SimpleDependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false, false ) ); /* @formatter:on */ diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDepTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDepTCK.java index 278035a3..5a8eeb7c 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDepTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDepTCK.java @@ -48,11 +48,11 @@ public void run() final ProjectVersionRef d2 = projectVersion( "foo", "dep-L2", "1.1.1" ); final RelationshipGraph graph = simpleGraph( root ); - + /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( source, root ), - new SimpleDependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false ), - new SimpleDependencyRelationship( source, d1, d2.asJarArtifact(), compile, 0, false ) + new SimpleDependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false, false ), + new SimpleDependencyRelationship( source, d1, d2.asJarArtifact(), compile, 0, false, false ) ); /* @formatter:on */ diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDep_ExtMgmtTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDep_ExtMgmtTCK.java index 34d768b7..36cb236e 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDep_ExtMgmtTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDep_ExtMgmtTCK.java @@ -52,8 +52,8 @@ public void run() /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( source, root ), - new SimpleDependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false ), - new SimpleDependencyRelationship( source, d1, d2.asJarArtifact(), compile, 0, false ) + new SimpleDependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false, false ), + new SimpleDependencyRelationship( source, d1, d2.asJarArtifact(), compile, 0, false, false ) ); /* @formatter:on */ diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferDirectTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferDirectTCK.java index c17525d0..3b9f6a02 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferDirectTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferDirectTCK.java @@ -47,14 +47,14 @@ public void run() final ProjectVersionRef d1 = projectVersion( "other.group", "dep-L1", "1.0.1" ); final ProjectVersionRef d2a = projectVersion( "foo", "dep-L2", "1.1.1" ); final ProjectVersionRef d2b = projectVersion( "foo", "dep-L2", "1.0" ); - + final RelationshipGraph graph = simpleGraph( root ); /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( source, root ), - new SimpleDependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false ), - new SimpleDependencyRelationship( source, root, d2a.asJarArtifact(), compile, 1, false ), - new SimpleDependencyRelationship( source, d1, d2b.asJarArtifact(), compile, 0, false ) + new SimpleDependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false, false ), + new SimpleDependencyRelationship( source, root, d2a.asJarArtifact(), compile, 1, false, false ), + new SimpleDependencyRelationship( source, d1, d2b.asJarArtifact(), compile, 0, false, false ) ); /* @formatter:on */ diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferLocalTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferLocalTCK.java index ce3e58df..127d6ac0 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferLocalTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferLocalTCK.java @@ -53,8 +53,8 @@ public void run() /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( source, root, parent ), - new SimpleDependencyRelationship( source, root, d1a.asJarArtifact(), compile, 0, false ), - new SimpleDependencyRelationship( source, parent, d1b.asJarArtifact(), compile, 0, false ) + new SimpleDependencyRelationship( source, root, d1a.asJarArtifact(), compile, 0, false, false ), + new SimpleDependencyRelationship( source, parent, d1b.asJarArtifact(), compile, 0, false, false ) ); /* @formatter:on */ From 1ea57d40da53db5e8ccedc3ce54b84842d1be7af Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Thu, 26 Nov 2015 16:45:36 +0100 Subject: [PATCH 119/240] Add optional flag to dependency relationships json output --- .../atlas/graph/jackson/ProjectRelationshipSerializer.java | 1 + .../maven/atlas/graph/jackson/SerializationConstants.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java index 5d645147..8d3f07fa 100644 --- a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java @@ -89,6 +89,7 @@ public void serialize( final T value, final JsonGenerator gen, final SerializerP { gen.writeStringField( SCOPE, ( (DependencyRelationship) value ).getScope().realName() ); gen.writeBooleanField( MANAGED, value.isManaged() ); + gen.writeBooleanField( OPTIONAL, value.getTargetArtifact().isOptional() ); break; } case PLUGIN_DEP: diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java index 92235a17..8f096a6b 100644 --- a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java @@ -48,6 +48,8 @@ private SerializationConstants() public static final String MIXIN = "mixin"; + public static final String OPTIONAL = "optional"; + public static final String REPORTING = "reporting"; public static final String SCOPE = "scope"; From 6b87a9253342afd782b2289a7152da9dca0453fa Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 1 Dec 2015 15:39:23 -0600 Subject: [PATCH 120/240] formats --- .../atlas/graph/mutate/ManagedDependencyMutator.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java index 0230b173..445b3ab1 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java @@ -23,8 +23,8 @@ import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; public class ManagedDependencyMutator - extends VersionManagerMutator - implements GraphMutator + extends VersionManagerMutator + implements GraphMutator { public static final ManagedDependencyMutator INSTANCE = new ManagedDependencyMutator(); @@ -37,10 +37,10 @@ public class ManagedDependencyMutator private ManagedDependencyMutator() { } - + @Override public ProjectRelationship selectFor( final ProjectRelationship rel, final GraphPath path, - final RelationshipGraphConnection connection, final ViewParams params ) + final RelationshipGraphConnection connection, final ViewParams params ) { if ( rel.getType() != RelationshipType.DEPENDENCY ) // TODO: BOM types?? { @@ -52,8 +52,7 @@ private ManagedDependencyMutator() if ( mutated == null || mutated == rel ) { final ProjectVersionRef managed = - connection - .getManagedTargetFor( rel.getTarget(), path, RelationshipType.DEPENDENCY ); + connection.getManagedTargetFor( rel.getTarget(), path, RelationshipType.DEPENDENCY ); if ( managed != null ) { mutated = rel.selectTarget( managed ); From 73dc664dea519f3e2159c2c71e829de3e74ad9eb Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Fri, 4 Dec 2015 16:29:53 +0100 Subject: [PATCH 121/240] Support detaching of AbstractNeoProjectRelationship instances --- .../atlas/graph/spi/neo4j/io/Conversions.java | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java index 7dcb6b2d..0c4da04a 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java @@ -63,6 +63,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -232,12 +233,34 @@ public static List convertToProjects( final Iterable return refs; } - public static List> convertToDetachedRelationships( final Iterable relationships ) + /** + * Converts an iterable of relationships to project relationships detached from database. + * + * @param relationships iterable of {@link AbstractNeoProjectRelationship} or {@link Relationship} + * @return list of detached relationships + * @throws IllegalArgumentException if an iterable of unsupported classes is passed + */ + public static List> convertToDetachedRelationships( final Iterable relationships ) { final List> rels = new ArrayList>(); - for ( final Relationship relationship : relationships ) + Iterator iterator = relationships.iterator(); + while ( iterator.hasNext() ) { - final AbstractNeoProjectRelationship rel = Conversions.toProjectRelationship( relationship ); + final AbstractNeoProjectRelationship rel; + Object next = iterator.next(); + if ( next instanceof AbstractNeoProjectRelationship ) + { + rel = ( AbstractNeoProjectRelationship) next; + } + else if ( next instanceof AbstractNeoProjectRelationship ) + { + rel = Conversions.toProjectRelationship( ( Relationship ) next ); + } + else + { + throw new IllegalArgumentException( "Relationship class " + next.getClass().getCanonicalName() + + " cannot be converted to detached relationship." ); + } if ( rel != null ) { rels.add( rel.detach() ); From 4e8e560cb850e329e311dd419a60b3394d58b60e Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Tue, 8 Dec 2015 19:17:51 +0100 Subject: [PATCH 122/240] Fix class check in detaching relationships --- .../commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java index 0c4da04a..29ec218d 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java @@ -252,7 +252,7 @@ public static List convertToProjects( final Iterable { rel = ( AbstractNeoProjectRelationship) next; } - else if ( next instanceof AbstractNeoProjectRelationship ) + else if ( next instanceof Relationship ) { rel = Conversions.toProjectRelationship( ( Relationship ) next ); } From 4173cc40e6b298c9a1722949140434d2e28cff2a Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Tue, 12 Jan 2016 18:34:47 +0100 Subject: [PATCH 123/240] Add test for relationship comparison transitivity This test reveals a problem in RelationshipComparator. It creates 3 relationships A, B and C. Then it confirms that A < B and B < C. In the end it tests that A < C, which is the transitivity rule. It shows that in this case with given relationships it is not true. The relationships are intentionally chosen to be of the same type creating dependency chain, i.e. A's target is B's declaring and B's target is C's declaring. The comparator tries to sort consequential relationships correctly, but if you compare relationships A and C, you are missing the info that there is a relationship B between them and they are evaluated as equal from the sorting point of view, which violates the general contract. There is no way to get this info in comparator from the given relationships, so we have to drop this sorting feature and instead compare/sort them in some safer way. The same comparison approach is used in PathComparator, but it is not that easy to write a test for it. --- .../graph/rel/RelationshipComparatorTest.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java new file mode 100644 index 00000000..64810173 --- /dev/null +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java @@ -0,0 +1,49 @@ +package org.commonjava.maven.atlas.graph.rel; + +import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.POM_ROOT_URI; +import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.dependency; +import static org.commonjava.maven.atlas.ident.util.IdentityUtils.projectVersion; +import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.*; + +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.junit.Test; + +public class RelationshipComparatorTest +{ + + /** + * Tests the transitivity of the compare mathod, i.e. if A < B and B < C, then also A < C. + * The test creates 4 projects (W, X, Y and Z) and 3 relationships: + *
+     * A = W depends on X
+     * B = X depends on Y
+     * C = Y depends on Z
+     * 
+ * + * Then it confirms that A < B and B < C. The last step is to test if A < C. + */ + @Test + public void testCompareTransitivity() + { + final ProjectVersionRef nodeW = projectVersion( "w", "w", "1.0" ); + final ProjectVersionRef nodeX = projectVersion( "x", "x", "1.0" ); + final ProjectVersionRef nodeY = projectVersion( "y", "y", "1.0" ); + final ProjectVersionRef nodeZ = projectVersion( "z", "z", "1.0" ); + + DependencyRelationship relA = dependency( POM_ROOT_URI, nodeW, nodeX, 0, false ); + DependencyRelationship relB = dependency( POM_ROOT_URI, nodeX, nodeY, 0, false ); + DependencyRelationship relC = dependency( POM_ROOT_URI, nodeY, nodeZ, 0, false ); + + assertThat( "relA < relB must be true to perform the test", + RelationshipComparator.INSTANCE.compare( relA, relB ), equalTo( -1 ) ); + assertThat( "relB < relC must be true to perform the test", + RelationshipComparator.INSTANCE.compare( relB, relC ), equalTo( -1 ) ); + + int compare = RelationshipComparator.INSTANCE.compare( relA, relC ); + compare = ((Float) Math.signum( compare )).intValue(); + assertThat( "relA < relC must be true because relA < relB and relB < relC, but it is not", + compare, equalTo( -1 ) ); + } + +} From c76da5bdc44ab2866c3e78e6450b1f566d1581e9 Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Tue, 12 Jan 2016 22:58:46 +0100 Subject: [PATCH 124/240] Fix #60: IllegalArgumentException when fetching objects from database Fixes the transitivity rule of RelationshipComparator and PathComparator. --- .../atlas/graph/spi/neo4j/PathComparator.java | 23 +++++++------------ .../graph/rel/RelationshipComparator.java | 22 ++++-------------- 2 files changed, 13 insertions(+), 32 deletions(-) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java index 08aa6643..b3398e1d 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java @@ -82,14 +82,14 @@ else if ( second.length() > commonLen ) return 0; } - private int compareTypes( Relationship f, Relationship s ) + private int compareTypes( final Relationship f, final Relationship s ) { GraphRelType ft = GraphRelType.valueOf( f.getType().name() ); GraphRelType st = GraphRelType.valueOf( s.getType().name() ); return ft.ordinal() - st.ordinal(); } - private int compareRels( Relationship first, Relationship second ) + private int compareRels( final Relationship first, final Relationship second ) { if ( first.getType() == second.getType() ) { @@ -105,27 +105,20 @@ else if ( !firstSrc.equals( POM_ROOT_URI ) && secSrc.equals( POM_ROOT_URI ) ) return 1; } - if ( first.getEndNode().getId() == second.getStartNode().getId() ) + int res = ( (Long) first.getStartNode().getId() ).compareTo( second.getStartNode().getId() ); + if ( res == 0 ) { - return -1; - } - else if ( first.getStartNode().getId() == second.getEndNode().getId() ) - { - return 1; - } - else if ( first.getStartNode().getId() == second.getStartNode().getId() ) - { - return Conversions.getIntegerProperty( Conversions.INDEX, first ) - Conversions.getIntegerProperty( - Conversions.INDEX, second ); + res = Conversions.getIntegerProperty( Conversions.INDEX, first ) + - Conversions.getIntegerProperty( Conversions.INDEX, second ); } + + return res; } else { // really, we can't reach this because of the way the main compare method works... return compareTypes( first, second ); } - - return 0; } } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparator.java index 7c95cd24..c3658d8b 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparator.java @@ -47,23 +47,13 @@ else if ( !one.getPomLocation() return 1; } - if ( one.getTarget() - .asProjectVersionRef() - .equals( two.getDeclaring() ) ) + int res = one.getDeclaring().compareTo( two.getDeclaring() ); + if ( res == 0 ) { - return -1; - } - else if ( one.getDeclaring() - .equals( two.getTarget() - .asProjectVersionRef() ) ) - { - return 1; - } - else if ( one.getDeclaring() - .equals( two.getDeclaring() ) ) - { - return one.getIndex() - two.getIndex(); + res = one.getIndex() - two.getIndex(); } + + return res; } else { @@ -71,8 +61,6 @@ else if ( one.getDeclaring() .ordinal() - two.getType() .ordinal(); } - - return 0; } } From 5ce2239ab7317dcbef2d0a440f3ecd1f9522a81f Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Tue, 12 Jan 2016 23:56:15 +0100 Subject: [PATCH 125/240] Move test from src/main to src/test --- .../maven/atlas/graph/rel/RelationshipComparatorTest.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename relationships-api/src/{main => test}/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java (100%) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java similarity index 100% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java rename to relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java From d5fdfe7515c7b2b7356d061d952e100fc1fc4927 Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Tue, 15 Dec 2015 13:27:18 +0100 Subject: [PATCH 126/240] Provide optional flag properly on dependency relationships --- .../ProjectRelationshipDeserializer.java | 3 +- .../ProjectRelationshipSerializer.java | 2 +- ...ojectRelationshipSerializerModuleTest.java | 2 +- .../atlas/graph/spi/neo4j/io/Conversions.java | 3 +- .../model/NeoDependencyRelationship.java | 6 +++ .../NeoPluginDependencyRelationship.java | 10 +++- ...ojectRelationshipSerializerModuleTest.java | 4 +- .../NeoProjectRelationshipEqualitiesTest.java | 4 +- .../model/EProjectDirectRelationships.java | 6 +-- .../graph/rel/DependencyRelationship.java | 2 + .../rel/PluginDependencyRelationship.java | 2 + .../rel/SimpleDependencyRelationship.java | 33 +++++++++---- .../SimplePluginDependencyRelationship.java | 12 +++++ .../DependencyTreeRelationshipPrinter.java | 3 +- .../atlas/graph/util/RelationshipUtils.java | 47 ++++++++++--------- .../graph/EProjectRelationshipsTest.java | 4 +- .../graph/filter/DependencyFilterTest.java | 2 +- .../rel/RelationshipPathComparatorTest.java | 6 +-- .../tck/graph/batch/LargeBatchInsertTCK.java | 2 +- .../cycle/CycleDetection_BackToRootTCK.java | 6 +-- .../CycleDetection_BetweenDepLevelsTCK.java | 6 +-- .../CycleDetection_FilterRemovesCycleTCK.java | 8 ++-- ...CycleDetection_IntroduceToExistingTCK.java | 6 +-- .../CycleDetection_RootDependentTCK.java | 10 ++-- ...pGraph_NullPathOnTargetExprVersionTCK.java | 2 +- ...ionshipGraph_StoreAndVerifyInView_TCK.java | 4 +- .../graph/selection/SubGraphSelectionTCK.java | 4 +- ...SubGraphSelection_ContextualToViewTCK.java | 4 +- ...stryTraversal_IgnoreNonParentRels_TCK.java | 6 +-- ...ndencyBuildOrderIgnoringPluginPathTCK.java | 6 +-- .../DependencyExcludesBuildOrderTCK.java | 6 +-- .../ParentDependencyBuildOrderTCK.java | 4 +- .../RuntimeDependencyBuildOrderTCK.java | 10 ++-- .../SimpleDependencyBuildOrderTCK.java | 4 +- .../SimpleEverythingBuildOrderTCK.java | 6 +-- ...sitiveDependencyTraversal_DepOfDepTCK.java | 4 +- ...pendencyTraversal_DepOfDep_ExtMgmtTCK.java | 4 +- ...veDependencyTraversal_PreferDirectTCK.java | 6 +-- ...iveDependencyTraversal_PreferLocalTCK.java | 4 +- 39 files changed, 154 insertions(+), 109 deletions(-) diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java index 946461a5..c89e04b7 100644 --- a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java @@ -182,6 +182,7 @@ public T deserialize( final JsonParser jp, final DeserializationContext ctx ) boolean managed = Boolean.TRUE.equals( ast.get( MANAGED ) ); boolean inherited = Boolean.TRUE.equals( ast.get( INHERITED ) ); boolean mixin = Boolean.TRUE.equals( ast.get( MIXIN ) ); + boolean optional = Boolean.TRUE.equals( ast.get( OPTIONAL ) ); ProjectRelationship rel = null; switch ( type ) @@ -202,7 +203,7 @@ public T deserialize( final JsonParser jp, final DeserializationContext ctx ) } rel = new SimpleDependencyRelationship( sources, pomLocation, declaring, target, scope, index, - managed, inherited ); + managed, inherited, optional ); break; } case EXTENSION: diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java index 8d3f07fa..3f32fba5 100644 --- a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java @@ -89,7 +89,7 @@ public void serialize( final T value, final JsonGenerator gen, final SerializerP { gen.writeStringField( SCOPE, ( (DependencyRelationship) value ).getScope().realName() ); gen.writeBooleanField( MANAGED, value.isManaged() ); - gen.writeBooleanField( OPTIONAL, value.getTargetArtifact().isOptional() ); + gen.writeBooleanField( OPTIONAL, ( (DependencyRelationship) value ).isOptional() ); break; } case PLUGIN_DEP: diff --git a/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java b/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java index 92447035..90e67af6 100644 --- a/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java +++ b/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java @@ -82,7 +82,7 @@ public void roundTrip_SimpleConcreteDependency() new SimpleDependencyRelationship( URI.create( "some:test:location" ), RelationshipUtils.POM_ROOT_URI, new SimpleProjectVersionRef( "org.foo", "bar", "1" ), new SimpleProjectVersionRef( "org.foo", "dep", "1.1" ).asJarArtifact(), - DependencyScope.compile, 0, false, false ); + DependencyScope.compile, 0, false, false, false ); String json = mapper.writeValueAsString( rel ); System.out.println( json ); diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java index 29ec218d..5f802fca 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java @@ -418,6 +418,7 @@ public static void toRelationshipProperties( final ProjectRelationship rel toRelationshipProperties( (ArtifactRef) rel.getTarget(), relationship ); relationship.setProperty( IS_MANAGED, specificRel.isManaged() ); relationship.setProperty( SCOPE, specificRel.getScope().realName() ); + relationship.setProperty( OPTIONAL, specificRel.isOptional() ); final Set excludes = specificRel.getExcludes(); if ( excludes != null && !excludes.isEmpty() ) @@ -596,8 +597,6 @@ private static ArtifactRef toArtifactRef( final ProjectVersionRef ref, final Rel private static void toRelationshipProperties( final ArtifactRef target, final Relationship relationship ) { - relationship.setProperty( OPTIONAL, target.isOptional() ); - Logger logger = LoggerFactory.getLogger( Conversions.class ); logger.debug( "Type of artifact: {} (type: {}) is: {}", target, target.getClass().getSimpleName(), target.getType() ); diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java index 77ba30e3..aa3ca72b 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java @@ -187,4 +187,10 @@ public boolean isBOM() return DependencyScope._import == getScope() && "pom".equals( getTargetArtifact().getType() ); } + @Override + public boolean isOptional() + { + return Conversions.getBooleanProperty( Conversions.OPTIONAL, rel ); + } + } diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java index 2819c535..92d9b0f2 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java @@ -133,7 +133,7 @@ public PluginDependencyRelationship selectTarget( final ProjectVersionRef ref ) } @Override - public PluginDependencyRelationship addSource( URI source ) + public PluginDependencyRelationship addSource( final URI source ) { Set sources = getSources(); if ( sources.add( source ) ) @@ -145,7 +145,7 @@ public PluginDependencyRelationship addSource( URI source ) } @Override - public PluginDependencyRelationship addSources( Collection sources ) + public PluginDependencyRelationship addSources( final Collection sources ) { Set srcs = getSources(); boolean changed = false; @@ -162,4 +162,10 @@ public PluginDependencyRelationship addSources( Collection sources ) return this; } + @Override + public boolean isOptional() + { + return Conversions.getBooleanProperty( Conversions.OPTIONAL, rel ); + } + } diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectRelationshipSerializerModuleTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectRelationshipSerializerModuleTest.java index 6f9372d0..6c9fb8e8 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectRelationshipSerializerModuleTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectRelationshipSerializerModuleTest.java @@ -171,7 +171,7 @@ public void roundTripDependencyRelationship() ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); DependencyRelationship rel = new SimpleDependencyRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2.asJarArtifact(), - DependencyScope.compile, 0, false, false ); + DependencyScope.compile, 0, false, false, false ); String json = mapper.writeValueAsString( rel ); @@ -320,7 +320,7 @@ public void roundTripMixedList() List> rels = Arrays.> asList( new SimpleParentRelationship( TEST_URI, pvr, parent ), new SimpleDependencyRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, dep.asJarArtifact(), - DependencyScope.compile, 0, false, false ), + DependencyScope.compile, 0, false, false, false ), new SimpleBomRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, ext, 0, false, false ), new SimpleExtensionRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, ext, 0, false ), new SimplePluginRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, plug, 0, false, false ), diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRelationshipEqualitiesTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRelationshipEqualitiesTest.java index e5764d83..6904b5fa 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRelationshipEqualitiesTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRelationshipEqualitiesTest.java @@ -126,7 +126,7 @@ public void dependencyRelationshipEq() ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); DependencyRelationship rel = new SimpleDependencyRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2.asJarArtifact(), - DependencyScope.compile, 0, false, false ); + DependencyScope.compile, 0, false, false, false ); Relationship r = store( rel ); @@ -235,7 +235,7 @@ public void mixedSetContains() List> rels = Arrays.> asList( new SimpleParentRelationship( TEST_URI, pvr, parent ), new SimpleDependencyRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, dep.asJarArtifact(), - DependencyScope.compile, 0, false, false ), + DependencyScope.compile, 0, false, false, false ), new SimpleBomRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, bom, 0, false, false ), new SimpleExtensionRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, ext, 0, false ), new SimplePluginRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, plug, 0, false, false ), diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java index 84d8f88c..330d3489 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java @@ -466,11 +466,11 @@ public int getNextExtensionIndex() } public Builder withDependency( final ProjectVersionRef ref, final String type, final String classifier, final DependencyScope scope, - final boolean managed, final boolean inherited ) + final boolean managed, final boolean inherited, final boolean optional ) { - withDependencies( new SimpleDependencyRelationship( source, ref, new SimpleArtifactRef( ref, type, classifier, false ), + withDependencies( new SimpleDependencyRelationship( source, ref, new SimpleArtifactRef( ref, type, classifier, optional ), scope, - getNextDependencyIndex( managed ), managed, inherited ) ); + getNextDependencyIndex( managed ), managed, inherited, optional ) ); return this; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java index 58fb0ed6..263f241d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java @@ -46,4 +46,6 @@ public interface DependencyRelationship DependencyRelationship selectTarget( ProjectVersionRef ref ); boolean isBOM(); + + boolean isOptional(); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java index 508e2e5f..afe84257 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java @@ -40,4 +40,6 @@ public interface PluginDependencyRelationship @Override PluginDependencyRelationship selectTarget( ProjectVersionRef ref ); + + boolean isOptional(); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java index 4da4f8ce..76ee1e3f 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java @@ -39,40 +39,48 @@ public final class SimpleDependencyRelationship private final Set excludes; + private boolean optional; + public SimpleDependencyRelationship( final URI source, final ProjectVersionRef declaring, final ArtifactRef target, final DependencyScope scope, final int index, final boolean managed, - final boolean inherited, final ProjectRef... excludes ) + final boolean inherited, final boolean optional, final ProjectRef... excludes ) { super( source, RelationshipType.DEPENDENCY, declaring, target, index, managed, inherited, false ); this.scope = scope == null ? DependencyScope.compile : scope; + this.optional = optional; this.excludes = new HashSet( Arrays.asList( excludes ) ); } public SimpleDependencyRelationship( final URI source, final URI pomLocation, final ProjectVersionRef declaring, final ArtifactRef target, final DependencyScope scope, final int index, - final boolean managed, final boolean inherited, final ProjectRef... excludes ) + final boolean managed, final boolean inherited, final boolean optional, + final ProjectRef... excludes ) { super( source, pomLocation, RelationshipType.DEPENDENCY, declaring, target, index, managed, inherited, false ); this.scope = scope == null ? DependencyScope.compile : scope; + this.optional = optional; this.excludes = new HashSet( Arrays.asList( excludes ) ); } public SimpleDependencyRelationship( final Collection sources, final ProjectVersionRef declaring, final ArtifactRef target, final DependencyScope scope, final int index, - final boolean managed, final boolean inherited, final ProjectRef... excludes ) + final boolean managed, final boolean inherited, final boolean optional, + final ProjectRef... excludes ) { super( sources, RelationshipType.DEPENDENCY, declaring, target, index, managed, inherited, false ); this.scope = scope == null ? DependencyScope.compile : scope; + this.optional = optional; this.excludes = new HashSet( Arrays.asList( excludes ) ); } public SimpleDependencyRelationship( final Collection sources, final URI pomLocation, final ProjectVersionRef declaring, final ArtifactRef target, final DependencyScope scope, final int index, final boolean managed, - final boolean inherited, final ProjectRef... excludes ) + final boolean inherited, final boolean optional, final ProjectRef... excludes ) { super( sources, pomLocation, RelationshipType.DEPENDENCY, declaring, target, index, managed, inherited, false ); this.scope = scope == null ? DependencyScope.compile : scope; + this.optional = optional; this.excludes = new HashSet( Arrays.asList( excludes ) ); } @@ -80,6 +88,7 @@ public SimpleDependencyRelationship( final DependencyRelationship relationship ) { super( relationship ); this.scope = relationship.getScope(); + this.optional = relationship.isOptional(); this.excludes = new HashSet( relationship.getExcludes() ); } @@ -89,11 +98,17 @@ public final DependencyScope getScope() return scope; } + @Override + public boolean isOptional() + { + return optional; + } + @Override public synchronized DependencyRelationship cloneFor( final ProjectVersionRef projectRef ) { return new SimpleDependencyRelationship( getSources(), getPomLocation(), projectRef, getTarget(), scope, getIndex(), - isManaged(), isInherited() ); + isManaged(), isInherited(), optional ); } @Override @@ -102,7 +117,7 @@ public DependencyRelationship addSource( final URI source ) Set srcs = getSources(); srcs.add( source ); return new SimpleDependencyRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), scope, getIndex(), - isManaged(), isInherited() ); + isManaged(), isInherited(), optional ); } @Override @@ -111,7 +126,7 @@ public DependencyRelationship addSources( final Collection sources ) Set srcs = getSources(); srcs.addAll( sources ); return new SimpleDependencyRelationship( srcs, getPomLocation(), getDeclaring(), getTarget(), scope, getIndex(), - isManaged(), isInherited() ); + isManaged(), isInherited(), optional ); } @Override @@ -174,7 +189,7 @@ public DependencyRelationship selectDeclaring( final ProjectVersionRef ref ) Set var = getExcludes(); return new SimpleDependencyRelationship( getSources(), getPomLocation(), ref, t, getScope(), getIndex(), isManaged(), - isInherited(), var.toArray( new ProjectRef[var.size()] ) ); + isInherited(), optional, var.toArray( new ProjectRef[var.size()] ) ); } @Override @@ -188,7 +203,7 @@ public DependencyRelationship selectTarget( final ProjectVersionRef ref ) Set var = getExcludes(); return new SimpleDependencyRelationship( getSources(), getPomLocation(), d, t, getScope(), getIndex(), isManaged(), - isInherited(), var.toArray( new ProjectRef[var.size()] ) ); + isInherited(), optional, var.toArray( new ProjectRef[var.size()] ) ); } @Override diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java index f0826bfd..1b1c9d72 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java @@ -35,12 +35,15 @@ public final class SimplePluginDependencyRelationship private final ProjectRef plugin; + private boolean optional; + public SimplePluginDependencyRelationship( final URI source, final ProjectVersionRef declaring, final ProjectRef plugin, final ArtifactRef target, final int index, final boolean managed, final boolean inherited ) { super( source, RelationshipType.PLUGIN_DEP, declaring, target, index, managed, inherited, false ); this.plugin = plugin; + this.optional = optional; } public SimplePluginDependencyRelationship( final URI source, final URI pomLocation, @@ -50,6 +53,7 @@ public SimplePluginDependencyRelationship( final URI source, final URI pomLocati { super( source, pomLocation, RelationshipType.PLUGIN_DEP, declaring, target, index, managed, inherited, false ); this.plugin = plugin; + this.optional = optional; } public SimplePluginDependencyRelationship( final Collection sources, final URI pomLocation, @@ -59,12 +63,14 @@ public SimplePluginDependencyRelationship( final Collection sources, final { super( sources, pomLocation, RelationshipType.PLUGIN_DEP, declaring, target, index, managed, inherited, false ); this.plugin = plugin; + this.optional = optional; } public SimplePluginDependencyRelationship( final PluginDependencyRelationship relationship ) { super( relationship ); this.plugin = new SimpleProjectRef( relationship.getPlugin() ); + this.optional = optional; } @Override @@ -73,6 +79,12 @@ public final ProjectRef getPlugin() return plugin; } + @Override + public boolean isOptional() + { + return optional; + } + @Override public int hashCode() { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/DependencyTreeRelationshipPrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/DependencyTreeRelationshipPrinter.java index dbd06f83..2abd9548 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/DependencyTreeRelationshipPrinter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/DependencyTreeRelationshipPrinter.java @@ -77,8 +77,7 @@ public void print( final ProjectRelationship relationship, final ProjectVe suffix = ":" + dr.getScope() .name(); - if ( dr.getTargetArtifact() - .isOptional() ) + if ( dr.isOptional() ) { localLabels.add( "OPTIONAL" ); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java index 08488b01..8c940d4e 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java @@ -411,33 +411,34 @@ public static PluginDependencyRelationship pluginDependency( final URI source, f } public static DependencyRelationship dependency( final URI source, final ProjectVersionRef owner, final String groupId, final String artifactId, - final String version, final int index, final boolean inherited ) + final String version, final int index, final boolean inherited, final boolean optional ) throws InvalidVersionSpecificationException { - return dependency( source, owner, groupId, artifactId, version, null, null, false, null, index, false, inherited ); + return dependency( source, owner, groupId, artifactId, version, null, null, optional, null, index, false, inherited ); } public static DependencyRelationship dependency( final URI source, final ProjectVersionRef owner, - final ProjectVersionRef dep, final int index, final boolean inherited ) + final ProjectVersionRef dep, final int index, final boolean inherited, + final boolean optional ) throws InvalidVersionSpecificationException { - return dependency( source, owner, dep, null, null, false, null, index, false, inherited ); + return dependency( source, owner, dep, null, null, optional, null, index, false, inherited ); } public static DependencyRelationship dependency( final URI source, final ProjectVersionRef owner, final String groupId, final String artifactId, final String version, final DependencyScope scope, final int index, final boolean managed, - final boolean inherited ) + final boolean inherited, final boolean optional ) throws InvalidVersionSpecificationException { - return dependency( source, owner, groupId, artifactId, version, null, null, false, scope, index, managed, inherited ); + return dependency( source, owner, groupId, artifactId, version, null, null, optional, scope, index, managed, inherited ); } public static DependencyRelationship dependency( final URI source, final ProjectVersionRef owner, final ProjectVersionRef dep, final DependencyScope scope, final int index, final boolean managed, - final boolean inherited ) + final boolean inherited, final boolean optional ) throws InvalidVersionSpecificationException { - return new SimpleDependencyRelationship( source, owner, artifact( dep, null, null, false ), scope, index, managed, inherited ); + return new SimpleDependencyRelationship( source, owner, artifact( dep, null, null, optional ), scope, index, managed, inherited, optional ); } public static DependencyRelationship dependency( final URI source, final ProjectVersionRef owner, final String groupId, final String artifactId, @@ -445,8 +446,8 @@ public static DependencyRelationship dependency( final URI source, final Project final DependencyScope scope, final int index, final boolean managed, final boolean inherited ) throws InvalidVersionSpecificationException { - return new SimpleDependencyRelationship( source, owner, artifact( groupId, artifactId, version, type, classifier, optional ), null, index, - false, inherited ); + return new SimpleDependencyRelationship( source, owner, artifact( groupId, artifactId, version, type, classifier, optional ), scope, index, + managed, inherited, optional ); } public static DependencyRelationship dependency( final URI source, final ProjectVersionRef owner, final ProjectVersionRef dep, final String type, @@ -454,37 +455,39 @@ public static DependencyRelationship dependency( final URI source, final Project final boolean managed, final boolean inherited ) throws InvalidVersionSpecificationException { - return new SimpleDependencyRelationship( source, owner, artifact( dep, type, classifier, optional ), null, index, false, inherited ); + return new SimpleDependencyRelationship( source, owner, artifact( dep, type, classifier, optional ), scope, index, managed, inherited, optional ); } public static DependencyRelationship dependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, final String groupId, - final String artifactId, final String version, final int index, final boolean inherited ) + final String artifactId, final String version, final int index, final boolean inherited, + final boolean optional ) throws InvalidVersionSpecificationException { - return dependency( source, pomLocation, owner, groupId, artifactId, version, null, null, false, null, index, false, inherited ); + return dependency( source, pomLocation, owner, groupId, artifactId, version, null, null, optional, null, index, false, inherited ); } public static DependencyRelationship dependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, - final ProjectVersionRef dep, final int index, final boolean inherited ) + final ProjectVersionRef dep, final int index, final boolean inherited, + final boolean optional ) throws InvalidVersionSpecificationException { - return dependency( source, pomLocation, owner, dep, null, null, false, null, index, false, inherited ); + return dependency( source, pomLocation, owner, dep, null, null, optional, null, index, false, inherited ); } public static DependencyRelationship dependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, final String groupId, final String artifactId, final String version, final DependencyScope scope, final int index, - final boolean managed, final boolean inherited ) + final boolean managed, final boolean inherited, final boolean optional ) throws InvalidVersionSpecificationException { - return dependency( source, pomLocation, owner, groupId, artifactId, version, null, null, false, scope, index, managed, inherited ); + return dependency( source, pomLocation, owner, groupId, artifactId, version, null, null, optional, scope, index, managed, inherited ); } public static DependencyRelationship dependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, final ProjectVersionRef dep, final DependencyScope scope, final int index, - final boolean managed, final boolean inherited ) + final boolean managed, final boolean inherited, final boolean optional ) throws InvalidVersionSpecificationException { - return new SimpleDependencyRelationship( source, pomLocation, owner, artifact( dep, null, null, false ), scope, index, managed, inherited ); + return new SimpleDependencyRelationship( source, pomLocation, owner, artifact( dep, null, null, optional ), scope, index, managed, inherited, optional ); } public static DependencyRelationship dependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, final String groupId, @@ -493,8 +496,8 @@ public static DependencyRelationship dependency( final URI source, final URI pom final boolean inherited ) throws InvalidVersionSpecificationException { - return new SimpleDependencyRelationship( source, pomLocation, owner, artifact( groupId, artifactId, version, type, classifier, optional ), null, - index, false, inherited ); + return new SimpleDependencyRelationship( source, pomLocation, owner, artifact( groupId, artifactId, version, type, classifier, optional ), scope, + index, managed, inherited, optional ); } public static DependencyRelationship dependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, @@ -502,7 +505,7 @@ public static DependencyRelationship dependency( final URI source, final URI pom final DependencyScope scope, final int index, final boolean managed, final boolean inherited ) throws InvalidVersionSpecificationException { - return new SimpleDependencyRelationship( source, pomLocation, owner, artifact( dep, type, classifier, optional ), null, index, false, inherited ); + return new SimpleDependencyRelationship( source, pomLocation, owner, artifact( dep, type, classifier, optional ), scope, index, managed, inherited, optional ); } public static Set getRelationshipTypes( final ProjectRelationshipFilter filter ) diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java index c34d69e0..3f4f49e8 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java @@ -62,11 +62,11 @@ public void builderWith2Dependencies2PluginsAParentAndAnExtension() final DependencyRelationship papi = new SimpleDependencyRelationship( source, p, new SimpleArtifactRef( "org.apache.maven", "maven-plugin-api", "3.0.3", null, null, false ), DependencyScope.compile, - idx++, false, false ); + idx++, false, false, false ); final DependencyRelationship art = new SimpleDependencyRelationship( source, p, new SimpleArtifactRef( "org.apache.maven", "maven-artifact", "3.0.3", null, null, false ), DependencyScope.compile, - idx++, false, false ); + idx++, false, false, false ); final PluginRelationship jarp = new SimplePluginRelationship( source, p, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-jar-plugin", "2.2" ), pidx++, false, false ); diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java index 97fb5a8c..b48a52e5 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java @@ -50,7 +50,7 @@ public void rejectTestScopeForRuntimeFilter() final DependencyRelationship rel = new SimpleDependencyRelationship( testURI(), new SimpleProjectVersionRef( "g", "a", "1" ), new SimpleArtifactRef( "g", "b", "2", "jar", null, false ), DependencyScope.test, 0, - false, false ); + false, false, false ); assertThat( filter.accept( rel ), equalTo( false ) ); } diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparatorTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparatorTest.java index 13651e2a..b0395714 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparatorTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparatorTest.java @@ -57,8 +57,8 @@ public void sortParentDependencyPathAheadOfDirectDependency() final ProjectVersionRef dep = projectVersion( "org.group", "dep-1", "1.0" ); final URI source = testURI(); - rels.add( dependency( source, root, dep, 0, false ) ); - rels.add( dependency( source, dep, projectVersion( "org.foo", "bar", "1.0" ), 0, false ) ); + rels.add( dependency( source, root, dep, 0, false, false ) ); + rels.add( dependency( source, dep, projectVersion( "org.foo", "bar", "1.0" ), 0, false, false ) ); paths.add( rels ); @@ -67,7 +67,7 @@ public void sortParentDependencyPathAheadOfDirectDependency() final ProjectVersionRef parent = projectVersion( "group.id", "parent", "1" ); rels.add( new SimpleParentRelationship( source, root, parent ) ); - rels.add( dependency( source, parent, "org.foo", "bar", "1.1.1", 0, false ) ); + rels.add( dependency( source, parent, "org.foo", "bar", "1.1.1", 0, false, false ) ); paths.add( rels ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java index a852378d..95872528 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java @@ -55,7 +55,7 @@ public void run() for ( int i = 0; i < 550; i++ ) { rels.add(new SimpleDependencyRelationship( sourceURI(), RelationshipUtils.POM_ROOT_URI, myRef, newArtifact(), - DependencyScope.compile, i, false, false ) ); + DependencyScope.compile, i, false, false, false ) ); } final RelationshipGraph graph = simpleGraph( myRef ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BackToRootTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BackToRootTCK.java index a6afe4de..228c4b8d 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BackToRootTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BackToRootTCK.java @@ -55,9 +55,9 @@ public void run() final RelationshipGraph graph = simpleGraph( project ); /* @formatter:off */ - graph.storeRelationships( new SimpleDependencyRelationship( source, project, dep.asJarArtifact(), null, 0, false, false ), - new SimpleDependencyRelationship( source, dep, dep2.asJarArtifact(), null, 0, false, false ), - new SimpleDependencyRelationship( source, dep2, project.asJarArtifact(), null, 0, false, false ) ); + graph.storeRelationships( new SimpleDependencyRelationship( source, project, dep.asJarArtifact(), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, dep, dep2.asJarArtifact(), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, dep2, project.asJarArtifact(), null, 0, false, false, false ) ); /* @formatter:on */ // final EProjectGraph graph = getManager().getGraph( session, project ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java index d04ac2b3..f324b2f5 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java @@ -56,9 +56,9 @@ public void run() /* @formatter:off */ final Set> rejected = graph.storeRelationships( - new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null, false ), null, 0, false, false ), - new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null, false ), null, 0, false, false ), - new SimpleDependencyRelationship( source, dep2, new SimpleArtifactRef( dep, null, null, false ), null, 0, false, false ) ); + new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null, false ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null, false ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, dep2, new SimpleArtifactRef( dep, null, null, false ), null, 0, false, false, false ) ); /* @formatter:on */ assertThat( rejected, notNullValue() ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java index b75ede46..84dfd62c 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java @@ -60,11 +60,11 @@ public void run() /* @formatter:off */ // a --> b --> c --> a // d --> e --> c --> a --> b --> c - graph.storeRelationships( new SimpleDependencyRelationship( source, a, new SimpleArtifactRef( b, null, null, false ), null, 0, false, false ), - new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( a, null, null, false ), null, 0, false, false ), + graph.storeRelationships( new SimpleDependencyRelationship( source, a, new SimpleArtifactRef( b, null, null, false ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( a, null, null, false ), null, 0, false, false, false ), new SimplePluginRelationship( source, b, c, 0, false, false ), - new SimpleDependencyRelationship( source, d, new SimpleArtifactRef( e, null, null, false ), null, 0, false, false ), - new SimpleDependencyRelationship( source, e, new SimpleArtifactRef( c, null, null, false ), null, 0, false, false ) ); + new SimpleDependencyRelationship( source, d, new SimpleArtifactRef( e, null, null, false ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, e, new SimpleArtifactRef( c, null, null, false ), null, 0, false, false, false ) ); /* @formatter:on */ final RelationshipGraph graph2 = diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java index 199938dd..a7f47bc0 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java @@ -55,10 +55,10 @@ public void run() final RelationshipGraph graph = simpleGraph( project ); /* @formatter:off */ - graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null, false ), null, 0, false, false ), - new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null, false ), null, 0, false, false ) ); + graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null, false ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null, false ), null, 0, false, false, false ) ); - final boolean introduces = graph.introducesCycle( new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( project, null, null, false ), null, 0, false, false ) ); + final boolean introduces = graph.introducesCycle( new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( project, null, null, false ), null, 0, false, false, false ) ); /* @formatter:on */ assertThat( introduces, equalTo( true ) ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java index 29233605..131d5c14 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java @@ -58,11 +58,11 @@ public void run() /* @formatter:off */ // a --> b --> c --> a // d --> e --> c --> a --> b --> c - graph.storeRelationships( new SimpleDependencyRelationship( source, a, new SimpleArtifactRef( b, null, null, false ), null, 0, false, false ), - new SimpleDependencyRelationship( source, b, new SimpleArtifactRef( c, null, null, false ), null, 0, false, false ), - new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( a, null, null, false ), null, 0, false, false ), - new SimpleDependencyRelationship( source, d, new SimpleArtifactRef( e, null, null, false ), null, 0, false, false ), - new SimpleDependencyRelationship( source, e, new SimpleArtifactRef( c, null, null, false ), null, 0, false, false ) ); + graph.storeRelationships( new SimpleDependencyRelationship( source, a, new SimpleArtifactRef( b, null, null, false ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, b, new SimpleArtifactRef( c, null, null, false ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( a, null, null, false ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, d, new SimpleArtifactRef( e, null, null, false ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, e, new SimpleArtifactRef( c, null, null, false ), null, 0, false, false, false ) ); /* @formatter:on */ final RelationshipGraph graph2 = diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_NullPathOnTargetExprVersionTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_NullPathOnTargetExprVersionTCK.java index 66e5820b..3f0489ee 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_NullPathOnTargetExprVersionTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_NullPathOnTargetExprVersionTCK.java @@ -52,7 +52,7 @@ public void run() final URI src = new URI( "test:source-uri" ); final ProjectRelationship rel = - new SimpleDependencyRelationship( src, from, to.asArtifactRef( "jar", null ), DependencyScope.compile, 0, false, false ); + new SimpleDependencyRelationship( src, from, to.asArtifactRef( "jar", null ), DependencyScope.compile, 0, false, false, false ); final RelationshipGraph graph = simpleGraph( from ); final GraphPath path = graph.createPath( rel ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java index 87a07690..75ecabb6 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java @@ -60,9 +60,9 @@ public void run() graph.storeRelationships( new SimpleParentRelationship(src, gav), new SimpleDependencyRelationship(src, gav, d1.asArtifactRef("jar", - null), DependencyScope.compile, 0, true, false ), + null), DependencyScope.compile, 0, true, false, false ), new SimpleDependencyRelationship(src, gav, d2.asArtifactRef("jar", - null), DependencyScope.compile, 1, true, false )); + null), DependencyScope.compile, 1, true, false, false )); /* @formatter:on */ graph.containsGraph( gav ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java index 99480bbe..54a0f0a2 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java @@ -52,8 +52,8 @@ public void run() final RelationshipGraph graph = simpleGraph( project ); /* @formatter:off */ - graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false, false ), - new SimpleDependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false, false ) ); + graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false, false, false ) ); /* @formatter:on */ Set variables = graph.getVariableSubgraphs(); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelection_ContextualToViewTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelection_ContextualToViewTCK.java index 63303026..30d0c702 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelection_ContextualToViewTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelection_ContextualToViewTCK.java @@ -49,8 +49,8 @@ public void run() final RelationshipGraph graph = simpleGraph( project ); /* @formatter:off */ - graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false, false ), - new SimpleDependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false, false ) ); + graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false, false, false ) ); /* @formatter:on */ Set variables = graph.getVariableSubgraphs(); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java index d29523cc..1eefa869 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java @@ -49,13 +49,13 @@ public void run() /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( source, myRef, parentRef ), - new SimpleDependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "foo", "1.0" ), null, null, false ), null, 0, false, false ), - new SimpleDependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "bar", "1.2.1" ), null, null, false ), null, 1, false, false ), + new SimpleDependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "foo", "1.0" ), null, null, false ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "bar", "1.2.1" ), null, null, false ), null, 1, false, false, false ), new SimplePluginRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.5.1" ), 0, false, false ), new SimplePluginRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins","maven-jar-plugin", "2.2" ), 1, false, false ), new SimpleExtensionRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.5.1" ), 0, false ), new SimpleParentRelationship( source, parentRef, grandRef ), - new SimpleDependencyRelationship( source, parentRef, new SimpleProjectVersionRef( "other.group", "utils", "3-1" ).asJarArtifact(), null, 0, false, false ) + new SimpleDependencyRelationship( source, parentRef, new SimpleProjectVersionRef( "other.group", "utils", "3-1" ).asJarArtifact(), null, 0, false, false, false ) ); /* @formatter:on */ diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java index 7bcfd344..10589876 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java @@ -64,10 +64,10 @@ public void run() /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( source, c ), - new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false ), + new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false, false ), new SimplePluginRelationship( source, c, pb, 0, false, false ), - new SimpleDependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false, false ), - new SimpleDependencyRelationship( source, b, a.asJarArtifact(), null, 0, false, false ) + new SimpleDependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, b, a.asJarArtifact(), null, 0, false, false, false ) ); /* @formatter:on */ diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java index 35527d55..89df7965 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java @@ -61,9 +61,9 @@ public void run() /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( c ), - new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false, d ), - new SimpleDependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false, false ), - new SimpleDependencyRelationship( source, b, d.asJarArtifact(), DependencyScope.runtime, 1, false, false ) + new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false, false, d ), + new SimpleDependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false, false, false ), + new SimpleDependencyRelationship( source, b, d.asJarArtifact(), DependencyScope.runtime, 1, false, false, false ) ); /* @formatter:on */ diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java index cd376373..d5afd24c 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java @@ -65,8 +65,8 @@ public void run() /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( source, c ), new SimpleParentRelationship( source, b, p ), - new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false ), - new SimpleDependencyRelationship( source, b, a.asJarArtifact(), null, 0, false, false ) + new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, b, a.asJarArtifact(), null, 0, false, false, false ) ); /* @formatter:on */ diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java index d2dcf467..3b5c1d65 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java @@ -66,12 +66,12 @@ public void run() /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( source, c ), - new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false ), - new SimpleDependencyRelationship( source, c, d.asJarArtifact(), DependencyScope.test, 1, false, false ), + new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, c, d.asJarArtifact(), DependencyScope.test, 1, false, false, false ), new SimplePluginRelationship( source, c, pb, 0, false, false ), - new SimpleDependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false, false ), - new SimpleDependencyRelationship( source, d, e.asJarArtifact(), DependencyScope.runtime, 0, false, false ), - new SimpleDependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false, false ) + new SimpleDependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false, false, false ), + new SimpleDependencyRelationship( source, d, e.asJarArtifact(), DependencyScope.runtime, 0, false, false, false ), + new SimpleDependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false, false, false ) ); /* @formatter:on */ diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java index 2f1df275..681ecb22 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java @@ -59,8 +59,8 @@ public void run() final RelationshipGraph graph = simpleGraph( c ); /* @formatter:off */ - graph.storeRelationships( new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( b, null, null, false ), null, 0, false, false ), - new SimpleDependencyRelationship( source, b, new SimpleArtifactRef( a, null, null, false ), null, 0, false, false ) ); + graph.storeRelationships( new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( b, null, null, false ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, b, new SimpleArtifactRef( a, null, null, false ), null, 0, false, false, false ) ); /* @formatter:on */ assertThat( graph.getAllRelationships() diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java index 48a9cf07..52e4bfad 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java @@ -66,10 +66,10 @@ public void run() /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( source, c ), - new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false ), + new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false, false ), new SimplePluginRelationship( source, c, pb, 0, false, false ), - new SimpleDependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false, false ), - new SimpleDependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false, false ) + new SimpleDependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false, false, false ), + new SimpleDependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false, false, false ) ); /* @formatter:on */ diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDepTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDepTCK.java index 5a8eeb7c..2779e9b2 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDepTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDepTCK.java @@ -51,8 +51,8 @@ public void run() /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( source, root ), - new SimpleDependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false, false ), - new SimpleDependencyRelationship( source, d1, d2.asJarArtifact(), compile, 0, false, false ) + new SimpleDependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false, false, false ), + new SimpleDependencyRelationship( source, d1, d2.asJarArtifact(), compile, 0, false, false, false ) ); /* @formatter:on */ diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDep_ExtMgmtTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDep_ExtMgmtTCK.java index 36cb236e..ff3e078f 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDep_ExtMgmtTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDep_ExtMgmtTCK.java @@ -52,8 +52,8 @@ public void run() /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( source, root ), - new SimpleDependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false, false ), - new SimpleDependencyRelationship( source, d1, d2.asJarArtifact(), compile, 0, false, false ) + new SimpleDependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false, false, false ), + new SimpleDependencyRelationship( source, d1, d2.asJarArtifact(), compile, 0, false, false, false ) ); /* @formatter:on */ diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferDirectTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferDirectTCK.java index 3b9f6a02..78fee1ed 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferDirectTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferDirectTCK.java @@ -52,9 +52,9 @@ public void run() /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( source, root ), - new SimpleDependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false, false ), - new SimpleDependencyRelationship( source, root, d2a.asJarArtifact(), compile, 1, false, false ), - new SimpleDependencyRelationship( source, d1, d2b.asJarArtifact(), compile, 0, false, false ) + new SimpleDependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false, false, false ), + new SimpleDependencyRelationship( source, root, d2a.asJarArtifact(), compile, 1, false, false, false ), + new SimpleDependencyRelationship( source, d1, d2b.asJarArtifact(), compile, 0, false, false, false ) ); /* @formatter:on */ diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferLocalTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferLocalTCK.java index 127d6ac0..d38ba9cc 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferLocalTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferLocalTCK.java @@ -53,8 +53,8 @@ public void run() /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( source, root, parent ), - new SimpleDependencyRelationship( source, root, d1a.asJarArtifact(), compile, 0, false, false ), - new SimpleDependencyRelationship( source, parent, d1b.asJarArtifact(), compile, 0, false, false ) + new SimpleDependencyRelationship( source, root, d1a.asJarArtifact(), compile, 0, false, false, false ), + new SimpleDependencyRelationship( source, parent, d1b.asJarArtifact(), compile, 0, false, false, false ) ); /* @formatter:on */ From 3d29d20cb6e6dd0a62d1438111203e57f756e273 Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Wed, 13 Jan 2016 23:05:20 +0100 Subject: [PATCH 127/240] Remove optional flag from ArtifactRef It was added into DependencyRelationship instead --- .../atlas/graph/spi/neo4j/io/Conversions.java | 3 +- .../graph/spi/neo4j/model/NeoArtifactRef.java | 53 ++++-------------- .../spi/neo4j/model/NeoIdentityUtils.java | 15 ++--- .../neo4j/model/NeoPluginRelationship.java | 2 +- .../graph/spi/neo4j/model/NeoProjectRef.java | 28 +++------- .../spi/neo4j/model/NeoProjectVersionRef.java | 23 ++------ .../model/NeoVersionlessArtifactRef.java | 47 +++------------- ...ProjectVersionRefSerializerModuleTest.java | 2 +- .../spi/neo4j/model/NeoIdentitiesTest.java | 2 +- .../maven/atlas/ident/ref/ArtifactRef.java | 5 +- .../maven/atlas/ident/ref/ProjectRef.java | 4 -- .../atlas/ident/ref/ProjectVersionRef.java | 4 -- .../atlas/ident/ref/SimpleArtifactRef.java | 48 ++++------------ .../atlas/ident/ref/SimpleProjectRef.java | 26 +++------ .../ident/ref/SimpleProjectVersionRef.java | 27 +++------ .../ref/SimpleVersionlessArtifactRef.java | 56 ++++--------------- .../ident/ref/VersionlessArtifactRef.java | 7 --- .../atlas/ident/util/ArtifactPathInfo.java | 2 +- .../maven/atlas/ident/util/IdentityUtils.java | 13 ++--- .../ident/ref/VersionlessArtifactRefTest.java | 24 ++++---- .../model/EProjectDirectRelationships.java | 2 +- .../rel/SimpleDependencyRelationship.java | 2 +- .../rel/SimpleExtensionRelationship.java | 2 +- .../graph/rel/SimpleParentRelationship.java | 2 +- .../SimplePluginDependencyRelationship.java | 2 +- .../graph/rel/SimplePluginRelationship.java | 2 +- .../atlas/graph/util/RelationshipUtils.java | 20 +++---- .../graph/EProjectRelationshipsTest.java | 4 +- .../graph/filter/DependencyFilterTest.java | 2 +- .../tck/graph/batch/LargeBatchInsertTCK.java | 2 +- .../CycleDetection_BetweenDepLevelsTCK.java | 6 +- .../CycleDetection_FilterRemovesCycleTCK.java | 8 +-- ...CycleDetection_IntroduceToExistingTCK.java | 6 +- .../CycleDetection_RootDependentTCK.java | 10 ++-- .../graph/selection/SubGraphSelectionTCK.java | 4 +- ...SubGraphSelection_ContextualToViewTCK.java | 4 +- ...stryTraversal_IgnoreNonParentRels_TCK.java | 4 +- .../SimpleDependencyBuildOrderTCK.java | 4 +- 38 files changed, 145 insertions(+), 332 deletions(-) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java index 5f802fca..a0c96156 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java @@ -590,9 +590,8 @@ private static ArtifactRef toArtifactRef( final ProjectVersionRef ref, final Rel final String type = getStringProperty( TYPE, rel ); final String classifier = getStringProperty( CLASSIFIER, rel ); - final boolean optional = getBooleanProperty( OPTIONAL, rel ); - return new NeoArtifactRef( ref, new NeoTypeAndClassifier( rel ), optional ); + return new NeoArtifactRef( ref, new NeoTypeAndClassifier( rel ) ); } private static void toRelationshipProperties( final ArtifactRef target, final Relationship relationship ) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java index a120b24b..1164a9ae 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java @@ -34,12 +34,12 @@ /** * Represents an artifact, in Maven parlance. A tangible result of a build, which is typically made available in a Maven repository for others * to consume. NOTE: a POM file is both a piece of metadata AND an artifact in the Maven world! - * + * * Artifacts are based on the GAV coordinate for the project release, but also contain a type and optionally, a classifier. Type defaults to 'jar'. - * + * * @see {@link NeoProjectRef} * @see {@link NeoProjectVersionRef} - * + * * @author jdcasey */ public class NeoArtifactRef @@ -51,32 +51,27 @@ public class NeoArtifactRef private NeoTypeAndClassifier tc; - private Boolean optional; - public NeoArtifactRef( final String groupId, final String artifactId, final VersionSpec version, final String type, - final String classifier, final boolean optional ) + final String classifier ) { super( groupId, artifactId, version ); - this.optional = optional; this.tc = new NeoTypeAndClassifier( type, classifier ); } - public NeoArtifactRef( final NeoProjectVersionRef ref, final String type, final String classifier, - final boolean optional ) + public NeoArtifactRef( final NeoProjectVersionRef ref, final String type, final String classifier ) { - this( ref, new NeoTypeAndClassifier( type, classifier ), optional ); + this( ref, new NeoTypeAndClassifier( type, classifier ) ); } public NeoArtifactRef( final NeoProjectVersionRef ref ) { - this( ref, new NeoTypeAndClassifier( "pom", null ), false ); + this( ref, new NeoTypeAndClassifier( "pom", null ) ); } - public NeoArtifactRef( final ProjectVersionRef ref, final NeoTypeAndClassifier tc, final Boolean optional ) + public NeoArtifactRef( final ProjectVersionRef ref, final NeoTypeAndClassifier tc ) { super( ref ); this.tc = tc; - this.optional = optional; } public NeoArtifactRef( final Node node ) @@ -86,12 +81,11 @@ public NeoArtifactRef( final Node node ) } public NeoArtifactRef( final String groupId, final String artifactId, final String versionSpec, final String type, - final String classifier, final boolean optional ) + final String classifier ) throws InvalidVersionSpecificationException { super( groupId, artifactId, versionSpec ); this.tc = new NeoTypeAndClassifier( type, classifier ); - this.optional = optional; } @Override @@ -134,13 +128,13 @@ public static NeoArtifactRef parse( final String spec ) // assume non-optional, because it might not matter if you're parsing a string like this...you'd be more careful if you were reading something // that had an optional field, because it's not in the normal GATV[C] spec. - return new NeoArtifactRef( g, a, v, t, c, false ); + return new NeoArtifactRef( g, a, v, t, c ); } @Override public NeoArtifactRef newRef( final String groupId, final String artifactId, final SingleVersion version ) { - return new NeoArtifactRef( groupId, artifactId, version, tc.getType(), tc.getClassifier(), isOptional() ); + return new NeoArtifactRef( groupId, artifactId, version, tc.getType(), tc.getClassifier() ); } @Override @@ -161,30 +155,12 @@ public TypeAndClassifier getTypeAndClassifier() return tc; } - public NeoArtifactRef setOptional( final boolean optional ) - { - if ( isOptional() == optional ) - { - return this; - } - - return new NeoArtifactRef( this, getType(), getClassifier(), optional ); - } - - @Override - public boolean isOptional() - { - return getBooleanProperty( container, Conversions.OPTIONAL, optional, false ); - } - @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ( ( tc == null ) ? 0 : tc.hashCode() ); - result = prime * result + Boolean.valueOf( isOptional() ) - .hashCode(); return result; } @@ -241,15 +217,10 @@ public boolean versionlessEquals( final ProjectVersionRef other ) return artifactFieldsEqual( (ArtifactRef) other ); } - public Boolean getDirtyOptionalFlag() - { - return optional; - } - @Override public boolean isDirty() { - return super.isDirty() || optional != null || tc.isDirty(); + return super.isDirty() || tc.isDirty(); } @Override diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentityUtils.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentityUtils.java index cd735b40..46b69aa6 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentityUtils.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentityUtils.java @@ -33,7 +33,7 @@ public final class NeoIdentityUtils private NeoIdentityUtils(){} - public static String getStringProperty( PropertyContainer container, String named, String memVal ) + public static String getStringProperty( final PropertyContainer container, final String named, final String memVal ) { if ( memVal != null ) { @@ -49,7 +49,7 @@ public static String getStringProperty( PropertyContainer container, String name return v; } - public static String getStringProperty( PropertyContainer container, String named, String memVal, String defaultVal ) + public static String getStringProperty( final PropertyContainer container, final String named, final String memVal, final String defaultVal ) { // Logger logger = LoggerFactory.getLogger( NeoIdentityUtils.class ); // logger.debug( "Looking for property: {} in: {}.\nMemory value: {}\nDefault value: {}", named, container, memVal, defaultVal); @@ -64,7 +64,7 @@ public static String getStringProperty( PropertyContainer container, String name return memVal; } - public static boolean getBooleanProperty( PropertyContainer container, String named, Boolean memVal, boolean defaultVal ) + public static boolean getBooleanProperty( final PropertyContainer container, final String named, final Boolean memVal, final boolean defaultVal ) { if ( memVal != null ) { @@ -75,24 +75,21 @@ public static boolean getBooleanProperty( PropertyContainer container, String na return v == null ? defaultVal : v; } - public static ArtifactRef newNeoArtifactRef( ProjectVersionRef ref, ArtifactRef target ) + public static ArtifactRef newNeoArtifactRef( final ProjectVersionRef ref, final ArtifactRef target ) { NeoTypeAndClassifier tc; - Boolean optional; if ( target instanceof NeoArtifactRef ) { tc = (NeoTypeAndClassifier) target.getTypeAndClassifier(); - optional = ( (NeoArtifactRef) target ).getDirtyOptionalFlag(); } else { tc = new NeoTypeAndClassifier( target.getType(), target.getClassifier() ); - optional = target.isOptional(); } - return new NeoArtifactRef( ref, tc, optional ); + return new NeoArtifactRef( ref, tc ); } - public static int getIntegerProperty( PropertyContainer container, String named, Integer memVal, int defaultVal ) + public static int getIntegerProperty( final PropertyContainer container, final String named, final Integer memVal, final int defaultVal ) { if ( memVal != null ) { diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java index 5ff0b608..d155bddf 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java @@ -99,7 +99,7 @@ public ProjectVersionRef getTarget() @Override public ArtifactRef getTargetArtifact() { - return new SimpleArtifactRef( getTarget(), "maven-plugin", null, false ); + return new SimpleArtifactRef( getTarget(), "maven-plugin", null ); } @Override diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java index d97e5681..ed62105f 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java @@ -52,7 +52,7 @@ public class NeoProjectRef private String artifactIdProperty = Conversions.ARTIFACT_ID; - public NeoProjectRef(ProjectRef ref) + public NeoProjectRef(final ProjectRef ref) { if ( ref instanceof NeoProjectRef) { @@ -82,7 +82,7 @@ public NeoProjectRef( final String groupId, final String artifactId ) } } - public NeoProjectRef( Node container ) + public NeoProjectRef( final Node container ) { this.container = container; if ( isEmpty( getGroupId() ) || isEmpty( getArtifactId() ) ) @@ -92,7 +92,7 @@ public NeoProjectRef( Node container ) } } - public NeoProjectRef( PropertyContainer container, String groupIdProperty, String artifactIdProperty ) + public NeoProjectRef( final PropertyContainer container, final String groupIdProperty, final String artifactIdProperty ) { Logger logger = LoggerFactory.getLogger( getClass() ); logger.debug( "setting up project ref on container: {} with gid prop: {} and aid prop: {}", container, @@ -136,38 +136,25 @@ public ProjectRef asProjectRef() @Override public VersionlessArtifactRef asVersionlessPomArtifact() { - return asVersionlessArtifactRef( "pom", null, false ); + return asVersionlessArtifactRef( "pom", null ); } @Override public VersionlessArtifactRef asVersionlessJarArtifact() { - return asVersionlessArtifactRef( "jar", null, false ); + return asVersionlessArtifactRef( "jar", null ); } @Override public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier ) { - return asVersionlessArtifactRef( type, classifier, false ); - } - - @Override - public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier, - final boolean optional ) - { - return new NeoVersionlessArtifactRef( this, type, classifier, optional ); + return new NeoVersionlessArtifactRef( this, type, classifier ); } @Override public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc ) { - return asVersionlessArtifactRef( tc, false ); - } - - @Override - public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc, final boolean optional ) - { - return new NeoVersionlessArtifactRef( this, tc, optional ); + return new NeoVersionlessArtifactRef( this, tc ); } @Override @@ -209,6 +196,7 @@ public boolean equals( final Object obj ) return getGroupId().equals( other.getGroupId() ); } + @Override public int compareTo( final ProjectRef o ) { int comp = getGroupId().compareTo( o.getGroupId() ); diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java index 5b020f52..12db8da9 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java @@ -82,7 +82,7 @@ public NeoProjectVersionRef( final String groupId, final String artifactId, fina this( groupId, artifactId, null, versionString ); } - public NeoProjectVersionRef( ProjectVersionRef ref ) + public NeoProjectVersionRef( final ProjectVersionRef ref ) { super( ref ); if ( container == null ) @@ -121,41 +121,29 @@ public ProjectVersionRef asProjectVersionRef() @Override public ArtifactRef asPomArtifact() { - return asArtifactRef( "pom", null, false ); + return asArtifactRef( "pom", null ); } @Override public ArtifactRef asJarArtifact() { - return asArtifactRef( "jar", null, false ); + return asArtifactRef( "jar", null ); } @Override public ArtifactRef asArtifactRef( final String type, final String classifier ) { - return asArtifactRef( type, classifier, false ); - } - - @Override - public ArtifactRef asArtifactRef( final String type, final String classifier, final boolean optional ) - { - return new NeoArtifactRef( this, type, classifier, optional ); + return new NeoArtifactRef( this, type, classifier ); } @Override public ArtifactRef asArtifactRef( final TypeAndClassifier tc ) - { - return asArtifactRef( tc, false ); - } - - @Override - public ArtifactRef asArtifactRef( final TypeAndClassifier tc, final boolean optional ) { NeoTypeAndClassifier ntc = ( tc instanceof NeoTypeAndClassifier ) ? (NeoTypeAndClassifier) tc : new NeoTypeAndClassifier( tc.getType(), tc.getClassifier() ); - return new NeoArtifactRef( this, ntc, optional ); + return new NeoArtifactRef( this, ntc ); } @Override @@ -253,6 +241,7 @@ public int hashCode() return result; } + @Override public boolean versionlessEquals( final ProjectVersionRef other ) { return this == other || super.equals( other ); diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java index fcc1103d..7e7922d5 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java @@ -40,28 +40,22 @@ public class NeoVersionlessArtifactRef private TypeAndClassifier tc; - private boolean optional; - public NeoVersionlessArtifactRef( final ArtifactRef ref ) { super( ref.getGroupId(), ref.getArtifactId() ); - this.optional = ref.isOptional(); this.tc = ref.getTypeAndClassifier(); } - public NeoVersionlessArtifactRef( final ProjectRef ref, final String type, final String classifier, - final boolean optional ) + public NeoVersionlessArtifactRef( final ProjectRef ref, final String type, final String classifier ) { super( ref.getGroupId(), ref.getArtifactId() ); - this.optional = optional; this.tc = new NeoTypeAndClassifier( type, classifier ); } - public NeoVersionlessArtifactRef( final ProjectRef ref, final TypeAndClassifier tc, final boolean optional ) + public NeoVersionlessArtifactRef( final ProjectRef ref, final TypeAndClassifier tc ) { super( ref.getGroupId(), ref.getArtifactId() ); this.tc = tc == null ? new NeoTypeAndClassifier() : tc; - this.optional = optional; } public NeoVersionlessArtifactRef( final String groupId, final String artifactId, final String type, @@ -70,7 +64,6 @@ public NeoVersionlessArtifactRef( final String groupId, final String artifactId, { super( groupId, artifactId ); this.tc = new NeoTypeAndClassifier( type, classifier ); - this.optional = optional; } @Override @@ -138,18 +131,11 @@ public TypeAndClassifier getTypeAndClassifier() return tc; } - @Override - public boolean isOptional() - { - return optional; - } - @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); - result = prime * result + ( optional ? 1231 : 1237 ); result = prime * result + ( ( tc == null ) ? 0 : tc.hashCode() ); return result; } @@ -170,10 +156,6 @@ public boolean equals( final Object obj ) return false; } final VersionlessArtifactRef other = (VersionlessArtifactRef) obj; - if ( optional != other.isOptional() ) - { - return false; - } if ( tc == null ) { if ( other.getTypeAndClassifier() != null ) @@ -191,49 +173,36 @@ else if ( !tc.equals( other.getTypeAndClassifier() ) ) @Override public VersionlessArtifactRef asVersionlessPomArtifact() { - return asVersionlessArtifactRef( "pom", null, false ); + return asVersionlessArtifactRef( "pom", null ); } @Override public VersionlessArtifactRef asVersionlessJarArtifact() { - return asVersionlessArtifactRef( "jar", null, false ); + return asVersionlessArtifactRef( "jar", null ); } @Override public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier ) - { - return asVersionlessArtifactRef( type, classifier, false ); - } - - @Override - public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier, - final boolean optional ) { final TypeAndClassifier tc = new NeoTypeAndClassifier( type, classifier ); - if ( NeoVersionlessArtifactRef.class.equals( getClass() ) && this.tc.equals( tc ) && this.optional == optional ) + if ( NeoVersionlessArtifactRef.class.equals( getClass() ) && this.tc.equals( tc ) ) { return this; } - return super.asVersionlessArtifactRef( type, classifier, optional ); + return super.asVersionlessArtifactRef( type, classifier ); } @Override public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc ) { - return asVersionlessArtifactRef( tc, false ); - } - - @Override - public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc, final boolean optional ) - { - if ( NeoVersionlessArtifactRef.class.equals( getClass() ) && this.tc.equals( tc ) && this.optional == optional ) + if ( NeoVersionlessArtifactRef.class.equals( getClass() ) && this.tc.equals( tc ) ) { return this; } - return super.asVersionlessArtifactRef( tc, optional ); + return super.asVersionlessArtifactRef( tc ); } @Override diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectVersionRefSerializerModuleTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectVersionRefSerializerModuleTest.java index 28d61700..117eb814 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectVersionRefSerializerModuleTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectVersionRefSerializerModuleTest.java @@ -111,7 +111,7 @@ public void roundTripArtifactRef() throws IOException { ArtifactRef aref = new SimpleArtifactRef( new SimpleProjectVersionRef( "org.foo", "bar", "1" ), - new SimpleTypeAndClassifier( "jar", null ), false ); + new SimpleTypeAndClassifier( "jar", null ) ); String json = mapper.writeValueAsString( aref ); diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java index ea66718a..94d29311 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java @@ -99,7 +99,7 @@ public void projectVersionRefCrossImplEquality() public void artifactRefCrossImplEquality() { ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); - ArtifactRef aref = new SimpleArtifactRef( pvr, "jar", null, false ); + ArtifactRef aref = new SimpleArtifactRef( pvr, "jar", null ); Node node = toNode( aref ); NeoArtifactRef naref = new NeoArtifactRef( node ); diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java index 73f4fa95..21f8086e 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java @@ -29,9 +29,6 @@ public interface ArtifactRef TypeAndClassifier getTypeAndClassifier(); - boolean isOptional(); - - ArtifactRef setOptional(boolean optional ); - + @Override boolean versionlessEquals( ProjectVersionRef other ); } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java index 4d58c697..9e0ea881 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java @@ -35,11 +35,7 @@ public interface ProjectRef VersionlessArtifactRef asVersionlessArtifactRef( String type, String classifier ); - VersionlessArtifactRef asVersionlessArtifactRef( String type, String classifier, boolean optional ); - VersionlessArtifactRef asVersionlessArtifactRef( TypeAndClassifier tc ); - VersionlessArtifactRef asVersionlessArtifactRef( TypeAndClassifier tc, boolean optional ); - boolean matches( ProjectRef ref ); } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java index 41692621..7f5c6014 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java @@ -34,12 +34,8 @@ public interface ProjectVersionRef ArtifactRef asArtifactRef( String type, String classifier ); - ArtifactRef asArtifactRef( String type, String classifier, boolean optional ); - ArtifactRef asArtifactRef( TypeAndClassifier tc ); - ArtifactRef asArtifactRef( TypeAndClassifier tc, boolean optional ); - VersionSpec getVersionSpecRaw(); String getVersionStringRaw(); diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRef.java index eba20137..2d50d2f2 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRef.java @@ -26,12 +26,12 @@ /** * Represents an artifact, in Maven parlance. A tangible result of a build, which is typically made available in a Maven repository for others * to consume. NOTE: a POM file is both a piece of metadata AND an artifact in the Maven world! - * + * * Artifacts are based on the GAV coordinate for the project release, but also contain a type and optionally, a classifier. Type defaults to 'jar'. - * + * * @see {@link SimpleProjectRef} * @see {@link SimpleProjectVersionRef} - * + * * @author jdcasey */ public class SimpleArtifactRef @@ -43,45 +43,37 @@ public class SimpleArtifactRef private final TypeAndClassifier tc; - private final boolean optional; - public SimpleArtifactRef( final String groupId, final String artifactId, final VersionSpec version, - final String type, final String classifier, final boolean optional ) + final String type, final String classifier ) { super( groupId, artifactId, version ); - this.optional = optional; this.tc = new SimpleTypeAndClassifier( type, classifier ); } - public SimpleArtifactRef( final ProjectVersionRef ref, final String type, final String classifier, - final boolean optional ) + public SimpleArtifactRef( final ProjectVersionRef ref, final String type, final String classifier ) { super( ref.getGroupId(), ref.getArtifactId(), ref.getVersionSpecRaw(), ref.getVersionStringRaw() ); - this.optional = optional; this.tc = new SimpleTypeAndClassifier( type, classifier ); } - public SimpleArtifactRef( final ProjectVersionRef ref, final TypeAndClassifier tc, final boolean optional ) + public SimpleArtifactRef( final ProjectVersionRef ref, final TypeAndClassifier tc ) { super( ref.getGroupId(), ref.getArtifactId(), ref.getVersionSpecRaw(), ref.getVersionStringRaw() ); this.tc = tc; - this.optional = optional; } public SimpleArtifactRef( final String groupId, final String artifactId, final String versionSpec, - final String type, final String classifier, final boolean optional ) + final String type, final String classifier ) throws InvalidVersionSpecificationException { super( groupId, artifactId, versionSpec ); this.tc = new SimpleTypeAndClassifier( type, classifier ); - this.optional = optional; } - public SimpleArtifactRef( ArtifactRef ref ) + public SimpleArtifactRef( final ArtifactRef ref ) { super( ref ); this.tc = ref.getTypeAndClassifier(); - this.optional = ref.isOptional(); } @Override @@ -124,13 +116,13 @@ public static SimpleArtifactRef parse( final String spec ) // assume non-optional, because it might not matter if you're parsing a string like this...you'd be more careful if you were reading something // that had an optional field, because it's not in the normal GATV[C] spec. - return new SimpleArtifactRef( g, a, v, t, c, false ); + return new SimpleArtifactRef( g, a, v, t, c ); } @Override public SimpleArtifactRef newRef( final String groupId, final String artifactId, final SingleVersion version ) { - return new SimpleArtifactRef( groupId, artifactId, version, tc.getType(), tc.getClassifier(), optional ); + return new SimpleArtifactRef( groupId, artifactId, version, tc.getType(), tc.getClassifier() ); } @Override @@ -151,30 +143,12 @@ public TypeAndClassifier getTypeAndClassifier() return tc; } - public SimpleArtifactRef setOptional( final boolean optional ) - { - if ( this.optional == optional ) - { - return this; - } - - return new SimpleArtifactRef( this, getType(), getClassifier(), optional ); - } - - @Override - public boolean isOptional() - { - return optional; - } - @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ( ( tc == null ) ? 0 : tc.hashCode() ); - result = prime * result + Boolean.valueOf( optional ) - .hashCode(); return result; } @@ -225,7 +199,7 @@ public boolean versionlessEquals( final ProjectVersionRef other ) if ( !( other instanceof ArtifactRef ) ) { // compare vs. POM reference. - return artifactFieldsEqual( new SimpleArtifactRef( other, "pom", null, false ) ); + return artifactFieldsEqual( new SimpleArtifactRef( other, "pom", null ) ); } return artifactFieldsEqual( (ArtifactRef) other ); diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectRef.java index c5fbceaa..666673c2 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectRef.java @@ -19,7 +19,7 @@ /** * Reference to a whole project (or module, in terms of Maven builds). This reference is not specific to a release of the project (see {@link SimpleProjectVersionRef}). - * + * * @author jdcasey */ public class SimpleProjectRef @@ -46,7 +46,7 @@ public SimpleProjectRef( final String groupId, final String artifactId ) this.artifactId = artifactId; } - public SimpleProjectRef( ProjectRef ref ) + public SimpleProjectRef( final ProjectRef ref ) { this.groupId = ref.getGroupId(); this.artifactId = ref.getArtifactId(); @@ -85,38 +85,25 @@ public ProjectRef asProjectRef() @Override public VersionlessArtifactRef asVersionlessPomArtifact() { - return asVersionlessArtifactRef( "pom", null, false ); + return asVersionlessArtifactRef( "pom", null ); } @Override public VersionlessArtifactRef asVersionlessJarArtifact() { - return asVersionlessArtifactRef( "jar", null, false ); + return asVersionlessArtifactRef( "jar", null ); } @Override public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier ) { - return asVersionlessArtifactRef( type, classifier, false ); - } - - @Override - public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier, - final boolean optional ) - { - return new SimpleVersionlessArtifactRef( this, type, classifier, optional ); + return new SimpleVersionlessArtifactRef( this, type, classifier ); } @Override public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc ) { - return asVersionlessArtifactRef( tc, false ); - } - - @Override - public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc, final boolean optional ) - { - return new SimpleVersionlessArtifactRef( this, tc, optional ); + return new SimpleVersionlessArtifactRef( this, tc ); } @Override @@ -158,6 +145,7 @@ public boolean equals( final Object obj ) return groupId.equals( other.getGroupId() ); } + @Override public int compareTo( final ProjectRef o ) { int comp = groupId.compareTo( o.getGroupId() ); diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java index 8e6bae5a..3d7379c7 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java @@ -25,10 +25,10 @@ /** * Reference to a particular release of a project (or module, in terms of Maven builds). A release may contain many artifacts (see {@link SimpleArtifactRef}). - * + * * @see {@link SimpleProjectRef} * @see {@link SimpleArtifactRef} - * + * * @author jdcasey */ public class SimpleProjectVersionRef @@ -79,7 +79,7 @@ public SimpleProjectVersionRef( final String groupId, final String artifactId, f this( groupId, artifactId, null, versionString ); } - public SimpleProjectVersionRef( ProjectVersionRef ref ) + public SimpleProjectVersionRef( final ProjectVersionRef ref ) { super( ref ); this.versionSpec = ref.getVersionSpecRaw(); @@ -111,37 +111,25 @@ public SimpleProjectVersionRef asProjectVersionRef() @Override public ArtifactRef asPomArtifact() { - return asArtifactRef( "pom", null, false ); + return asArtifactRef( "pom", null ); } @Override public ArtifactRef asJarArtifact() { - return asArtifactRef( "jar", null, false ); + return asArtifactRef( "jar", null ); } @Override public ArtifactRef asArtifactRef( final String type, final String classifier ) { - return asArtifactRef( type, classifier, false ); - } - - @Override - public ArtifactRef asArtifactRef( final String type, final String classifier, final boolean optional ) - { - return new SimpleArtifactRef( this, type, classifier, optional ); + return new SimpleArtifactRef( this, type, classifier ); } @Override public ArtifactRef asArtifactRef( final TypeAndClassifier tc ) { - return asArtifactRef( tc, false ); - } - - @Override - public ArtifactRef asArtifactRef( final TypeAndClassifier tc, final boolean optional ) - { - return new SimpleArtifactRef( this, tc, optional ); + return new SimpleArtifactRef( this, tc ); } @Override @@ -237,6 +225,7 @@ public int hashCode() return result; } + @Override public boolean versionlessEquals( final ProjectVersionRef other ) { return this == other || super.equals( other ); diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleVersionlessArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleVersionlessArtifactRef.java index 61cb5184..6999a3b6 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleVersionlessArtifactRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleVersionlessArtifactRef.java @@ -22,7 +22,7 @@ /** * Special implementation of {@link SimpleArtifactRef} that forces all versions to ZERO, to allow calculation of transitive * dependency graphs, where version collisions of the same project are likely. - * + * * @author jdcasey */ public class SimpleVersionlessArtifactRef @@ -34,44 +34,36 @@ public class SimpleVersionlessArtifactRef private final TypeAndClassifier tc; - private final boolean optional; - public SimpleVersionlessArtifactRef( final ArtifactRef ref ) { super( ref.getGroupId(), ref.getArtifactId() ); - this.optional = ref.isOptional(); this.tc = ref.getTypeAndClassifier(); } - public SimpleVersionlessArtifactRef( final ProjectRef ref, final String type, final String classifier, - final boolean optional ) + public SimpleVersionlessArtifactRef( final ProjectRef ref, final String type, final String classifier ) { super( ref.getGroupId(), ref.getArtifactId() ); - this.optional = optional; this.tc = new SimpleTypeAndClassifier( type, classifier ); } - public SimpleVersionlessArtifactRef( final ProjectRef ref, final TypeAndClassifier tc, final boolean optional ) + public SimpleVersionlessArtifactRef( final ProjectRef ref, final TypeAndClassifier tc ) { super( ref.getGroupId(), ref.getArtifactId() ); this.tc = tc == null ? new SimpleTypeAndClassifier() : tc; - this.optional = optional; } public SimpleVersionlessArtifactRef( final String groupId, final String artifactId, final String type, - final String classifier, final boolean optional ) + final String classifier ) throws InvalidVersionSpecificationException { super( groupId, artifactId ); this.tc = new SimpleTypeAndClassifier( type, classifier ); - this.optional = optional; } - public SimpleVersionlessArtifactRef( VersionlessArtifactRef ref ) + public SimpleVersionlessArtifactRef( final VersionlessArtifactRef ref ) { super( ref ); this.tc = ref.getTypeAndClassifier(); - this.optional = ref.isOptional(); } @Override @@ -118,7 +110,7 @@ public static VersionlessArtifactRef parse( final String spec ) // assume non-optional, because it might not matter if you're parsing a string like this...you'd be more careful if you were reading something // that had an optional field, because it's not in the normal GATV[C] spec. - return new SimpleVersionlessArtifactRef( g, a, t, c, false ); + return new SimpleVersionlessArtifactRef( g, a, t, c ); } @Override @@ -139,18 +131,11 @@ public TypeAndClassifier getTypeAndClassifier() return tc; } - @Override - public boolean isOptional() - { - return optional; - } - @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); - result = prime * result + ( optional ? 1231 : 1237 ); result = prime * result + ( ( tc == null ) ? 0 : tc.hashCode() ); return result; } @@ -171,10 +156,6 @@ public boolean equals( final Object obj ) return false; } final VersionlessArtifactRef other = (VersionlessArtifactRef) obj; - if ( optional != other.isOptional() ) - { - return false; - } if ( tc == null ) { if ( other.getTypeAndClassifier() != null ) @@ -192,48 +173,35 @@ else if ( !tc.equals( other.getTypeAndClassifier() ) ) @Override public VersionlessArtifactRef asVersionlessPomArtifact() { - return asVersionlessArtifactRef( "pom", null, false ); + return asVersionlessArtifactRef( "pom", null ); } @Override public VersionlessArtifactRef asVersionlessJarArtifact() { - return asVersionlessArtifactRef( "jar", null, false ); + return asVersionlessArtifactRef( "jar", null ); } @Override public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier ) - { - return asVersionlessArtifactRef( type, classifier, false ); - } - - @Override - public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier, - final boolean optional ) { final TypeAndClassifier tc = new SimpleTypeAndClassifier( type, classifier ); - if ( SimpleVersionlessArtifactRef.class.equals( getClass() ) && this.tc.equals( tc ) && this.optional == optional ) + if ( SimpleVersionlessArtifactRef.class.equals( getClass() ) && this.tc.equals( tc ) ) { return this; } - return super.asVersionlessArtifactRef( type, classifier, optional ); + return super.asVersionlessArtifactRef( type, classifier ); } @Override public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc ) { - return asVersionlessArtifactRef( tc, false ); - } - - @Override - public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc, final boolean optional ) - { - if ( SimpleVersionlessArtifactRef.class.equals( getClass() ) && this.tc.equals( tc ) && this.optional == optional ) + if ( SimpleVersionlessArtifactRef.class.equals( getClass() ) && this.tc.equals( tc ) ) { return this; } - return super.asVersionlessArtifactRef( tc, optional ); + return super.asVersionlessArtifactRef( tc ); } } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java index 25641f47..56556c91 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java @@ -27,8 +27,6 @@ public interface VersionlessArtifactRef TypeAndClassifier getTypeAndClassifier(); - boolean isOptional(); - @Override VersionlessArtifactRef asVersionlessPomArtifact(); @@ -38,12 +36,7 @@ public interface VersionlessArtifactRef @Override VersionlessArtifactRef asVersionlessArtifactRef( String type, String classifier ); - @Override - VersionlessArtifactRef asVersionlessArtifactRef( String type, String classifier, boolean optional ); - @Override VersionlessArtifactRef asVersionlessArtifactRef( TypeAndClassifier tc ); - @Override - VersionlessArtifactRef asVersionlessArtifactRef( TypeAndClassifier tc, boolean optional ); } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java index a0b4b9cc..3dc69e6a 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java @@ -261,7 +261,7 @@ public ProjectVersionRef getProjectId() public ArtifactRef getArtifact() { - return new SimpleArtifactRef( getGroupId(), getArtifactId(), getVersion(), getType(), getClassifier(), false ); + return new SimpleArtifactRef( getGroupId(), getArtifactId(), getVersion(), getType(), getClassifier() ); } } diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/IdentityUtils.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/IdentityUtils.java index 14b4e9e7..fd637587 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/IdentityUtils.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/IdentityUtils.java @@ -28,26 +28,25 @@ private IdentityUtils() public static ArtifactRef artifact( final String groupId, final String artifactId, final String version ) throws InvalidVersionSpecificationException { - return new SimpleArtifactRef( projectVersion( groupId, artifactId, version ), null, null, false ); + return new SimpleArtifactRef( projectVersion( groupId, artifactId, version ), null, null ); } public static ArtifactRef artifact( final ProjectVersionRef ref ) throws InvalidVersionSpecificationException { - return new SimpleArtifactRef( ref, null, null, false ); + return new SimpleArtifactRef( ref, null, null ); } public static ArtifactRef artifact( final String groupId, final String artifactId, final String version, - final String type, final String classifier, final boolean optional ) + final String type, final String classifier ) throws InvalidVersionSpecificationException { - return new SimpleArtifactRef( projectVersion( groupId, artifactId, version ), type, classifier, optional ); + return new SimpleArtifactRef( projectVersion( groupId, artifactId, version ), type, classifier ); } - public static ArtifactRef artifact( final ProjectVersionRef dep, final String type, final String classifier, - final boolean optional ) + public static ArtifactRef artifact( final ProjectVersionRef dep, final String type, final String classifier ) { - return new SimpleArtifactRef( dep, type, classifier, optional ); + return new SimpleArtifactRef( dep, type, classifier ); } public static ProjectVersionRef projectVersion( final String src ) diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRefTest.java b/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRefTest.java index b00a3e47..b2acd2e7 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRefTest.java +++ b/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRefTest.java @@ -126,8 +126,8 @@ public void identicalVersionlessArtifactsAreNotEqualWhenOptionalFlagsDiffer() final String v = "1"; final String t = "jar"; - final VersionlessArtifactRef r1 = new SimpleVersionlessArtifactRef( new SimpleArtifactRef( g, a, v, t, null, false ) ); - final VersionlessArtifactRef r2 = new SimpleVersionlessArtifactRef( new SimpleArtifactRef( g, a, v, t, null, true ) ); + final VersionlessArtifactRef r1 = new SimpleVersionlessArtifactRef( new SimpleArtifactRef( g, a, v, t, null ) ); + final VersionlessArtifactRef r2 = new SimpleVersionlessArtifactRef( new SimpleArtifactRef( g, a, v, t, null ) ); assertThat( r1.equals( r2 ), equalTo( false ) ); assertThat( r1.hashCode() == r2.hashCode(), equalTo( false ) ); @@ -137,8 +137,8 @@ public void identicalVersionlessArtifactsAreNotEqualWhenOptionalFlagsDiffer() public void twoIdenticalArtifactsWrappedInVersionlessInstanceAreEqual_DefaultTypeAndClassifier() { final ProjectVersionRef pvr = new SimpleProjectVersionRef( "group", "artifact", "1" ); - final ArtifactRef r1 = new SimpleArtifactRef( pvr, null, null, false ); - final ArtifactRef r2 = new SimpleArtifactRef( pvr, null, null, false ); + final ArtifactRef r1 = new SimpleArtifactRef( pvr, null, null ); + final ArtifactRef r2 = new SimpleArtifactRef( pvr, null, null ); final VersionlessArtifactRef vr1 = new SimpleVersionlessArtifactRef( r1 ); final VersionlessArtifactRef vr2 = new SimpleVersionlessArtifactRef( r2 ); @@ -151,8 +151,8 @@ public void twoIdenticalArtifactsWrappedInVersionlessInstanceAreEqual_DefaultTyp public void twoArtifactsWrappedInVersionlessInstanceAreNotEqualWhenTypeDiffers() { final ProjectVersionRef pvr = new SimpleProjectVersionRef( "group", "artifact", "1" ); - final ArtifactRef r1 = new SimpleArtifactRef( pvr, "jar", null, false ); - final ArtifactRef r2 = new SimpleArtifactRef( pvr, "pom", null, false ); + final ArtifactRef r1 = new SimpleArtifactRef( pvr, "jar", null ); + final ArtifactRef r2 = new SimpleArtifactRef( pvr, "pom", null ); final VersionlessArtifactRef vr1 = new SimpleVersionlessArtifactRef( r1 ); final VersionlessArtifactRef vr2 = new SimpleVersionlessArtifactRef( r2 ); @@ -165,8 +165,8 @@ public void twoArtifactsWrappedInVersionlessInstanceAreNotEqualWhenTypeDiffers() public void twoArtifactsWrappedInVersionlessInstanceAreNotEqualWhenClassifierDiffers() { final ProjectVersionRef pvr = new SimpleProjectVersionRef( "group", "artifact", "1" ); - final ArtifactRef r1 = new SimpleArtifactRef( pvr, "jar", null, false ); - final ArtifactRef r2 = new SimpleArtifactRef( pvr, "jar", "foo", false ); + final ArtifactRef r1 = new SimpleArtifactRef( pvr, "jar", null ); + final ArtifactRef r2 = new SimpleArtifactRef( pvr, "jar", "foo" ); final VersionlessArtifactRef vr1 = new SimpleVersionlessArtifactRef( r1 ); final VersionlessArtifactRef vr2 = new SimpleVersionlessArtifactRef( r2 ); @@ -180,8 +180,8 @@ public void twoArtifactsWrappedInVersionlessInstanceAreEqualWhenVersionDiffers() { final ProjectVersionRef pvr1 = new SimpleProjectVersionRef( "group", "artifact", "1" ); final ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "group", "artifact", "2" ); - final ArtifactRef r1 = new SimpleArtifactRef( pvr1, null, null, false ); - final ArtifactRef r2 = new SimpleArtifactRef( pvr2, null, null, false ); + final ArtifactRef r1 = new SimpleArtifactRef( pvr1, null, null ); + final ArtifactRef r2 = new SimpleArtifactRef( pvr2, null, null ); final VersionlessArtifactRef vr1 = new SimpleVersionlessArtifactRef( r1 ); final VersionlessArtifactRef vr2 = new SimpleVersionlessArtifactRef( r2 ); @@ -195,8 +195,8 @@ public void twoArtifactsWrappedInVersionlessInstanceAreEqualWhenVersionDiffersWi { final ProjectVersionRef pvr1 = new SimpleProjectVersionRef( "group", "artifact", "1" ); final ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "group", "artifact", "[2,3.1]" ); - final ArtifactRef r1 = new SimpleArtifactRef( pvr1, null, null, false ); - final ArtifactRef r2 = new SimpleArtifactRef( pvr2, null, null, false ); + final ArtifactRef r1 = new SimpleArtifactRef( pvr1, null, null ); + final ArtifactRef r2 = new SimpleArtifactRef( pvr2, null, null ); // trigger parsing. r1.getVersionSpec(); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java index 330d3489..b2ccb424 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java @@ -468,7 +468,7 @@ public int getNextExtensionIndex() public Builder withDependency( final ProjectVersionRef ref, final String type, final String classifier, final DependencyScope scope, final boolean managed, final boolean inherited, final boolean optional ) { - withDependencies( new SimpleDependencyRelationship( source, ref, new SimpleArtifactRef( ref, type, classifier, optional ), + withDependencies( new SimpleDependencyRelationship( source, ref, new SimpleArtifactRef( ref, type, classifier ), scope, getNextDependencyIndex( managed ), managed, inherited, optional ) ); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java index 76ee1e3f..30b8c799 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java @@ -199,7 +199,7 @@ public DependencyRelationship selectTarget( final ProjectVersionRef ref ) ArtifactRef t = getTarget(); t = (ArtifactRef) ( ( ref instanceof ArtifactRef ) ? ref : new SimpleArtifactRef( ref, t.getType(), - t.getClassifier(), t.isOptional() ) ); + t.getClassifier() ) ); Set var = getExcludes(); return new SimpleDependencyRelationship( getSources(), getPomLocation(), d, t, getScope(), getIndex(), isManaged(), diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java index 1f61cff3..fb2837fb 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java @@ -80,7 +80,7 @@ protected ProjectVersionRef cloneTarget( final ProjectVersionRef target ) @Override public ArtifactRef getTargetArtifact() { - return new SimpleArtifactRef( getTarget(), null, null, false ); + return new SimpleArtifactRef( getTarget(), null, null ); } @Override diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java index 3a1d13d6..0b5ed5f6 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java @@ -84,7 +84,7 @@ protected ProjectVersionRef cloneTarget( final ProjectVersionRef target ) @Override public ArtifactRef getTargetArtifact() { - return new SimpleArtifactRef( getTarget(), "pom", null, false ); + return new SimpleArtifactRef( getTarget(), "pom", null ); } @Override diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java index 1b1c9d72..34bd8ac9 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java @@ -164,7 +164,7 @@ public PluginDependencyRelationship selectTarget( final ProjectVersionRef ref ) ArtifactRef t = getTarget(); t = (ArtifactRef) ( ( ref instanceof ArtifactRef ) ? ref : new SimpleArtifactRef( ref, t.getType(), - t.getClassifier(), t.isOptional() ) ); + t.getClassifier() ) ); return new SimplePluginDependencyRelationship( getSources(), getPomLocation(), d, getPlugin(), t, getIndex(), isManaged(), isInherited() ); diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java index a19fafe4..5932b7c9 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java @@ -128,7 +128,7 @@ protected ProjectVersionRef cloneTarget( final ProjectVersionRef target ) @Override public ArtifactRef getTargetArtifact() { - return new SimpleArtifactRef( getTarget(), "maven-plugin", null, false ); + return new SimpleArtifactRef( getTarget(), "maven-plugin", null ); } @Override diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java index 8c940d4e..39b7492c 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java @@ -361,7 +361,7 @@ public static PluginDependencyRelationship pluginDependency( final URI source, f final boolean inherited ) throws InvalidVersionSpecificationException { - return new SimplePluginDependencyRelationship( source, owner, plugin, artifact( groupId, artifactId, version, type, classifier, false ), index, + return new SimplePluginDependencyRelationship( source, owner, plugin, artifact( groupId, artifactId, version, type, classifier ), index, managed, inherited ); } @@ -370,7 +370,7 @@ public static PluginDependencyRelationship pluginDependency( final URI source, f final int index, final boolean managed, final boolean inherited ) throws InvalidVersionSpecificationException { - return new SimplePluginDependencyRelationship( source, owner, plugin, artifact( dep, type, classifier, false ), index, managed, inherited ); + return new SimplePluginDependencyRelationship( source, owner, plugin, artifact( dep, type, classifier ), index, managed, inherited ); } public static PluginDependencyRelationship pluginDependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, @@ -397,7 +397,7 @@ public static PluginDependencyRelationship pluginDependency( final URI source, f throws InvalidVersionSpecificationException { return new SimplePluginDependencyRelationship( source, pomLocation, owner, plugin, - artifact( groupId, artifactId, version, type, classifier, false ), index, managed, inherited ); + artifact( groupId, artifactId, version, type, classifier ), index, managed, inherited ); } public static PluginDependencyRelationship pluginDependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, @@ -406,7 +406,7 @@ public static PluginDependencyRelationship pluginDependency( final URI source, f final boolean inherited ) throws InvalidVersionSpecificationException { - return new SimplePluginDependencyRelationship( source, pomLocation, owner, plugin, artifact( dep, type, classifier, false ), index, managed, + return new SimplePluginDependencyRelationship( source, pomLocation, owner, plugin, artifact( dep, type, classifier ), index, managed, inherited ); } @@ -438,7 +438,7 @@ public static DependencyRelationship dependency( final URI source, final Project final boolean inherited, final boolean optional ) throws InvalidVersionSpecificationException { - return new SimpleDependencyRelationship( source, owner, artifact( dep, null, null, optional ), scope, index, managed, inherited, optional ); + return new SimpleDependencyRelationship( source, owner, artifact( dep, null, null ), scope, index, managed, inherited, optional ); } public static DependencyRelationship dependency( final URI source, final ProjectVersionRef owner, final String groupId, final String artifactId, @@ -446,7 +446,7 @@ public static DependencyRelationship dependency( final URI source, final Project final DependencyScope scope, final int index, final boolean managed, final boolean inherited ) throws InvalidVersionSpecificationException { - return new SimpleDependencyRelationship( source, owner, artifact( groupId, artifactId, version, type, classifier, optional ), scope, index, + return new SimpleDependencyRelationship( source, owner, artifact( groupId, artifactId, version, type, classifier ), scope, index, managed, inherited, optional ); } @@ -455,7 +455,7 @@ public static DependencyRelationship dependency( final URI source, final Project final boolean managed, final boolean inherited ) throws InvalidVersionSpecificationException { - return new SimpleDependencyRelationship( source, owner, artifact( dep, type, classifier, optional ), scope, index, managed, inherited, optional ); + return new SimpleDependencyRelationship( source, owner, artifact( dep, type, classifier ), scope, index, managed, inherited, optional ); } public static DependencyRelationship dependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, final String groupId, @@ -487,7 +487,7 @@ public static DependencyRelationship dependency( final URI source, final URI pom final boolean managed, final boolean inherited, final boolean optional ) throws InvalidVersionSpecificationException { - return new SimpleDependencyRelationship( source, pomLocation, owner, artifact( dep, null, null, optional ), scope, index, managed, inherited, optional ); + return new SimpleDependencyRelationship( source, pomLocation, owner, artifact( dep, null, null ), scope, index, managed, inherited, optional ); } public static DependencyRelationship dependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, final String groupId, @@ -496,7 +496,7 @@ public static DependencyRelationship dependency( final URI source, final URI pom final boolean inherited ) throws InvalidVersionSpecificationException { - return new SimpleDependencyRelationship( source, pomLocation, owner, artifact( groupId, artifactId, version, type, classifier, optional ), scope, + return new SimpleDependencyRelationship( source, pomLocation, owner, artifact( groupId, artifactId, version, type, classifier ), scope, index, managed, inherited, optional ); } @@ -505,7 +505,7 @@ public static DependencyRelationship dependency( final URI source, final URI pom final DependencyScope scope, final int index, final boolean managed, final boolean inherited ) throws InvalidVersionSpecificationException { - return new SimpleDependencyRelationship( source, pomLocation, owner, artifact( dep, type, classifier, optional ), scope, index, managed, inherited, optional ); + return new SimpleDependencyRelationship( source, pomLocation, owner, artifact( dep, type, classifier ), scope, index, managed, inherited, optional ); } public static Set getRelationshipTypes( final ProjectRelationshipFilter filter ) diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java index 3f4f49e8..870e407c 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java @@ -61,11 +61,11 @@ public void builderWith2Dependencies2PluginsAParentAndAnExtension() int pidx = 0; final DependencyRelationship papi = new SimpleDependencyRelationship( source, p, new SimpleArtifactRef( "org.apache.maven", "maven-plugin-api", "3.0.3", - null, null, false ), DependencyScope.compile, + null, null ), DependencyScope.compile, idx++, false, false, false ); final DependencyRelationship art = new SimpleDependencyRelationship( source, p, new SimpleArtifactRef( "org.apache.maven", "maven-artifact", "3.0.3", - null, null, false ), DependencyScope.compile, + null, null ), DependencyScope.compile, idx++, false, false, false ); final PluginRelationship jarp = new SimplePluginRelationship( source, p, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-jar-plugin", diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java index b48a52e5..2fc10f79 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java @@ -49,7 +49,7 @@ public void rejectTestScopeForRuntimeFilter() final DependencyFilter filter = new DependencyFilter( DependencyScope.runtime ); final DependencyRelationship rel = new SimpleDependencyRelationship( testURI(), new SimpleProjectVersionRef( "g", "a", "1" ), - new SimpleArtifactRef( "g", "b", "2", "jar", null, false ), DependencyScope.test, 0, + new SimpleArtifactRef( "g", "b", "2", "jar", null ), DependencyScope.test, 0, false, false, false ); assertThat( filter.accept( rel ), equalTo( false ) ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java index 95872528..680f5dea 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java @@ -73,7 +73,7 @@ public void run() private ArtifactRef newArtifact() { - return new SimpleArtifactRef( genName(), genName(), genNum(), "jar", null, false ); + return new SimpleArtifactRef( genName(), genName(), genNum(), "jar", null ); } private String genName() diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java index f324b2f5..bba4c295 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java @@ -56,9 +56,9 @@ public void run() /* @formatter:off */ final Set> rejected = graph.storeRelationships( - new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null, false ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null, false ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, dep2, new SimpleArtifactRef( dep, null, null, false ), null, 0, false, false, false ) ); + new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, dep2, new SimpleArtifactRef( dep, null, null ), null, 0, false, false, false ) ); /* @formatter:on */ assertThat( rejected, notNullValue() ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java index 84dfd62c..e0f07f16 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java @@ -60,11 +60,11 @@ public void run() /* @formatter:off */ // a --> b --> c --> a // d --> e --> c --> a --> b --> c - graph.storeRelationships( new SimpleDependencyRelationship( source, a, new SimpleArtifactRef( b, null, null, false ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( a, null, null, false ), null, 0, false, false, false ), + graph.storeRelationships( new SimpleDependencyRelationship( source, a, new SimpleArtifactRef( b, null, null ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( a, null, null ), null, 0, false, false, false ), new SimplePluginRelationship( source, b, c, 0, false, false ), - new SimpleDependencyRelationship( source, d, new SimpleArtifactRef( e, null, null, false ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, e, new SimpleArtifactRef( c, null, null, false ), null, 0, false, false, false ) ); + new SimpleDependencyRelationship( source, d, new SimpleArtifactRef( e, null, null ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, e, new SimpleArtifactRef( c, null, null ), null, 0, false, false, false ) ); /* @formatter:on */ final RelationshipGraph graph2 = diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java index a7f47bc0..89036469 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java @@ -55,10 +55,10 @@ public void run() final RelationshipGraph graph = simpleGraph( project ); /* @formatter:off */ - graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null, false ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null, false ), null, 0, false, false, false ) ); + graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null ), null, 0, false, false, false ) ); - final boolean introduces = graph.introducesCycle( new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( project, null, null, false ), null, 0, false, false, false ) ); + final boolean introduces = graph.introducesCycle( new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( project, null, null ), null, 0, false, false, false ) ); /* @formatter:on */ assertThat( introduces, equalTo( true ) ); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java index 131d5c14..6742555b 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java @@ -58,11 +58,11 @@ public void run() /* @formatter:off */ // a --> b --> c --> a // d --> e --> c --> a --> b --> c - graph.storeRelationships( new SimpleDependencyRelationship( source, a, new SimpleArtifactRef( b, null, null, false ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, b, new SimpleArtifactRef( c, null, null, false ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( a, null, null, false ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, d, new SimpleArtifactRef( e, null, null, false ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, e, new SimpleArtifactRef( c, null, null, false ), null, 0, false, false, false ) ); + graph.storeRelationships( new SimpleDependencyRelationship( source, a, new SimpleArtifactRef( b, null, null ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, b, new SimpleArtifactRef( c, null, null ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( a, null, null ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, d, new SimpleArtifactRef( e, null, null ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, e, new SimpleArtifactRef( c, null, null ), null, 0, false, false, false ) ); /* @formatter:on */ final RelationshipGraph graph2 = diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java index 54a0f0a2..238dbeb4 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java @@ -52,8 +52,8 @@ public void run() final RelationshipGraph graph = simpleGraph( project ); /* @formatter:off */ - graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false, false, false ) ); + graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null ), null, 0, false, false, false ) ); /* @formatter:on */ Set variables = graph.getVariableSubgraphs(); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelection_ContextualToViewTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelection_ContextualToViewTCK.java index 30d0c702..17626951 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelection_ContextualToViewTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelection_ContextualToViewTCK.java @@ -49,8 +49,8 @@ public void run() final RelationshipGraph graph = simpleGraph( project ); /* @formatter:off */ - graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null, false ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null, false ), null, 0, false, false, false ) ); + graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null ), null, 0, false, false, false ) ); /* @formatter:on */ Set variables = graph.getVariableSubgraphs(); diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java index 1eefa869..07fa2a81 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java @@ -49,8 +49,8 @@ public void run() /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship( source, myRef, parentRef ), - new SimpleDependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "foo", "1.0" ), null, null, false ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "bar", "1.2.1" ), null, null, false ), null, 1, false, false, false ), + new SimpleDependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "foo", "1.0" ), null, null ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "bar", "1.2.1" ), null, null ), null, 1, false, false, false ), new SimplePluginRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.5.1" ), 0, false, false ), new SimplePluginRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins","maven-jar-plugin", "2.2" ), 1, false, false ), new SimpleExtensionRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.5.1" ), 0, false ), diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java index 681ecb22..c1f634fe 100644 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java +++ b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java @@ -59,8 +59,8 @@ public void run() final RelationshipGraph graph = simpleGraph( c ); /* @formatter:off */ - graph.storeRelationships( new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( b, null, null, false ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, b, new SimpleArtifactRef( a, null, null, false ), null, 0, false, false, false ) ); + graph.storeRelationships( new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( b, null, null ), null, 0, false, false, false ), + new SimpleDependencyRelationship( source, b, new SimpleArtifactRef( a, null, null ), null, 0, false, false, false ) ); /* @formatter:on */ assertThat( graph.getAllRelationships() From f3d184c05608b0ddf972fb786104310b3d73d301 Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Thu, 14 Jan 2016 14:46:35 +0100 Subject: [PATCH 128/240] Fix tests --- .../ident/ref/VersionlessArtifactRefTest.java | 16 ---------------- .../graph/rel/RelationshipComparatorTest.java | 6 +++--- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRefTest.java b/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRefTest.java index b2acd2e7..7566e10d 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRefTest.java +++ b/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRefTest.java @@ -117,22 +117,6 @@ public void parseGATVC() assertThat( var.getClassifier(), nullValue() ); } - @Test - public void identicalVersionlessArtifactsAreNotEqualWhenOptionalFlagsDiffer() - { - // net.sf.kxml:kxml2:*:jar - final String g = "net.sf.kxml"; - final String a = "kxml2"; - final String v = "1"; - final String t = "jar"; - - final VersionlessArtifactRef r1 = new SimpleVersionlessArtifactRef( new SimpleArtifactRef( g, a, v, t, null ) ); - final VersionlessArtifactRef r2 = new SimpleVersionlessArtifactRef( new SimpleArtifactRef( g, a, v, t, null ) ); - - assertThat( r1.equals( r2 ), equalTo( false ) ); - assertThat( r1.hashCode() == r2.hashCode(), equalTo( false ) ); - } - @Test public void twoIdenticalArtifactsWrappedInVersionlessInstanceAreEqual_DefaultTypeAndClassifier() { diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java index 64810173..88bde5e6 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java @@ -31,9 +31,9 @@ public void testCompareTransitivity() final ProjectVersionRef nodeY = projectVersion( "y", "y", "1.0" ); final ProjectVersionRef nodeZ = projectVersion( "z", "z", "1.0" ); - DependencyRelationship relA = dependency( POM_ROOT_URI, nodeW, nodeX, 0, false ); - DependencyRelationship relB = dependency( POM_ROOT_URI, nodeX, nodeY, 0, false ); - DependencyRelationship relC = dependency( POM_ROOT_URI, nodeY, nodeZ, 0, false ); + DependencyRelationship relA = dependency( POM_ROOT_URI, nodeW, nodeX, 0, false, false ); + DependencyRelationship relB = dependency( POM_ROOT_URI, nodeX, nodeY, 0, false, false ); + DependencyRelationship relC = dependency( POM_ROOT_URI, nodeY, nodeZ, 0, false, false ); assertThat( "relA < relB must be true to perform the test", RelationshipComparator.INSTANCE.compare( relA, relB ), equalTo( -1 ) ); From 76f9443d88c6da5f69d7f40357bf1e06d74f5e6f Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 29 Feb 2016 15:30:27 -0600 Subject: [PATCH 129/240] Fixing license header. --- .../graph/rel/RelationshipComparatorTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java index 88bde5e6..39b003f4 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.rel; import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.POM_ROOT_URI; From e909a5d59cd1185ab0a57c976f3ded31293e75e6 Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 29 Feb 2016 15:33:08 -0600 Subject: [PATCH 130/240] [maven-release-plugin] prepare release atlas-parent-0.16.0 --- bindings/jackson-identities/pom.xml | 2 +- bindings/jackson-relationships/pom.xml | 2 +- bindings/pom.xml | 2 +- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- ftests/jung/pom.xml | 2 +- ftests/neo4j/pom.xml | 2 +- ftests/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 18 +++++++++--------- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 285180f4..002eefc4 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.15.3-SNAPSHOT + 0.16.0 atlas-bindings-jackson-identities diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml index e7dd9838..d03b2975 100644 --- a/bindings/jackson-relationships/pom.xml +++ b/bindings/jackson-relationships/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.15.3-SNAPSHOT + 0.16.0 atlas-bindings-jackson-relationships diff --git a/bindings/pom.xml b/bindings/pom.xml index 69c91eee..6e104bf6 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.3-SNAPSHOT + 0.16.0 atlas-bindings-parent diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index c119eea2..68d8b44f 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.15.3-SNAPSHOT + 0.16.0 atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index d876ade9..72476a60 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.15.3-SNAPSHOT + 0.16.0 atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index b0601e2d..b277df1b 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.3-SNAPSHOT + 0.16.0 atlas-drivers-parent diff --git a/ftests/jung/pom.xml b/ftests/jung/pom.xml index c432619c..01243cce 100644 --- a/ftests/jung/pom.xml +++ b/ftests/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.15.3-SNAPSHOT + 0.16.0 atlas-ftests-jung diff --git a/ftests/neo4j/pom.xml b/ftests/neo4j/pom.xml index f294562f..5bc5b0e4 100644 --- a/ftests/neo4j/pom.xml +++ b/ftests/neo4j/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.15.3-SNAPSHOT + 0.16.0 atlas-ftests-neo4j diff --git a/ftests/pom.xml b/ftests/pom.xml index 9eb88ef4..8239ee20 100644 --- a/ftests/pom.xml +++ b/ftests/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.3-SNAPSHOT + 0.16.0 atlas-ftests-parent diff --git a/identities/pom.xml b/identities/pom.xml index f5ee1622..e38f7310 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.3-SNAPSHOT + 0.16.0 atlas-identities diff --git a/pom.xml b/pom.xml index 34d8474a..51955a1e 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.3-SNAPSHOT + 0.16.0 pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - HEAD + atlas-parent-0.16.0 @@ -48,37 +48,37 @@ org.commonjava.maven.atlas atlas-identities - 0.15.3-SNAPSHOT + 0.16.0 org.commonjava.maven.atlas atlas-relationships-api - 0.15.3-SNAPSHOT + 0.16.0 org.commonjava.maven.atlas atlas-bindings-jackson-identities - 0.15.3-SNAPSHOT + 0.16.0 org.commonjava.maven.atlas atlas-bindings-jackson-relationships - 0.15.3-SNAPSHOT + 0.16.0 org.commonjava.maven.atlas atlas-driver-jung - 0.15.3-SNAPSHOT + 0.16.0 org.commonjava.maven.atlas atlas-driver-neo4j-embedded - 0.15.3-SNAPSHOT + 0.16.0 org.commonjava.maven.atlas atlas-drivers-tck - 0.15.3-SNAPSHOT + 0.16.0 test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 068b1ae5..533cbe0b 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.3-SNAPSHOT + 0.16.0 atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 9158d0e8..91216ad8 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.15.3-SNAPSHOT + 0.16.0 atlas-drivers-tck From 380dde2bd3fe138103199f9c7afe6789268a76c1 Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 29 Feb 2016 15:33:18 -0600 Subject: [PATCH 131/240] [maven-release-plugin] prepare for next development iteration --- bindings/jackson-identities/pom.xml | 2 +- bindings/jackson-relationships/pom.xml | 2 +- bindings/pom.xml | 2 +- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- ftests/jung/pom.xml | 2 +- ftests/neo4j/pom.xml | 2 +- ftests/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 18 +++++++++--------- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 002eefc4..c6071214 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.16.0 + 0.16.1-SNAPSHOT atlas-bindings-jackson-identities diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml index d03b2975..669b5148 100644 --- a/bindings/jackson-relationships/pom.xml +++ b/bindings/jackson-relationships/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.16.0 + 0.16.1-SNAPSHOT atlas-bindings-jackson-relationships diff --git a/bindings/pom.xml b/bindings/pom.xml index 6e104bf6..d3216bc2 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.0 + 0.16.1-SNAPSHOT atlas-bindings-parent diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index 68d8b44f..a9b6c65b 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.16.0 + 0.16.1-SNAPSHOT atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 72476a60..5d4dcb57 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.16.0 + 0.16.1-SNAPSHOT atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index b277df1b..49196931 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.0 + 0.16.1-SNAPSHOT atlas-drivers-parent diff --git a/ftests/jung/pom.xml b/ftests/jung/pom.xml index 01243cce..e6ccf051 100644 --- a/ftests/jung/pom.xml +++ b/ftests/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.16.0 + 0.16.1-SNAPSHOT atlas-ftests-jung diff --git a/ftests/neo4j/pom.xml b/ftests/neo4j/pom.xml index 5bc5b0e4..dc3de5f9 100644 --- a/ftests/neo4j/pom.xml +++ b/ftests/neo4j/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.16.0 + 0.16.1-SNAPSHOT atlas-ftests-neo4j diff --git a/ftests/pom.xml b/ftests/pom.xml index 8239ee20..85d03b4f 100644 --- a/ftests/pom.xml +++ b/ftests/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.0 + 0.16.1-SNAPSHOT atlas-ftests-parent diff --git a/identities/pom.xml b/identities/pom.xml index e38f7310..922d6409 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.0 + 0.16.1-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index 51955a1e..5a0b6fb2 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.0 + 0.16.1-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - atlas-parent-0.16.0 + HEAD @@ -48,37 +48,37 @@ org.commonjava.maven.atlas atlas-identities - 0.16.0 + 0.16.1-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.16.0 + 0.16.1-SNAPSHOT org.commonjava.maven.atlas atlas-bindings-jackson-identities - 0.16.0 + 0.16.1-SNAPSHOT org.commonjava.maven.atlas atlas-bindings-jackson-relationships - 0.16.0 + 0.16.1-SNAPSHOT org.commonjava.maven.atlas atlas-driver-jung - 0.16.0 + 0.16.1-SNAPSHOT org.commonjava.maven.atlas atlas-driver-neo4j-embedded - 0.16.0 + 0.16.1-SNAPSHOT org.commonjava.maven.atlas atlas-drivers-tck - 0.16.0 + 0.16.1-SNAPSHOT test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 533cbe0b..0e43c74a 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.0 + 0.16.1-SNAPSHOT atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 91216ad8..fd05fa7b 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.0 + 0.16.1-SNAPSHOT atlas-drivers-tck From f9b53b7cb3d5b71961e208f4cf7062118ffeea7e Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Wed, 6 Apr 2016 23:38:31 +0200 Subject: [PATCH 132/240] Fix relationship deserialization When a dependency pointing at a non-jar artifact got deserialized, the information about type and classifier was lost. The problem was, that it tried to read those properties from the end node, but they are stored at the relationship. --- .../atlas/graph/spi/neo4j/model/NeoArtifactRef.java | 6 ++---- .../graph/spi/neo4j/model/NeoDependencyRelationship.java | 2 +- .../spi/neo4j/model/NeoPluginDependencyRelationship.java | 2 +- .../graph/spi/neo4j/model/NeoTypeAndClassifier.java | 9 +-------- .../io/NeoProjectVersionRefSerializerModuleTest.java | 3 ++- .../atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java | 4 ++-- 6 files changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java index 1164a9ae..bcb528c0 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java @@ -15,8 +15,6 @@ */ package org.commonjava.maven.atlas.graph.spi.neo4j.model; -import static org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoIdentityUtils.getBooleanProperty; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.InvalidRefException; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; @@ -74,10 +72,10 @@ public NeoArtifactRef( final ProjectVersionRef ref, final NeoTypeAndClassifier t this.tc = tc; } - public NeoArtifactRef( final Node node ) + public NeoArtifactRef( final Node node, final NeoTypeAndClassifier tc ) { super( node ); - this.tc = new NeoTypeAndClassifier( node ); + this.tc = tc; } public NeoArtifactRef( final String groupId, final String artifactId, final String versionSpec, final String type, diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java index aa3ca72b..c8c5a9f3 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java @@ -104,7 +104,7 @@ public String toString() @Override public ArtifactRef getTarget() { - return target == null ? new NeoArtifactRef( rel.getEndNode() ) : target; + return target == null ? new NeoArtifactRef( rel.getEndNode(), new NeoTypeAndClassifier( rel ) ) : target; } @Override diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java index 92d9b0f2..05ad2a94 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java @@ -110,7 +110,7 @@ public String toString() @Override public ArtifactRef getTarget() { - return target == null ? new NeoArtifactRef( rel.getEndNode() ) : target; + return target == null ? new NeoArtifactRef( rel.getEndNode(), new NeoTypeAndClassifier( rel ) ) : target; } @Override diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoTypeAndClassifier.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoTypeAndClassifier.java index aa32cf62..d5002d86 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoTypeAndClassifier.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoTypeAndClassifier.java @@ -34,8 +34,6 @@ public class NeoTypeAndClassifier private Relationship rel; - private Node node; - public NeoTypeAndClassifier( final String type, final String classifier ) { this.type = type == null ? "jar" : type; @@ -52,16 +50,11 @@ public NeoTypeAndClassifier() this( null, null ); } - public NeoTypeAndClassifier( Relationship rel ) + public NeoTypeAndClassifier( final Relationship rel ) { this.rel = rel; } - public NeoTypeAndClassifier( Node node ) - { - this.node = node; - } - @Override public String getType() { diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectVersionRefSerializerModuleTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectVersionRefSerializerModuleTest.java index 117eb814..71385a37 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectVersionRefSerializerModuleTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectVersionRefSerializerModuleTest.java @@ -35,6 +35,7 @@ import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoArtifactRef; import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoProjectRef; import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoProjectVersionRef; +import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoTypeAndClassifier; import org.commonjava.maven.atlas.ident.jackson.ProjectVersionRefSerializerModule; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectRef; @@ -128,7 +129,7 @@ public void roundTripArtifactRef() tx.finish(); } - NeoArtifactRef naref = new NeoArtifactRef( node ); + NeoArtifactRef naref = new NeoArtifactRef( node, new NeoTypeAndClassifier( "jar" ) ); String njson = mapper.writeValueAsString( naref ); assertThat( njson, equalTo( json ) ); diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java index 94d29311..80e2917e 100644 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java +++ b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java @@ -102,12 +102,12 @@ public void artifactRefCrossImplEquality() ArtifactRef aref = new SimpleArtifactRef( pvr, "jar", null ); Node node = toNode( aref ); - NeoArtifactRef naref = new NeoArtifactRef( node ); + NeoArtifactRef naref = new NeoArtifactRef( node, new NeoTypeAndClassifier( "jar" ) ); assertThat( naref, equalTo( aref ) ); } - private Node toNode( ProjectVersionRef pvr ) + private Node toNode( final ProjectVersionRef pvr ) { Transaction tx = graph.beginTx(); Node node; From 83913ebf3932425bfeb1def66a8242db946c52b6 Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Wed, 6 Apr 2016 23:43:40 +0200 Subject: [PATCH 133/240] Minor code cleanup * remove trailing spaces * add final modifier to method params * remove unused local variables --- .../spi/neo4j/FileNeo4JGraphConnection.java | 20 +++++++++---------- .../atlas/graph/spi/neo4j/io/Conversions.java | 3 --- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java index 39e2d027..f0f37f9f 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java @@ -94,8 +94,8 @@ public class FileNeo4JGraphConnection /* @formatter:off */ // private static final String CYPHER_SELECTION_RETRIEVAL = String.format( -// "CYPHER 1.8 START a=node({roots}) " -// + "\nMATCH p1=(a)-[:{}*1..]->(s), " +// "CYPHER 1.8 START a=node({roots}) " +// + "\nMATCH p1=(a)-[:{}*1..]->(s), " // + "\n p2=(a)-[:{}*1..]->(v) " // + "\nWITH v, s, last(relationships(p1)) as r1, last(relationships(p2)) as r2 " // + "\nWHERE v.{} = s.{} " @@ -107,13 +107,13 @@ public class FileNeo4JGraphConnection // + "\n AND any(x in r2.{} " // + "\n WHERE x IN {roots}) " // + "\nRETURN r1,r2,v,s", -// GRAPH_ATLAS_TYPES_CLAUSE, GRAPH_ATLAS_TYPES_CLAUSE, -// Conversions.GROUP_ID, Conversions.GROUP_ID, -// Conversions.ARTIFACT_ID, Conversions.ARTIFACT_ID, -// Conversions.SELECTED_FOR, Conversions.SELECTED_FOR, +// GRAPH_ATLAS_TYPES_CLAUSE, GRAPH_ATLAS_TYPES_CLAUSE, +// Conversions.GROUP_ID, Conversions.GROUP_ID, +// Conversions.ARTIFACT_ID, Conversions.ARTIFACT_ID, +// Conversions.SELECTED_FOR, Conversions.SELECTED_FOR, // Conversions.DESELECTED_FOR, Conversions.DESELECTED_FOR // ); - + /* @formatter:on */ private boolean closed = false; @@ -531,7 +531,7 @@ public ProjectVersionRef getPathTargetRef( final GraphPath path ) return createdRelationshipsMap; } - private void insertRelationshipBatch( List> rels, Map> createdRelationshipsMap ) + private void insertRelationshipBatch( final List> rels, final Map> createdRelationshipsMap ) { final Transaction tx = graph.beginTx(); try @@ -2407,9 +2407,9 @@ public void addProjectError( final ProjectVersionRef ref, final String error ) { node = newProjectNode( ref ); } - + Conversions.storeError( node, error ); - + tx.success(); } finally diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java index a0c96156..964c9b5d 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java @@ -588,9 +588,6 @@ private static ArtifactRef toArtifactRef( final ProjectVersionRef ref, final Rel return null; } - final String type = getStringProperty( TYPE, rel ); - final String classifier = getStringProperty( CLASSIFIER, rel ); - return new NeoArtifactRef( ref, new NeoTypeAndClassifier( rel ) ); } From fc54eb867fa7c782f310f7a9207973d99ba4467f Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Wed, 13 Apr 2016 12:43:41 +0200 Subject: [PATCH 134/240] Fix NotFoundExceptions and NullPointerExceptions After fixing of the relationship deserialization in #63 on commandline there were some NotFoundExceptions similar to those in #55 followed by some NullPointerExceptions somewhere in neo4j. Unfortunately Gnome collapsed and the console got closed and the exceptions are not in indy log, so the stacktraces are lost. Anyway during #63 debugging I noticed that TypeAndClassifier instances are not detached in Conversions.convertToDetachedRelationships(), so the produced SimpleArtifactRef instances in target field contained NeoTypeAndClassifier instances referencing RelationshipProxy. This is obviously wrong. --- .../maven/atlas/ident/ref/SimpleArtifactRef.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRef.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRef.java index 2d50d2f2..49356aef 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRef.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRef.java @@ -59,7 +59,7 @@ public SimpleArtifactRef( final ProjectVersionRef ref, final String type, final public SimpleArtifactRef( final ProjectVersionRef ref, final TypeAndClassifier tc ) { super( ref.getGroupId(), ref.getArtifactId(), ref.getVersionSpecRaw(), ref.getVersionStringRaw() ); - this.tc = tc; + this.tc = getSimpleTypeAndClassifier( tc ); } public SimpleArtifactRef( final String groupId, final String artifactId, final String versionSpec, @@ -73,7 +73,19 @@ public SimpleArtifactRef( final String groupId, final String artifactId, final S public SimpleArtifactRef( final ArtifactRef ref ) { super( ref ); - this.tc = ref.getTypeAndClassifier(); + this.tc = getSimpleTypeAndClassifier( ref.getTypeAndClassifier() ); + } + + private SimpleTypeAndClassifier getSimpleTypeAndClassifier( final TypeAndClassifier tc ) + { + if ( tc instanceof SimpleTypeAndClassifier ) + { + return ( SimpleTypeAndClassifier ) tc; + } + else + { + return new SimpleTypeAndClassifier( tc.getType(), tc.getClassifier() ); + } } @Override From ea5cd9cc8683896d1f83890e904e697104651ff8 Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 1 Jun 2016 16:19:28 -0500 Subject: [PATCH 135/240] [maven-release-plugin] prepare release atlas-parent-0.16.1 --- bindings/jackson-identities/pom.xml | 2 +- bindings/jackson-relationships/pom.xml | 2 +- bindings/pom.xml | 2 +- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- ftests/jung/pom.xml | 2 +- ftests/neo4j/pom.xml | 2 +- ftests/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 18 +++++++++--------- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index c6071214..5a9e5814 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.16.1-SNAPSHOT + 0.16.1 atlas-bindings-jackson-identities diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml index 669b5148..54eb2349 100644 --- a/bindings/jackson-relationships/pom.xml +++ b/bindings/jackson-relationships/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.16.1-SNAPSHOT + 0.16.1 atlas-bindings-jackson-relationships diff --git a/bindings/pom.xml b/bindings/pom.xml index d3216bc2..b777496d 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.1-SNAPSHOT + 0.16.1 atlas-bindings-parent diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index a9b6c65b..66679478 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.16.1-SNAPSHOT + 0.16.1 atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 5d4dcb57..91500a09 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.16.1-SNAPSHOT + 0.16.1 atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 49196931..1aabbd8f 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.1-SNAPSHOT + 0.16.1 atlas-drivers-parent diff --git a/ftests/jung/pom.xml b/ftests/jung/pom.xml index e6ccf051..2a747fb8 100644 --- a/ftests/jung/pom.xml +++ b/ftests/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.16.1-SNAPSHOT + 0.16.1 atlas-ftests-jung diff --git a/ftests/neo4j/pom.xml b/ftests/neo4j/pom.xml index dc3de5f9..19ea5c47 100644 --- a/ftests/neo4j/pom.xml +++ b/ftests/neo4j/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.16.1-SNAPSHOT + 0.16.1 atlas-ftests-neo4j diff --git a/ftests/pom.xml b/ftests/pom.xml index 85d03b4f..387b55e4 100644 --- a/ftests/pom.xml +++ b/ftests/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.1-SNAPSHOT + 0.16.1 atlas-ftests-parent diff --git a/identities/pom.xml b/identities/pom.xml index 922d6409..4d3fdd42 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.1-SNAPSHOT + 0.16.1 atlas-identities diff --git a/pom.xml b/pom.xml index 5a0b6fb2..0c6edcb1 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.1-SNAPSHOT + 0.16.1 pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - HEAD + atlas-parent-0.16.1 @@ -48,37 +48,37 @@ org.commonjava.maven.atlas atlas-identities - 0.16.1-SNAPSHOT + 0.16.1 org.commonjava.maven.atlas atlas-relationships-api - 0.16.1-SNAPSHOT + 0.16.1 org.commonjava.maven.atlas atlas-bindings-jackson-identities - 0.16.1-SNAPSHOT + 0.16.1 org.commonjava.maven.atlas atlas-bindings-jackson-relationships - 0.16.1-SNAPSHOT + 0.16.1 org.commonjava.maven.atlas atlas-driver-jung - 0.16.1-SNAPSHOT + 0.16.1 org.commonjava.maven.atlas atlas-driver-neo4j-embedded - 0.16.1-SNAPSHOT + 0.16.1 org.commonjava.maven.atlas atlas-drivers-tck - 0.16.1-SNAPSHOT + 0.16.1 test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 0e43c74a..355125b0 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.1-SNAPSHOT + 0.16.1 atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index fd05fa7b..d8eedef4 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.1-SNAPSHOT + 0.16.1 atlas-drivers-tck From da8109b003e0a15c3fbc4f1f3d1c2d7fedddd2a2 Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 1 Jun 2016 16:19:31 -0500 Subject: [PATCH 136/240] [maven-release-plugin] prepare for next development iteration --- bindings/jackson-identities/pom.xml | 2 +- bindings/jackson-relationships/pom.xml | 2 +- bindings/pom.xml | 2 +- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- ftests/jung/pom.xml | 2 +- ftests/neo4j/pom.xml | 2 +- ftests/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 18 +++++++++--------- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 5a9e5814..564bdf8e 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.16.1 + 0.16.2-SNAPSHOT atlas-bindings-jackson-identities diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml index 54eb2349..d22e0e74 100644 --- a/bindings/jackson-relationships/pom.xml +++ b/bindings/jackson-relationships/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.16.1 + 0.16.2-SNAPSHOT atlas-bindings-jackson-relationships diff --git a/bindings/pom.xml b/bindings/pom.xml index b777496d..2ba305d5 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.1 + 0.16.2-SNAPSHOT atlas-bindings-parent diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index 66679478..e0845def 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.16.1 + 0.16.2-SNAPSHOT atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index 91500a09..b0682242 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.16.1 + 0.16.2-SNAPSHOT atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 1aabbd8f..ace5ba4d 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.1 + 0.16.2-SNAPSHOT atlas-drivers-parent diff --git a/ftests/jung/pom.xml b/ftests/jung/pom.xml index 2a747fb8..e55e96b0 100644 --- a/ftests/jung/pom.xml +++ b/ftests/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.16.1 + 0.16.2-SNAPSHOT atlas-ftests-jung diff --git a/ftests/neo4j/pom.xml b/ftests/neo4j/pom.xml index 19ea5c47..f0b96207 100644 --- a/ftests/neo4j/pom.xml +++ b/ftests/neo4j/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.16.1 + 0.16.2-SNAPSHOT atlas-ftests-neo4j diff --git a/ftests/pom.xml b/ftests/pom.xml index 387b55e4..a0a8e547 100644 --- a/ftests/pom.xml +++ b/ftests/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.1 + 0.16.2-SNAPSHOT atlas-ftests-parent diff --git a/identities/pom.xml b/identities/pom.xml index 4d3fdd42..d977f397 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.1 + 0.16.2-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index 0c6edcb1..1226689a 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.1 + 0.16.2-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - atlas-parent-0.16.1 + HEAD @@ -48,37 +48,37 @@ org.commonjava.maven.atlas atlas-identities - 0.16.1 + 0.16.2-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.16.1 + 0.16.2-SNAPSHOT org.commonjava.maven.atlas atlas-bindings-jackson-identities - 0.16.1 + 0.16.2-SNAPSHOT org.commonjava.maven.atlas atlas-bindings-jackson-relationships - 0.16.1 + 0.16.2-SNAPSHOT org.commonjava.maven.atlas atlas-driver-jung - 0.16.1 + 0.16.2-SNAPSHOT org.commonjava.maven.atlas atlas-driver-neo4j-embedded - 0.16.1 + 0.16.2-SNAPSHOT org.commonjava.maven.atlas atlas-drivers-tck - 0.16.1 + 0.16.2-SNAPSHOT test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 355125b0..84e49ace 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.1 + 0.16.2-SNAPSHOT atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index d8eedef4..697b8dc8 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.1 + 0.16.2-SNAPSHOT atlas-drivers-tck From d8a010a7e1623204eedb22ff3164897dbaec01f6 Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Sat, 2 Jul 2016 00:37:18 +0200 Subject: [PATCH 137/240] Add getRelationships method to RelationshipGraph --- .../atlas/graph/spi/jung/JungGraphConnection.java | 13 +++++++++++++ .../graph/spi/neo4j/FileNeo4JGraphConnection.java | 13 +++++++++++++ .../maven/atlas/graph/RelationshipGraph.java | 5 +++++ .../graph/spi/RelationshipGraphConnection.java | 8 +++++--- 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java index b89415af..dd285ef2 100644 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java +++ b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java @@ -1182,6 +1182,19 @@ public List getPathRefs( final ViewParams params, final Graph return refs; } + @Override + public List> getRelationships( final ViewParams params, final GraphPath path ) + { + if ( path != null && !( path instanceof JungGraphPath ) ) + { + throw new IllegalArgumentException( "Cannot get target GAV for: " + path + + ". This is not a JungGraphPath instance!" ); + } + + final JungGraphPath gp = (JungGraphPath) path; + return gp.getPathElements(); + } + @Override public String getWorkspaceId() { diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java index f0f37f9f..a87812ff 100644 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java +++ b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java @@ -2013,6 +2013,19 @@ public List getPathRefs( final ViewParams params, final Graph return refs; } + @Override + public List> getRelationships( final ViewParams params, final GraphPath path ) + { + if ( path != null && !( path instanceof Neo4jGraphPath ) ) + { + throw new IllegalArgumentException( "Cannot get refs for: " + path + + ". This is not a Neo4jGraphPathKey instance!" ); + } + + final Neo4jGraphPath gp = (Neo4jGraphPath) path; + return (List) convertToRelationships( gp, adminAccess ); + } + @Override public GraphPath createPath( final ProjectRelationship... rels ) { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java index ba7ca5bf..b192ed1d 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java @@ -700,6 +700,11 @@ public List getPathRefs( final GraphPath path ) return getConnectionInternal().getPathRefs( params, path ); } + public List> getRelationships( final GraphPath path ) + { + return getConnectionInternal().getRelationships( params, path ); + } + RelationshipGraphConnection getConnection() { return connection; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java index 74de7792..4483c151 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java @@ -38,7 +38,7 @@ public interface RelationshipGraphConnection extends Closeable { - /* + /* * ######################### * Mutations are viewless * ######################### @@ -61,7 +61,7 @@ void deleteRelationshipsDeclaredBy( ProjectVersionRef root ) /** * Add the given relationships. Skip/return those that introduce cycles. - * + * * @return The set of relationships that were NOT added because they introduce cycles. NEVER null, but maybe empty. */ Set> addRelationships( ProjectRelationship... rel ) @@ -82,7 +82,7 @@ void reindex() void reindex( final ProjectVersionRef ref ) throws RelationshipGraphConnectionException; - /* + /* * ################################################ * Queries require a view * --- @@ -172,6 +172,8 @@ void traverse( RelationshipGraphTraversal traversal, ProjectVersionRef root, Rel List getPathRefs( ViewParams params, GraphPath path ); + List> getRelationships( ViewParams params, GraphPath path ); + boolean isClosed(); String getWorkspaceId(); From 067692806d3f1b2a586a3c4fe08799b6e7fa73ea Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Sat, 2 Jul 2016 01:06:05 +0200 Subject: [PATCH 138/240] Add getDepExcludes to ProjectRelationshipFilter --- .../graph/filter/AbstractTypedFilter.java | 9 +++++- .../maven/atlas/graph/filter/AndFilter.java | 31 ++++++++++++++++++- .../maven/atlas/graph/filter/AnyFilter.java | 9 +++++- .../maven/atlas/graph/filter/BomFilter.java | 4 +-- .../atlas/graph/filter/DependencyFilter.java | 7 ++++- .../atlas/graph/filter/ExcludingFilter.java | 7 +++++ .../maven/atlas/graph/filter/NoneFilter.java | 9 +++++- .../maven/atlas/graph/filter/OrFilter.java | 23 +++++++++++++- .../graph/filter/PluginRuntimeFilter.java | 9 +++++- .../filter/ProjectRelationshipFilter.java | 25 ++++++++++----- 10 files changed, 117 insertions(+), 16 deletions(-) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java index a21b7bba..b039205b 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java @@ -26,6 +26,7 @@ import org.apache.commons.codec.digest.DigestUtils; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; public abstract class AbstractTypedFilter implements ProjectRelationshipFilter @@ -34,7 +35,7 @@ public abstract class AbstractTypedFilter // private final Logger logger = new Logger( getClass() ); /** - * + * */ private static final long serialVersionUID = 1L; @@ -167,6 +168,12 @@ public final boolean accept( final ProjectRelationship rel ) return false; } + @Override + public Set getDepExcludes() + { + return null; + } + public Set getRelationshipTypes() { return types; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java index 2ac134db..e47c7c84 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java @@ -16,15 +16,19 @@ package org.commonjava.maven.atlas.graph.filter; import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; public class AndFilter extends AbstractAggregatingFilter { /** - * + * */ private static final long serialVersionUID = 1L; @@ -54,6 +58,31 @@ public boolean accept( final ProjectRelationship rel ) return accepted; } + @Override + public Set getDepExcludes() + { + Set excludes = null; + for (ProjectRelationshipFilter filter : getFilters()) + { + Set filterExcludes = filter.getDepExcludes(); + if (filterExcludes == null || filterExcludes.isEmpty()) + { + excludes = null; + break; + } + + if (excludes == null) + { + excludes = new HashSet(filterExcludes); + } + else + { + excludes.retainAll( filterExcludes ); + } + } + return excludes; + } + @Override protected AbstractAggregatingFilter newChildFilter( final Collection childFilters ) { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AnyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AnyFilter.java index 03be5eef..3261d9d9 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AnyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AnyFilter.java @@ -21,13 +21,14 @@ import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; public class AnyFilter implements ProjectRelationshipFilter { /** - * + * */ private static final long serialVersionUID = 1L; @@ -97,4 +98,10 @@ public Set getAllowedTypes() return new HashSet( Arrays.asList( RelationshipType.values() ) ); } + @Override + public Set getDepExcludes() + { + return null; + } + } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/BomFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/BomFilter.java index a2005664..67d1de68 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/BomFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/BomFilter.java @@ -28,8 +28,8 @@ public class BomFilter private BomFilter() { - // BOMs are actually marked as concrete...somewhat counter-intuitive, - // but they're structural, so managed isn't quite correct (despite + // BOMs are actually marked as concrete...somewhat counter-intuitive, + // but they're structural, so managed isn't quite correct (despite // Maven's unfortunate choice for location). super( RelationshipType.BOM, true, false, true ); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java index ac9bac6c..9f5cb466 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java @@ -34,7 +34,7 @@ public class DependencyFilter { /** - * + * */ private static final long serialVersionUID = 1L; @@ -152,6 +152,11 @@ public ProjectRelationshipFilter getChildFilter( final ProjectRelationship return this; } + public Set getDepExcludes() + { + return excludes; + } + public boolean isUseImpliedScopes() { return useImpliedScopes; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java index 28d836f9..0261301f 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java @@ -23,6 +23,7 @@ import org.apache.commons.codec.digest.DigestUtils; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; public class ExcludingFilter @@ -67,6 +68,12 @@ public ProjectRelationshipFilter getChildFilter( final ProjectRelationship } } + @Override + public Set getDepExcludes() + { + return filter.getDepExcludes(); + } + @Override public String getLongId() { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/NoneFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/NoneFilter.java index 77208254..8af48e06 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/NoneFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/NoneFilter.java @@ -20,13 +20,14 @@ import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; public class NoneFilter implements ProjectRelationshipFilter { /** - * + * */ private static final long serialVersionUID = 1L; @@ -96,4 +97,10 @@ public Set getAllowedTypes() return Collections.emptySet(); } + @Override + public Set getDepExcludes() + { + return null; + } + } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java index 9495f52d..8cedbe7e 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java @@ -16,8 +16,12 @@ package org.commonjava.maven.atlas.graph.filter; import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; public class OrFilter extends AbstractAggregatingFilter @@ -26,7 +30,7 @@ public class OrFilter // private final Logger logger = new Logger( getClass() ); /** - * + * */ private static final long serialVersionUID = 1L; @@ -57,6 +61,23 @@ public boolean accept( final ProjectRelationship rel ) return accepted; } + @Override + public Set getDepExcludes() + { + Set excludes = new HashSet(); + for (ProjectRelationshipFilter filter : getFilters()) + { + Set filterExcludes = filter.getDepExcludes(); + if (filterExcludes == null) + { + continue; + } + + excludes.addAll( filterExcludes ); + } + return excludes; + } + @Override protected AbstractAggregatingFilter newChildFilter( final Collection childFilters ) { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java index e8a4ffd6..d57b54a1 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java @@ -23,13 +23,14 @@ import org.commonjava.maven.atlas.graph.rel.RelationshipType; import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; public class PluginRuntimeFilter implements ProjectRelationshipFilter { /** - * + * */ private static final long serialVersionUID = 1L; @@ -64,6 +65,12 @@ public ProjectRelationshipFilter getChildFilter( final ProjectRelationship return child; } + @Override + public Set getDepExcludes() + { + return null; + } + @Override public String getLongId() { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ProjectRelationshipFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ProjectRelationshipFilter.java index 86a5d568..4443829b 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ProjectRelationshipFilter.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ProjectRelationshipFilter.java @@ -20,12 +20,13 @@ import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.graph.rel.RelationshipType; +import org.commonjava.maven.atlas.ident.ref.ProjectRef; /** * Filter used to determine which paths in a dependency graph to traverse (or discover). * The full dependency graph (relation dependency, not just maven-style dependency) * will be QUITE extensive, so a filter should be used in NEARLY ALL cases. - * + * * @author jdcasey */ public interface ProjectRelationshipFilter @@ -34,26 +35,36 @@ public interface ProjectRelationshipFilter /** * Determine whether the given relationship should be traversed. - * + * * @param rel The relationship in question * @return true to allow traversal, false otherwise. */ boolean accept( ProjectRelationship rel ); /** - * Return the filter used to handle the next wave of relationships after the + * Return the filter used to handle the next wave of relationships after the * given one is traversed. - * + * * @param parent The parent relationship for the set of relationships to which * the return filter from this method will be applied - * - * @return This instance WHENEVER POSSIBLE, but possibly a different filter + * + * @return This instance WHENEVER POSSIBLE, but possibly a different filter * if the relationship demands a shift in logic. */ ProjectRelationshipFilter getChildFilter( ProjectRelationship parent ); /** - * Retrieve a human-readable string that uniquely identifies the logic in this filter, + * Provides set of dependency exclusions applied by this filter. It means only exclusions + * applied on dependency relationships, not subgraph exclusions, i.e. a changing set of with + * traversing the dependency graph, not the constant part which is provided as part of the + * request. + * + * @return the set of dependency exclusions, might be {@code null} + */ + Set getDepExcludes(); + + /** + * Retrieve a human-readable string that uniquely identifies the logic in this filter, * along with any state stored in this instance. */ String getLongId(); From 7cf4ed51644fc94196615675ad8913ada24fc1e2 Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 7 Sep 2016 15:43:44 -0500 Subject: [PATCH 139/240] [maven-release-plugin] prepare release atlas-parent-0.16.2 --- bindings/jackson-identities/pom.xml | 2 +- bindings/jackson-relationships/pom.xml | 2 +- bindings/pom.xml | 2 +- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- ftests/jung/pom.xml | 2 +- ftests/neo4j/pom.xml | 2 +- ftests/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 18 +++++++++--------- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 564bdf8e..0068eb03 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.16.2-SNAPSHOT + 0.16.2 atlas-bindings-jackson-identities diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml index d22e0e74..37a74c68 100644 --- a/bindings/jackson-relationships/pom.xml +++ b/bindings/jackson-relationships/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.16.2-SNAPSHOT + 0.16.2 atlas-bindings-jackson-relationships diff --git a/bindings/pom.xml b/bindings/pom.xml index 2ba305d5..40639169 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.2-SNAPSHOT + 0.16.2 atlas-bindings-parent diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index e0845def..166445ed 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.16.2-SNAPSHOT + 0.16.2 atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index b0682242..f868a502 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.16.2-SNAPSHOT + 0.16.2 atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index ace5ba4d..39e33f57 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.2-SNAPSHOT + 0.16.2 atlas-drivers-parent diff --git a/ftests/jung/pom.xml b/ftests/jung/pom.xml index e55e96b0..8b812c46 100644 --- a/ftests/jung/pom.xml +++ b/ftests/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.16.2-SNAPSHOT + 0.16.2 atlas-ftests-jung diff --git a/ftests/neo4j/pom.xml b/ftests/neo4j/pom.xml index f0b96207..bbb425e3 100644 --- a/ftests/neo4j/pom.xml +++ b/ftests/neo4j/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.16.2-SNAPSHOT + 0.16.2 atlas-ftests-neo4j diff --git a/ftests/pom.xml b/ftests/pom.xml index a0a8e547..e617d412 100644 --- a/ftests/pom.xml +++ b/ftests/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.2-SNAPSHOT + 0.16.2 atlas-ftests-parent diff --git a/identities/pom.xml b/identities/pom.xml index d977f397..06d15765 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.2-SNAPSHOT + 0.16.2 atlas-identities diff --git a/pom.xml b/pom.xml index 1226689a..925af683 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.2-SNAPSHOT + 0.16.2 pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - HEAD + atlas-parent-0.16.2 @@ -48,37 +48,37 @@ org.commonjava.maven.atlas atlas-identities - 0.16.2-SNAPSHOT + 0.16.2 org.commonjava.maven.atlas atlas-relationships-api - 0.16.2-SNAPSHOT + 0.16.2 org.commonjava.maven.atlas atlas-bindings-jackson-identities - 0.16.2-SNAPSHOT + 0.16.2 org.commonjava.maven.atlas atlas-bindings-jackson-relationships - 0.16.2-SNAPSHOT + 0.16.2 org.commonjava.maven.atlas atlas-driver-jung - 0.16.2-SNAPSHOT + 0.16.2 org.commonjava.maven.atlas atlas-driver-neo4j-embedded - 0.16.2-SNAPSHOT + 0.16.2 org.commonjava.maven.atlas atlas-drivers-tck - 0.16.2-SNAPSHOT + 0.16.2 test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 84e49ace..0d5e340c 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.2-SNAPSHOT + 0.16.2 atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 697b8dc8..753e26d6 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.2-SNAPSHOT + 0.16.2 atlas-drivers-tck From 4256b66399d717fb93d948f68cd99dbd3baa7a57 Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 7 Sep 2016 15:43:48 -0500 Subject: [PATCH 140/240] [maven-release-plugin] prepare for next development iteration --- bindings/jackson-identities/pom.xml | 2 +- bindings/jackson-relationships/pom.xml | 2 +- bindings/pom.xml | 2 +- drivers/jung/pom.xml | 2 +- drivers/neo4j-embedded/pom.xml | 2 +- drivers/pom.xml | 2 +- ftests/jung/pom.xml | 2 +- ftests/neo4j/pom.xml | 2 +- ftests/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 18 +++++++++--------- relationships-api/pom.xml | 2 +- tck/pom.xml | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 0068eb03..586c12ae 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.16.2 + 0.16.3-SNAPSHOT atlas-bindings-jackson-identities diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml index 37a74c68..76b7ac0f 100644 --- a/bindings/jackson-relationships/pom.xml +++ b/bindings/jackson-relationships/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.16.2 + 0.16.3-SNAPSHOT atlas-bindings-jackson-relationships diff --git a/bindings/pom.xml b/bindings/pom.xml index 40639169..e503af42 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.2 + 0.16.3-SNAPSHOT atlas-bindings-parent diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml index 166445ed..063fbe64 100644 --- a/drivers/jung/pom.xml +++ b/drivers/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.16.2 + 0.16.3-SNAPSHOT atlas-driver-jung diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml index f868a502..edbfc0a4 100644 --- a/drivers/neo4j-embedded/pom.xml +++ b/drivers/neo4j-embedded/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-drivers-parent - 0.16.2 + 0.16.3-SNAPSHOT atlas-driver-neo4j-embedded diff --git a/drivers/pom.xml b/drivers/pom.xml index 39e33f57..53ac1742 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.2 + 0.16.3-SNAPSHOT atlas-drivers-parent diff --git a/ftests/jung/pom.xml b/ftests/jung/pom.xml index 8b812c46..b5e50f5f 100644 --- a/ftests/jung/pom.xml +++ b/ftests/jung/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.16.2 + 0.16.3-SNAPSHOT atlas-ftests-jung diff --git a/ftests/neo4j/pom.xml b/ftests/neo4j/pom.xml index bbb425e3..3850e762 100644 --- a/ftests/neo4j/pom.xml +++ b/ftests/neo4j/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-ftests-parent - 0.16.2 + 0.16.3-SNAPSHOT atlas-ftests-neo4j diff --git a/ftests/pom.xml b/ftests/pom.xml index e617d412..82470782 100644 --- a/ftests/pom.xml +++ b/ftests/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.2 + 0.16.3-SNAPSHOT atlas-ftests-parent diff --git a/identities/pom.xml b/identities/pom.xml index 06d15765..a53045a3 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.2 + 0.16.3-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index 925af683..7956d077 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.2 + 0.16.3-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - atlas-parent-0.16.2 + HEAD @@ -48,37 +48,37 @@ org.commonjava.maven.atlas atlas-identities - 0.16.2 + 0.16.3-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.16.2 + 0.16.3-SNAPSHOT org.commonjava.maven.atlas atlas-bindings-jackson-identities - 0.16.2 + 0.16.3-SNAPSHOT org.commonjava.maven.atlas atlas-bindings-jackson-relationships - 0.16.2 + 0.16.3-SNAPSHOT org.commonjava.maven.atlas atlas-driver-jung - 0.16.2 + 0.16.3-SNAPSHOT org.commonjava.maven.atlas atlas-driver-neo4j-embedded - 0.16.2 + 0.16.3-SNAPSHOT org.commonjava.maven.atlas atlas-drivers-tck - 0.16.2 + 0.16.3-SNAPSHOT test diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 0d5e340c..fed556e0 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.2 + 0.16.3-SNAPSHOT atlas-relationships-api diff --git a/tck/pom.xml b/tck/pom.xml index 753e26d6..9b66691c 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.2 + 0.16.3-SNAPSHOT atlas-drivers-tck From 736f256841348b74757877ed8b0c6fb6bf70810a Mon Sep 17 00:00:00 2001 From: Gang Li Date: Mon, 10 Oct 2016 15:17:54 +0800 Subject: [PATCH 141/240] Adds .gitignore --- .gitignore | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..5db1c859 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +# build +target + +# eclipse +.classpath +.project +.settings + +# idea +.idea +*.iml +*.iws +*.ipr From 3d5699c740c6a7715a58b2c4b3789967dfdf28c7 Mon Sep 17 00:00:00 2001 From: Rui Han Date: Thu, 8 Dec 2016 15:03:33 +0800 Subject: [PATCH 142/240] Refactor atlas to keep only models and move everything else to cartographer --- .../ProjectRelationshipDeserializer.java | 3 +- ...ojectRelationshipSerializerModuleTest.java | 3 +- drivers/jung/pom.xml | 39 - .../spi/jung/CycleDetectionTraversal.java | 77 - .../graph/spi/jung/JungGraphConnection.java | 1230 -------- .../spi/jung/JungGraphConnectionFactory.java | 78 - .../spi/jung/PathDetectionTraversal.java | 124 - .../graph/spi/jung/model/JungGraphPath.java | 175 -- drivers/neo4j-embedded/LICENSE.txt | 700 ----- drivers/neo4j-embedded/performance-todo.txt | 46 - drivers/neo4j-embedded/pom.xml | 72 - .../spi/neo4j/FileNeo4JGraphConnection.java | 2484 ----------------- .../spi/neo4j/FileNeo4jConnectionFactory.java | 229 -- .../atlas/graph/spi/neo4j/GraphAdmin.java | 45 - .../atlas/graph/spi/neo4j/GraphRelType.java | 128 - .../graph/spi/neo4j/Neo4JGraphConnection.java | 54 - .../atlas/graph/spi/neo4j/NodeToString.java | 38 - .../maven/atlas/graph/spi/neo4j/NodeType.java | 23 - .../atlas/graph/spi/neo4j/PathComparator.java | 124 - .../atlas/graph/spi/neo4j/RelToString.java | 37 - .../atlas/graph/spi/neo4j/ViewIndexes.java | 65 - .../atlas/graph/spi/neo4j/io/Conversions.java | 1199 -------- ...icProjectRelationshipSerializerModule.java | 83 - ...ificProjectVersionRefSerializerModule.java | 95 - .../graph/spi/neo4j/io/NodeIdProjector.java | 29 - .../atlas/graph/spi/neo4j/io/Projector.java | 23 - .../spi/neo4j/io/RelationshipIdProjector.java | 29 - .../model/AbstractNeoProjectRelationship.java | 227 -- .../graph/spi/neo4j/model/CyclePath.java | 333 --- .../graph/spi/neo4j/model/Neo4jGraphPath.java | 299 -- .../graph/spi/neo4j/model/NeoArtifactRef.java | 229 -- .../spi/neo4j/model/NeoBomRelationship.java | 105 - .../model/NeoDependencyRelationship.java | 196 -- .../neo4j/model/NeoExtensionRelationship.java | 112 - .../spi/neo4j/model/NeoIdentityUtils.java | 102 - .../neo4j/model/NeoParentRelationship.java | 135 - .../NeoPluginDependencyRelationship.java | 171 -- .../neo4j/model/NeoPluginRelationship.java | 147 - .../graph/spi/neo4j/model/NeoProjectRef.java | 251 -- .../spi/neo4j/model/NeoProjectVersionRef.java | 366 --- .../spi/neo4j/model/NeoTypeAndClassifier.java | 156 -- .../model/NeoVersionlessArtifactRef.java | 213 -- .../traverse/AbstractTraverseVisitor.java | 61 - .../spi/neo4j/traverse/AtlasCollector.java | 283 -- .../traverse/AtlasRelIndexComparator.java | 46 - .../MembershipWrappedTraversalEvaluator.java | 250 -- .../graph/spi/neo4j/traverse/NodePair.java | 71 - .../neo4j/traverse/PathCollectingVisitor.java | 64 - .../neo4j/traverse/PathExistenceVisitor.java | 59 - .../traverse/RootedRelationshipsVisitor.java | 73 - .../traverse/SubPathsCollectingVisitor.java | 99 - .../spi/neo4j/traverse/TraversalUtils.java | 173 -- .../spi/neo4j/traverse/TraverseVisitor.java | 63 - .../traverse/track/LuceneSeenTracker.java | 103 - .../traverse/track/MemorySeenTracker.java | 66 - .../traverse/track/TraverseSeenTracker.java | 28 - .../spi/neo4j/update/CycleCacheUpdater.java | 216 -- .../graph/spi/neo4j/update/ViewUpdater.java | 235 -- ...ojectRelationshipSerializerModuleTest.java | 359 --- ...ProjectVersionRefSerializerModuleTest.java | 202 -- .../spi/neo4j/model/NeoIdentitiesTest.java | 127 - .../NeoProjectRelationshipEqualitiesTest.java | 282 -- drivers/pom.xml | 44 - ftests/jung/pom.xml | 43 - .../graph/spi/jung/fixture/JungTCKDriver.java | 64 - ...a.maven.atlas.tck.graph.testutil.TCKDriver | 1 - .../jung/src/main/resources/logback-test.xml | 29 - ftests/neo4j/pom.xml | 60 - .../graph/spi/neo4j/fixture/NeoTCKDriver.java | 64 - ...a.maven.atlas.tck.graph.testutil.TCKDriver | 1 - .../neo4j/src/main/resources/logback-test.xml | 29 - ftests/pom.xml | 80 - pom.xml | 31 - .../AbstractRelationshipGraphListener.java | 75 - .../maven/atlas/graph/RelationshipGraph.java | 762 ----- .../graph/RelationshipGraphException.java | 64 - .../atlas/graph/RelationshipGraphFactory.java | 362 --- .../graph/RelationshipGraphListener.java | 42 - .../RelationshipGraphListenerFactory.java | 23 - .../maven/atlas/graph/ViewParams.java | 569 ---- .../filter/AbstractAggregatingFilter.java | 256 -- .../graph/filter/AbstractTypedFilter.java | 327 --- .../maven/atlas/graph/filter/AndFilter.java | 97 - .../maven/atlas/graph/filter/AnyFilter.java | 107 - .../maven/atlas/graph/filter/BomFilter.java | 49 - .../atlas/graph/filter/DependencyFilter.java | 244 -- .../graph/filter/DependencyOnlyFilter.java | 133 - .../atlas/graph/filter/ExcludingFilter.java | 117 - .../atlas/graph/filter/ExtensionFilter.java | 51 - .../graph/filter/ExtensionOnlyFilter.java | 41 - .../maven/atlas/graph/filter/NoneFilter.java | 106 - .../maven/atlas/graph/filter/OrFilter.java | 92 - .../atlas/graph/filter/ParentFilter.java | 91 - .../graph/filter/PluginDependencyFilter.java | 132 - .../filter/PluginDependencyOnlyFilter.java | 120 - .../atlas/graph/filter/PluginOnlyFilter.java | 63 - .../graph/filter/PluginRuntimeFilter.java | 118 - .../filter/ProjectRelationshipFilter.java | 85 - .../graph/filter/RelationshipTypeFilter.java | 75 - .../filter/StructuralRelationshipsFilter.java | 50 - .../atlas/graph/model/EProjectCycle.java | 4 +- .../model/EProjectDirectRelationships.java | 4 +- .../maven/atlas/graph/model/GraphPath.java | 22 - .../atlas/graph/model/GraphPathInfo.java | 164 -- .../atlas/graph/mutate/GraphMutator.java | 84 - .../mutate/ManagedDependencyMutator.java | 64 - .../atlas/graph/mutate/NoOpGraphMutator.java | 87 - .../graph/mutate/VersionManagerMutator.java | 119 - .../AbstractSimpleProjectRelationship.java | 2 +- .../graph/rel/RelationshipComparator.java | 2 +- .../graph/rel/RelationshipConstants.java | 59 + .../rel/SimpleExtensionRelationship.java | 5 +- .../graph/rel/SimpleParentRelationship.java | 5 +- .../spi/RelationshipGraphConnection.java | 181 -- .../RelationshipGraphConnectionException.java | 36 - .../RelationshipGraphConnectionFactory.java | 42 - .../traverse/AbstractFilteringTraversal.java | 118 - .../graph/traverse/AbstractTraversal.java | 51 - .../graph/traverse/AncestryTraversal.java | 37 - .../graph/traverse/BuildOrderTraversal.java | 171 -- .../graph/traverse/FilteringTraversal.java | 83 - .../atlas/graph/traverse/ImpactTraversal.java | 115 - .../atlas/graph/traverse/PathsTraversal.java | 137 - .../traverse/RelationshipGraphTraversal.java | 38 - .../TransitiveDependencyTraversal.java | 89 - .../atlas/graph/traverse/TraversalType.java | 23 - .../graph/traverse/model/BuildOrder.java | 59 - .../DependencyTreeRelationshipPrinter.java | 182 -- .../graph/traverse/print/ListPrinter.java | 167 -- .../print/StructurePrintingTraversal.java | 226 -- .../print/StructureRelationshipPrinter.java | 32 - .../traverse/print/TargetRefPrinter.java | 94 - .../graph/traverse/print/TreePrinter.java | 185 -- .../atlas/graph/util/RelationshipUtils.java | 439 +-- .../graph/EProjectRelationshipsTest.java | 99 - .../graph/filter/DependencyFilterTest.java | 58 - .../graph/rel/RelationshipComparatorTest.java | 2 +- tck/pom.xml | 48 - .../atlas/tck/graph/AbstractSPI_TCK.java | 143 - .../tck/graph/batch/LargeBatchInsertTCK.java | 100 - ...phConnection_CreateAndRetrieveByIdTCK.java | 55 - ...onnection_CreateAndVerifyInListingTCK.java | 55 - .../cycle/CycleDetection_BackToRootTCK.java | 78 - .../CycleDetection_BetweenDepLevelsTCK.java | 88 - .../CycleDetection_FilterRemovesCycleTCK.java | 105 - ...CycleDetection_IntroduceToExistingTCK.java | 67 - .../CycleDetection_RootDependentTCK.java | 101 - ...GraphFactory_OpenStoreDeleteReopenTCK.java | 148 - ...elationshipGraph_ConnectOutOfOrderTCK.java | 87 - ...ationshipGraph_ConnectWParentInterTCK.java | 81 - ...pGraph_NullPathOnTargetExprVersionTCK.java | 62 - ...ionshipGraph_StoreAndVerifyInView_TCK.java | 70 - .../graph/selection/SubGraphSelectionTCK.java | 80 - ...SubGraphSelection_ContextualToViewTCK.java | 90 - .../atlas/tck/graph/testutil/TCKDriver.java | 34 - ...tryTraversal_EmptyGrandparentRels_TCK.java | 80 - ...stryTraversal_IgnoreNonParentRels_TCK.java | 87 - .../AncestryTraversal_TwoAncestors_TCK.java | 90 - .../buildorder/AbstractBuildOrderTCK.java | 79 - ...ndencyBuildOrderIgnoringPluginPathTCK.java | 86 - .../DependencyExcludesBuildOrderTCK.java | 85 - .../ParentDependencyBuildOrderTCK.java | 90 - .../RuntimeDependencyBuildOrderTCK.java | 92 - .../SimpleDependencyBuildOrderTCK.java | 79 - .../SimpleEverythingBuildOrderTCK.java | 91 - ...sitiveDependencyTraversal_DepOfDepTCK.java | 75 - ...pendencyTraversal_DepOfDep_ExtMgmtTCK.java | 83 - ...veDependencyTraversal_PreferDirectTCK.java | 79 - ...iveDependencyTraversal_PreferLocalTCK.java | 77 - 169 files changed, 91 insertions(+), 23690 deletions(-) delete mode 100644 drivers/jung/pom.xml delete mode 100644 drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTraversal.java delete mode 100644 drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java delete mode 100644 drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnectionFactory.java delete mode 100644 drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java delete mode 100644 drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/model/JungGraphPath.java delete mode 100644 drivers/neo4j-embedded/LICENSE.txt delete mode 100644 drivers/neo4j-embedded/performance-todo.txt delete mode 100644 drivers/neo4j-embedded/pom.xml delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphAdmin.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphRelType.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/Neo4JGraphConnection.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeToString.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeType.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelToString.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/ViewIndexes.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoSpecificProjectRelationshipSerializerModule.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoSpecificProjectVersionRefSerializerModule.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NodeIdProjector.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Projector.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/RelationshipIdProjector.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/CyclePath.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoBomRelationship.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoExtensionRelationship.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentityUtils.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoParentRelationship.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoTypeAndClassifier.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AbstractTraverseVisitor.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasRelIndexComparator.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/NodePair.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathCollectingVisitor.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathExistenceVisitor.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/RootedRelationshipsVisitor.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/SubPathsCollectingVisitor.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraverseVisitor.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/LuceneSeenTracker.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/MemorySeenTracker.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/TraverseSeenTracker.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java delete mode 100644 drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java delete mode 100644 drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectRelationshipSerializerModuleTest.java delete mode 100644 drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectVersionRefSerializerModuleTest.java delete mode 100644 drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java delete mode 100644 drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRelationshipEqualitiesTest.java delete mode 100644 drivers/pom.xml delete mode 100644 ftests/jung/pom.xml delete mode 100644 ftests/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/fixture/JungTCKDriver.java delete mode 100644 ftests/jung/src/main/resources/META-INF/services/org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver delete mode 100644 ftests/jung/src/main/resources/logback-test.xml delete mode 100644 ftests/neo4j/pom.xml delete mode 100644 ftests/neo4j/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/NeoTCKDriver.java delete mode 100644 ftests/neo4j/src/main/resources/META-INF/services/org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver delete mode 100644 ftests/neo4j/src/main/resources/logback-test.xml delete mode 100644 ftests/pom.xml delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/AbstractRelationshipGraphListener.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphException.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListener.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListenerFactory.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AnyFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/BomFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionOnlyFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/NoneFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ParentFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyOnlyFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginOnlyFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ProjectRelationshipFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/RelationshipTypeFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/StructuralRelationshipsFilter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPath.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPathInfo.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/GraphMutator.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java create mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipConstants.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionException.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionFactory.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractFilteringTraversal.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractTraversal.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AncestryTraversal.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/FilteringTraversal.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/ImpactTraversal.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/RelationshipGraphTraversal.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TraversalType.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/model/BuildOrder.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/DependencyTreeRelationshipPrinter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructurePrintingTraversal.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructureRelationshipPrinter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TargetRefPrinter.java delete mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java delete mode 100644 relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java delete mode 100644 relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java delete mode 100644 tck/pom.xml delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/conn/RelationshipGraphConnection_CreateAndRetrieveByIdTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/conn/RelationshipGraphConnection_CreateAndVerifyInListingTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BackToRootTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/fac/RelationshipGraphFactory_OpenStoreDeleteReopenTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_ConnectOutOfOrderTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_ConnectWParentInterTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_NullPathOnTargetExprVersionTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelection_ContextualToViewTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/testutil/TCKDriver.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_EmptyGrandparentRels_TCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_TwoAncestors_TCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/AbstractBuildOrderTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDepTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDep_ExtMgmtTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferDirectTCK.java delete mode 100644 tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferLocalTCK.java diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java index c89e04b7..6cf1dd99 100644 --- a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java +++ b/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java @@ -19,7 +19,6 @@ import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import org.commonjava.maven.atlas.graph.rel.*; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.DependencyScope; import org.commonjava.maven.atlas.ident.ref.*; import org.slf4j.Logger; @@ -135,7 +134,7 @@ public T deserialize( final JsonParser jp, final DeserializationContext ctx ) URI pomLocation; if ( uri == null ) { - pomLocation = RelationshipUtils.POM_ROOT_URI; + pomLocation = RelationshipConstants.POM_ROOT_URI; } else { diff --git a/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java b/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java index 90e67af6..4496629d 100644 --- a/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java +++ b/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java @@ -17,7 +17,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.commonjava.maven.atlas.graph.rel.*; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.DependencyScope; import org.commonjava.maven.atlas.ident.jackson.ProjectVersionRefSerializerModule; import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; @@ -79,7 +78,7 @@ public void roundTrip_SimpleConcreteDependency() throws Exception { DependencyRelationship rel = - new SimpleDependencyRelationship( URI.create( "some:test:location" ), RelationshipUtils.POM_ROOT_URI, + new SimpleDependencyRelationship( URI.create( "some:test:location" ), RelationshipConstants.POM_ROOT_URI, new SimpleProjectVersionRef( "org.foo", "bar", "1" ), new SimpleProjectVersionRef( "org.foo", "dep", "1.1" ).asJarArtifact(), DependencyScope.compile, 0, false, false, false ); diff --git a/drivers/jung/pom.xml b/drivers/jung/pom.xml deleted file mode 100644 index 063fbe64..00000000 --- a/drivers/jung/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - 4.0.0 - - - org.commonjava.maven.atlas - atlas-drivers-parent - 0.16.3-SNAPSHOT - - - atlas-driver-jung - - Atlas :: Maven Project-Graph :: Jung Driver - - - - net.sf.jung - jung-graph-impl - - - - diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTraversal.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTraversal.java deleted file mode 100644 index b36cb9bd..00000000 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/CycleDetectionTraversal.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.jung; - -import static org.apache.commons.lang.StringUtils.join; - -import java.util.ArrayList; -import java.util.List; - -import org.commonjava.maven.atlas.graph.model.EProjectCycle; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.traverse.AbstractTraversal; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.util.JoinString; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -final class CycleDetectionTraversal - extends AbstractTraversal -{ - private final List cycles = new ArrayList(); - - private final ProjectRelationship rel; - - CycleDetectionTraversal( final ProjectRelationship rel ) - { - this.rel = rel; - } - - public List getCycles() - { - return cycles; - } - - @Override - public boolean preCheck( final ProjectRelationship relationship, final List> path ) - { - if ( rel.getDeclaring() - .equals( rel.getTarget() - .asProjectVersionRef() ) ) - { - return false; - } - - final Logger logger = LoggerFactory.getLogger( getClass() ); - - logger.debug( "Checking for cycle: {}\n\nPath: {}\n\n", relationship, new JoinString( "\n", path ) ); - - final ProjectVersionRef from = rel.getDeclaring(); - if ( from.equals( relationship.getTarget() - .asProjectVersionRef() ) ) - { - final List> cycle = new ArrayList>( path ); - cycle.add( rel ); - - cycles.add( new EProjectCycle( cycle ) ); - - logger.warn( "CYCLE: {}", join( cycle, ", " ) ); - return false; - } - - return true; - } -} diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java deleted file mode 100644 index dd285ef2..00000000 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnection.java +++ /dev/null @@ -1,1230 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.jung; - -import edu.uci.ics.jung.graph.DirectedGraph; -import edu.uci.ics.jung.graph.DirectedSparseMultigraph; -import org.apache.commons.lang.StringUtils; -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.filter.AnyFilter; -import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; -import org.commonjava.maven.atlas.graph.model.EProjectCycle; -import org.commonjava.maven.atlas.graph.model.GraphPath; -import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.rel.*; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; -import org.commonjava.maven.atlas.graph.spi.jung.model.JungGraphPath; -import org.commonjava.maven.atlas.graph.traverse.RelationshipGraphTraversal; -import org.commonjava.maven.atlas.graph.traverse.TraversalType; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.util.JoinString; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.net.URI; -import java.util.*; -import java.util.Map.Entry; - -import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.POM_ROOT_URI; -import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.UNKNOWN_SOURCE_URI; - -public class JungGraphConnection - implements RelationshipGraphConnection -{ - private final Logger logger = LoggerFactory.getLogger( getClass() ); - - private boolean closed = false; - - private DirectedGraph> graph = - new DirectedSparseMultigraph>(); - - private final Map> byGA = new HashMap>(); - - private transient Set incompleteSubgraphs = new HashSet(); - - private transient Set variableSubgraphs = new HashSet(); - - private final Map> metadataOwners = new HashMap>(); - - private final Map> metadata = - new HashMap>(); - - private final Set cycles = new HashSet(); - - private final Map errors = new HashMap(); - - private final String workspaceId; - - public JungGraphConnection( final String workspaceId ) - { - this.workspaceId = workspaceId; - } - - @Override - public Collection> getRelationshipsDeclaredBy( final ViewParams params, - final ProjectVersionRef ref ) - { - return imposeSelections( params, graph.getOutEdges( ref.asProjectVersionRef() ) ); - } - - @Override - public Collection> getRelationshipsTargeting( final ViewParams params, - final ProjectVersionRef ref ) - { - return imposeSelections( params, graph.getInEdges( ref.asProjectVersionRef() ) ); - } - - @Override - public Collection> getAllRelationships( final ViewParams params ) - { - return imposeSelections( params, graph.getEdges() ); - } - - private Collection> imposeSelections( final ViewParams params, - final Collection> edges ) - { - if ( edges == null || edges.isEmpty() ) - { - return edges; - } - - final List> result = new ArrayList>( edges.size() ); - for ( final ProjectRelationship edge : edges ) - { - if ( ( edge instanceof SimpleParentRelationship ) && ( (ParentRelationship) edge ).isTerminus() ) - { - continue; - } - - final ProjectVersionRef target = edge.getTarget() - .asProjectVersionRef(); - - final Set sources = params.getActiveSources(); - if ( sources != null && !sources.isEmpty() ) - { - if ( !sources.contains( RelationshipUtils.ANY_SOURCE_URI ) ) - { - Set s = edge.getSources(); - if ( s == null ) - { - s = Collections.singleton( UNKNOWN_SOURCE_URI ); - } - - boolean found = false; - for ( final URI uri : s ) - { - // TODO: What were the default sources?? - if ( /*sources == ViewParams.DEFAULT_SOURCES ||*/sources.contains( uri ) ) - { - found = true; - break; - } - } - - if ( !found ) - { - // log( "Found relationship in path with de-selected source-repository URI: %s", edge ); - continue; - } - } - } - - final Set pomLocations = params.getActivePomLocations(); - if ( pomLocations != null && !pomLocations.isEmpty() ) - { - URI pomLocation = edge.getPomLocation(); - if ( pomLocation == null ) - { - pomLocation = POM_ROOT_URI; - } - if ( !pomLocations.contains( pomLocation ) ) - { - // log( "Found relationship in path with de-selected pom-location URI: %s", edge ); - continue; - } - } - - final ProjectVersionRef selected = params == null ? null : params.getSelection( target ); - if ( selected != null ) - { - result.add( edge.selectTarget( selected ) ); - } - else - { - result.add( edge ); - } - } - - return result; - } - - @Override - public Set> addRelationships( final ProjectRelationship... rels ) - { - final Set> skipped = new HashSet>(); - for ( final ProjectRelationship rel : rels ) - { - if ( !graph.containsVertex( rel.getDeclaring() ) ) - { - // // logger.info( "Adding node: %s", rel.getDeclaring() ); - graph.addVertex( rel.getDeclaring() ); - addGA( rel.getDeclaring() ); - } - - final ProjectVersionRef target = rel.getTarget() - .asProjectVersionRef(); - if ( target.isVariableVersion() || !target.getVersionSpec() - .isSingle() ) - { - logger.info( "Adding variable target: {}", target ); - variableSubgraphs.add( target ); - } - else if ( !graph.containsVertex( target ) ) - { - // logger.info( "Adding incomplete target: %s", target ); - incompleteSubgraphs.add( target ); - } - - if ( !graph.containsVertex( target ) ) - { - // logger.info( "Adding node: %s", target ); - graph.addVertex( target.asProjectVersionRef() ); - addGA( target ); - } - - final List> edges = - new ArrayList>( graph.findEdgeSet( rel.getDeclaring(), target ) ); - if ( !edges.contains( rel ) ) - { - // logger.info( "Adding edge: %s -> %s", rel.getDeclaring(), target ); - graph.addEdge( rel, rel.getDeclaring(), target.asProjectVersionRef() ); - } - else - { - final int idx = edges.indexOf( rel ); - final ProjectRelationship existing = edges.get( idx ); - - // logger.info( "Adding sources: %s to existing edge: %s", rel.getSources(), existing ); - - existing.addSources( rel.getSources() ); - } - - // logger.info( "removing from incomplete status: %s", rel.getDeclaring() ); - incompleteSubgraphs.remove( rel.getDeclaring() ); - } - - for ( final ProjectRelationship rel : rels ) - { - if ( skipped.contains( rel ) ) - { - continue; - } - - // logger.info( "Detecting cycles introduced by: %s", rel ); - - final CycleDetectionTraversal traversal = new CycleDetectionTraversal( rel ); - - dfsTraverse( new ViewParams.Builder( workspaceId ).withActiveSources( Collections.singleton( RelationshipUtils.ANY_SOURCE_URI ) ) - .build(), traversal, rel.getTarget() - .asProjectVersionRef() ); - - final List cycles = traversal.getCycles(); - - if ( !cycles.isEmpty() ) - { - // logger.info( "CYCLE introduced by: %s", rel ); - skipped.add( rel ); - - graph.removeEdge( rel ); - this.cycles.addAll( cycles ); - } - } - - return skipped; - } - - private boolean addGA( final ProjectVersionRef ref ) - { - final ProjectRef pr = ref.asProjectRef(); - Set refs = byGA.get( pr ); - if ( refs == null ) - { - refs = new HashSet(); - byGA.put( pr, refs ); - } - - return refs.add( ref ); - } - - @Override - public Set>> getAllPathsTo( final ViewParams params, final ProjectVersionRef... refs ) - { - final PathDetectionTraversal traversal = new PathDetectionTraversal( this, params, refs ); - - final Set roots = params.getRoots(); - if ( roots == null ) - { - LoggerFactory.getLogger( getClass() ) - .warn( "Cannot retrieve paths targeting {}. No roots specified for this project network!", - new JoinString( ", ", refs ) ); - return null; - } - - for ( final ProjectVersionRef root : roots ) - { - dfsTraverse( params, traversal, root ); - } - - final Set paths = traversal.getPaths(); - final Set>> result = new HashSet>>( paths.size() ); - for ( final JungGraphPath path : paths ) - { - result.add( path.getPathElements() ); - } - - return result; - } - - @Override - public boolean introducesCycle( final ViewParams params, final ProjectRelationship rel ) - { - final CycleDetectionTraversal traversal = new CycleDetectionTraversal( rel ); - - dfsTraverse( params, traversal, rel.getTarget() - .asProjectVersionRef() ); - - return !traversal.getCycles() - .isEmpty(); - } - - @Override - public Set getAllProjects( final ViewParams params ) - { - return new HashSet( graph.getVertices() ); - } - - @Override - public void traverse( final RelationshipGraphTraversal traversal, final ProjectVersionRef root, - final RelationshipGraph graph, final TraversalType type ) - throws RelationshipGraphConnectionException - { - traversal.startTraverse( graph ); - - switch ( type ) - { - case breadth_first: - { - bfsTraverse( graph.getParams(), traversal, root ); - break; - } - case depth_first: - { - dfsTraverse( graph.getParams(), traversal, root ); - break; - } - } - - traversal.endTraverse( graph ); - } - - // TODO: Implement without recursion. - private void dfsTraverse( final ViewParams params, final RelationshipGraphTraversal traversal, - final ProjectVersionRef root ) - { - dfsIterate( params, root, traversal, new JungGraphPath( root ), new GraphPathInfo( this, params ) ); - } - - private void dfsIterate( final ViewParams params, final ProjectVersionRef node, - final RelationshipGraphTraversal traversal, final JungGraphPath path, - final GraphPathInfo pathInfo ) - { - final List> edges = getSortedOutEdges( params, node ); - if ( edges != null ) - { - for ( final ProjectRelationship edge : edges ) - { - final ProjectRelationship realEdge = pathInfo.selectRelationship( edge, path ); - if ( realEdge == null ) - { - continue; - } - - final JungGraphPath next = new JungGraphPath( path, realEdge ); - final List> pathElements = next.getPathElements(); - - if ( traversal.traverseEdge( realEdge, pathElements ) ) - { - final GraphPathInfo nextInfo = pathInfo.getChildPathInfo( realEdge ); - if ( !( edge instanceof SimpleParentRelationship ) || !( (ParentRelationship) edge ).isTerminus() ) - { - if ( next.hasCycle() ) - { - continue; - } - - final ProjectVersionRef target = edge.getTarget() - .asProjectVersionRef(); - - dfsIterate( params, target, traversal, next, nextInfo ); - } - - traversal.edgeTraversed( realEdge, pathElements ); - } - } - } - } - - // TODO: Implement without recursion. - private void bfsTraverse( final ViewParams params, final RelationshipGraphTraversal traversal, - final ProjectVersionRef root ) - { - final GraphPathInfo pathInfo = new GraphPathInfo( this, params ); - - bfsIterate( params, Collections.singletonMap( new JungGraphPath( root ), pathInfo ), traversal ); - } - - private void bfsIterate( final ViewParams params, final Map thisLayer, - final RelationshipGraphTraversal traversal ) - { - final Map nextLayer = new LinkedHashMap(); - - for ( final Entry entry : thisLayer.entrySet() ) - { - final JungGraphPath path = entry.getKey(); - final GraphPathInfo pathInfo = entry.getValue(); - - final ProjectVersionRef node = path.getTargetGAV(); - if ( node == null ) - { - continue; - } - - final List> edges = getSortedOutEdges( params, node ); - if ( edges != null ) - { - for ( final ProjectRelationship edge : edges ) - { - final ProjectRelationship realEdge = pathInfo.selectRelationship( edge, path ); - if ( realEdge == null ) - { - continue; - } - - final List> pathElements = path.getPathElements(); - // call traverseEdge no matter what, to allow traversal to "see" all relationships. - if ( traversal.traverseEdge( realEdge, pathElements ) ) - { - final JungGraphPath next = new JungGraphPath( path, realEdge ); - final GraphPathInfo nextInfo = pathInfo.getChildPathInfo( realEdge ); - - // Don't account for terminal parent relationship. - if ( !( realEdge instanceof SimpleParentRelationship ) - || !( (ParentRelationship) realEdge ).isTerminus() ) - { - if ( next.hasCycle() ) - { - continue; - } - - nextLayer.put( next, nextInfo ); - } - - traversal.edgeTraversed( realEdge, pathElements ); - } - } - } - } - - if ( !nextLayer.isEmpty() ) - { - bfsIterate( params, nextLayer, traversal ); - } - } - - private List> getSortedOutEdges( final ViewParams params, final ProjectVersionRef node ) - { - Collection> unsorted = graph.getOutEdges( node.asProjectVersionRef() ); - if ( unsorted == null ) - { - return null; - } - - unsorted = new ArrayList>( unsorted ); - - RelationshipUtils.filterTerminalParents( unsorted ); - - final List> sorted = - new ArrayList>( imposeSelections( params, unsorted ) ); - Collections.sort( sorted, RelationshipComparator.INSTANCE ); - - return sorted; - } - - // @Override - // public EGraphDriver newInstanceFrom( final EProjectNet net, final ProjectRelationshipFilter filter, - // final ProjectVersionRef... from ) - // throws GraphDriverException - // { - // final JungEGraphDriver neo = new JungEGraphDriver( this, filter, net, null, from ); - // neo.restrictProjectMembership( Arrays.asList( from ) ); - // - // return neo; - // } - // - // @Override - // public EGraphDriver newInstance( final EGraphSession workspace, final EProjectNet net, - // final ProjectRelationshipFilter filter, final ProjectVersionRef... from ) - // throws GraphDriverException - // { - // final JungEGraphDriver neo = new JungEGraphDriver( this, filter, net, null, from ); - // neo.restrictProjectMembership( Arrays.asList( from ) ); - // - // return neo; - // } - - @Override - public boolean containsProject( final ViewParams params, final ProjectVersionRef ref ) - { - return graph.containsVertex( ref.asProjectVersionRef() ) - && !incompleteSubgraphs.contains( ref.asProjectVersionRef() ); - } - - @Override - public boolean containsRelationship( final ViewParams params, final ProjectRelationship rel ) - { - return graph.containsEdge( rel ); - } - - public void restrictProjectMembership( final Collection refs ) - { - final Set> rels = new HashSet>(); - for ( final ProjectVersionRef ref : refs ) - { - final Collection> edges = graph.getOutEdges( ref.asProjectVersionRef() ); - if ( edges != null ) - { - rels.addAll( edges ); - } - } - - restrictRelationshipMembership( rels ); - } - - public void restrictRelationshipMembership( final Collection> rels ) - { - graph = new DirectedSparseMultigraph>(); - incompleteSubgraphs.clear(); - variableSubgraphs.clear(); - - addRelationships( rels.toArray( new ProjectRelationship[rels.size()] ) ); - - recomputeIncompleteSubgraphs(); - } - - @Override - public void close() - { - // NOP; stored in memory, just set the flag. - closed = true; - } - - @Override - public boolean isClosed() - { - return closed; - } - - // @Override - // public boolean isDerivedFrom( final EGraphDriver driver ) - // { - // return false; - // } - - @Override - public boolean isMissing( final ViewParams params, final ProjectVersionRef project ) - { - return !graph.containsVertex( project.asProjectVersionRef() ); - } - - @Override - public boolean hasMissingProjects( final ViewParams params ) - { - return !incompleteSubgraphs.isEmpty(); - } - - @Override - public Set getMissingProjects( final ViewParams params ) - { - final Set result = new HashSet( incompleteSubgraphs ); - for ( ProjectVersionRef ref: variableSubgraphs ) - { - ProjectVersionRef selected = params.getSelection( ref ); - if ( selected != null && !containsProject( params, selected ) ) - { - result.add( selected ); - } - } - // logger.info( "Got %d missing projects: %s", result.size(), result ); - return result; - } - - @Override - public boolean hasVariableProjects( final ViewParams params ) - { - return !variableSubgraphs.isEmpty(); - } - - @Override - public Set getVariableProjects( final ViewParams params ) - { - Set refs = new HashSet( variableSubgraphs ); - for ( Iterator iter = refs.iterator(); iter.hasNext(); ) - { - ProjectVersionRef gav = iter.next(); - logger.debug("Checking for selection of: {}", gav); - if ( params.hasSelection( gav ) ) - { - logger.debug( "Removing variable GAV: {}", gav ); - iter.remove(); - } - } - - logger.debug( "Resulting variable set: {}", refs ); - return refs; - } - - @Override - public boolean addCycle( final EProjectCycle cycle ) - { - boolean changed = false; - synchronized ( this.cycles ) - { - changed = this.cycles.add( cycle ); - } - - for ( final ProjectRelationship rel : cycle ) - { - incompleteSubgraphs.remove( rel.getDeclaring() ); - } - - return changed; - } - - // TODO: May not work with paths to the entries in the cycle...since filters are often path-sensitive - @Override - public Set getCycles( final ViewParams params ) - { - final Set result = new HashSet(); - if ( params.getFilter() == null || params.getFilter() - .equals( AnyFilter.INSTANCE ) ) - { - result.addAll( cycles ); - } - else - { - final ProjectRelationshipFilter filter = params.getFilter(); - nextCycle: for ( final EProjectCycle cycle : cycles ) - { - for ( final ProjectRelationship r : cycle ) - { - if ( !filter.accept( r ) ) - { - continue nextCycle; - } - } - - result.add( cycle ); - } - } - - return result; - } - - @Override - public boolean isCycleParticipant( final ViewParams params, final ProjectRelationship rel ) - { - for ( final EProjectCycle cycle : cycles ) - { - if ( cycle.contains( rel ) ) - { - return true; - } - } - - return false; - } - - @Override - public boolean isCycleParticipant( final ViewParams params, final ProjectVersionRef ref ) - { - for ( final EProjectCycle cycle : cycles ) - { - if ( cycle.contains( ref.asProjectVersionRef() ) ) - { - return true; - } - } - - return false; - } - - @Override - public void recomputeIncompleteSubgraphs() - { - final ViewParams params = - new ViewParams.Builder( workspaceId ).withActiveSources( Collections.singleton( RelationshipUtils.ANY_SOURCE_URI ) ) - .build(); - - for ( final ProjectVersionRef vertex : getAllProjects( params ) ) - { - final Collection> outEdges = getRelationshipsDeclaredBy( params, vertex ); - if ( outEdges != null && !outEdges.isEmpty() ) - { - incompleteSubgraphs.remove( vertex ); - } - } - } - - @Override - public Map getMetadata( final ProjectVersionRef ref ) - { - return getMetadata( ref, null ); - } - - @Override - public Map getMetadata( final ProjectVersionRef ref, final Set keys ) - { - Map metadata; - synchronized ( this ) - { - metadata = this.metadata.get( ref.asProjectVersionRef() ); - if ( metadata == null ) - { - metadata = new HashMap(); - this.metadata.put( ref.asProjectVersionRef(), metadata ); - } - } - - if ( keys != null && !keys.isEmpty() ) - { - metadata = new HashMap( metadata ); - final Set removable = new HashSet( metadata.keySet() ); - removable.removeAll( keys ); - - for ( final String remove : removable ) - { - metadata.remove( remove ); - } - } - - return metadata; - } - - @Override - public void addMetadata( final ProjectVersionRef ref, final String key, final String value ) - { - if ( StringUtils.isEmpty( key ) || StringUtils.isEmpty( value ) ) - { - return; - } - - final Map md = getMetadata( ref.asProjectVersionRef() ); - md.put( key, value ); - - addMetadataOwner( key, ref.asProjectVersionRef() ); - } - - private synchronized void addMetadataOwner( final String key, final ProjectVersionRef ref ) - { - Set owners = this.metadataOwners.get( key ); - if ( owners == null ) - { - owners = new HashSet(); - metadataOwners.put( key, owners ); - } - - owners.add( ref.asProjectVersionRef() ); - } - - @Override - public void setMetadata( final ProjectVersionRef ref, final Map metadata ) - { - if ( metadata == null || metadata.isEmpty() ) - { - return; - } - - final Map md = getMetadata( ref.asProjectVersionRef() ); - md.putAll( metadata ); - } - - @Override - public synchronized void reindex() - throws RelationshipGraphConnectionException - { - for ( final Map.Entry> refEntry : metadata.entrySet() ) - { - for ( final Map.Entry mdEntry : refEntry.getValue() - .entrySet() ) - { - addMetadataOwner( mdEntry.getKey(), refEntry.getKey() - .asProjectVersionRef() ); - } - } - } - - @Override - public synchronized void reindex( final ProjectVersionRef ref ) - { - if ( ref == null ) - { - return; - } - - final Map map = metadata.get( ref ); - if ( map != null ) - { - for ( final Map.Entry mdEntry : map.entrySet() ) - { - addMetadataOwner( mdEntry.getKey(), ref ); - } - } - } - - @Override - public Set getProjectsWithMetadata( final ViewParams params, final String key ) - { - return metadataOwners.get( key ); - } - - // public void selectVersionFor( final ProjectVersionRef variable, final ProjectVersionRef select ) - // throws GraphDriverException - // { - // if ( !select.isSpecificVersion() ) - // { - // throw new GraphDriverException( "Cannot select non-concrete version! Attempted to select: %s", select ); - // } - // - // if ( variable.isSpecificVersion() ) - // { - // throw new GraphDriverException( - // "Cannot select version if target is already a concrete version! Attempted to select for: %s", - // variable ); - // } - // - // selected.put( variable, select ); - // - // // Don't worry about selecting for outbound edges, as those subgraphs are supposed to be the same... - // final Collection> rels = graph.getInEdges( variable ); - // for ( final ProjectRelationship rel : rels ) - // { - // - // ProjectRelationship repl; - // if ( rel.getTarget() - // .asProjectVersionRef() - // .equals( variable ) ) - // { - // repl = rel.selectTarget( (SingleVersion) select.getVersionSpec() ); - // } - // else - // { - // continue; - // } - // - // graph.removeEdge( rel ); - // graph.addEdge( repl, repl.getDeclaring(), repl.getTarget() - // .asProjectVersionRef() ); - // - // replaced.put( rel, repl ); - // } - // } - // - // public Map clearSelectedVersions() - // { - // final Map selected = - // new HashMap( this.selected ); - // - // selected.clear(); - // - // for ( final Map.Entry, ProjectRelationship> entry : replaced.entrySet() ) - // { - // final ProjectRelationship rel = entry.getKey(); - // final ProjectRelationship repl = entry.getValue(); - // - // graph.removeEdge( repl ); - // graph.addEdge( rel, rel.getDeclaring(), rel.getTarget() - // .asProjectVersionRef() ); - // } - // - // for ( final ProjectVersionRef select : new HashSet( selected.values() ) ) - // { - // final Collection> edges = graph.getInEdges( select ); - // if ( edges.isEmpty() ) - // { - // graph.removeVertex( select ); - // } - // } - // - // return selected; - // } - // - // public Map getSelectedVersions() - // { - // return selected; - // } - - @Override - public void addDisconnectedProject( final ProjectVersionRef ref ) - { - if ( !graph.containsVertex( ref.asProjectVersionRef() ) ) - { - graph.addVertex( ref.asProjectVersionRef() ); - } - } - - @Deprecated - @Override - public Set> getDirectRelationshipsFrom( final ViewParams params, - final ProjectVersionRef from, - final boolean includeManagedInfo, - final RelationshipType... types ) - { - return getDirectRelationshipsFrom( params, from, includeManagedInfo, true, types ); - } - - @Override - public Set> getDirectRelationshipsFrom( final ViewParams params, - final ProjectVersionRef from, - final boolean includeManagedInfo, - final boolean includeConcreteInfo, - final RelationshipType... types ) - { - return getMatchingRelationships( graph.getOutEdges( from.asProjectVersionRef() ), params, includeManagedInfo, - includeConcreteInfo, types ); - } - - private Set> getMatchingRelationships( final Collection> edges, - final ViewParams params, - final boolean includeManagedInfo, - final boolean includeConcreteInfo, - final RelationshipType... types ) - { - if ( edges == null ) - { - // logger.info( "No edges found. Nothing to filter!" ); - return null; - } - - // logger.info( "Filtering %d edges...", edges.size() ); - final Set> rels = new HashSet>( edges.size() ); - - final List typeList = Arrays.asList( types ); - Collections.sort( typeList ); - - for ( final ProjectRelationship rel : edges ) - { - if ( !typeList.isEmpty() && !typeList.contains( rel.getType() ) ) - { - // logger.info( "-= %s (wrong type)", rel ); - continue; - } - - if ( params.getFilter() != null && !params.getFilter() - .accept( rel ) ) - { - // logger.info( "-= %s (rejected by filter)", rel ); - continue; - } - - if ( !includeManagedInfo && rel.isManaged() ) - { - // logger.info( "-= %s (wrong managed status)", rel ); - continue; - } - - if ( !includeConcreteInfo && !rel.isManaged() ) - { - // logger.info( "-= %s (wrong managed status)", rel ); - continue; - } - - // logger.info( "+= %s", rel ); - rels.add( rel ); - } - - return rels; - } - - @Deprecated - @Override - public Set> getDirectRelationshipsTo( final ViewParams params, final ProjectVersionRef to, - final boolean includeManagedInfo, - final RelationshipType... types ) - { - return getDirectRelationshipsTo( params, to, includeManagedInfo, true, types ); - } - - @Override - public Set> getDirectRelationshipsTo( final ViewParams params, final ProjectVersionRef to, - final boolean includeManagedInfo, - final boolean includeConcreteInfo, - final RelationshipType... types ) - { - // logger.info( "Getting relationships targeting: %s (types: %s)", to, join( types, ", " ) ); - return getMatchingRelationships( graph.getInEdges( to.asProjectVersionRef() ), params, includeManagedInfo, - includeConcreteInfo, types ); - } - - @Override - public Set getProjectsMatching( final ViewParams params, final ProjectRef projectRef ) - { - return byGA.containsKey( projectRef.asProjectRef() ) ? byGA.get( projectRef.asProjectRef() ) - : Collections. emptySet(); - } - - @Override - public void deleteRelationshipsDeclaredBy( final ProjectVersionRef ref ) - throws RelationshipGraphConnectionException - { - final Collection> edges = graph.getOutEdges( ref.asProjectVersionRef() ); - if ( edges != null ) - { - for ( final ProjectRelationship rel : edges ) - { - graph.removeEdge( rel ); - } - } - - incompleteSubgraphs.add( ref ); - } - - @Override - public void printStats() - { - logger.info( "Graph contains {} nodes.", graph.getVertexCount() ); - logger.info( "Graph contains {} relationships.", graph.getEdgeCount() ); - } - - @Override - public ProjectVersionRef getManagedTargetFor( final ProjectVersionRef target, final GraphPath path, - final RelationshipType type ) - { - if ( path == null ) - { - return null; - } - - if ( !( path instanceof JungGraphPath ) ) - { - throw new IllegalArgumentException( - "Cannot process GraphPath's from other implementations. (Non-Jung GraphPath detected: " - + path + ")" ); - } - - final ProjectRef targetGA = target.asProjectRef(); - - final JungGraphPath jungpath = (JungGraphPath) path; - for ( final ProjectRelationship ref : jungpath ) - { - final Collection> outEdges = graph.getOutEdges( ref.getDeclaring() ); - for ( final ProjectRelationship edge : outEdges ) - { - if ( edge.isManaged() && type == edge.getType() && targetGA.equals( edge.getTarget() ) ) - { - return edge.getTarget() - .asProjectVersionRef(); - } - } - } - - return null; - } - - @Override - public GraphPath createPath( final ProjectRelationship... rels ) - { - if ( rels.length > 0 ) - { - try - { - rels[rels.length - 1].getTarget() - .getVersionSpec(); - } - catch ( final InvalidVersionSpecificationException e ) - { - return null; - } - } - - return new JungGraphPath( rels ); - } - - @Override - public GraphPath createPath( final GraphPath parent, final ProjectRelationship child ) - { - try - { - child.getTarget() - .getVersionSpec(); - } - catch ( final InvalidVersionSpecificationException e ) - { - return null; - } - - if ( parent != null && !( parent instanceof JungGraphPath ) ) - { - throw new IllegalArgumentException( "Cannot get child path for: " + parent - + ". This is not a JungGraphPath instance!" ); - } - - return new JungGraphPath( (JungGraphPath) parent, child ); - } - - @Override - public boolean registerView( final ViewParams params ) - { - // TODO Tracking for the new params... - return false; - } - - @Override - public void registerViewSelection( final ViewParams params, final ProjectRef ref, - final ProjectVersionRef projectVersionRef ) - { - // NOP - } - - @Override - public Map, GraphPathInfo> getPathMapTargeting( final ViewParams params, - final Set refs ) - { - final PathDetectionTraversal traversal = new PathDetectionTraversal( this, params, refs ); - - final Set roots = params.getRoots(); - if ( roots == null ) - { - LoggerFactory.getLogger( getClass() ) - .warn( "Cannot retrieve paths targeting {}. No roots specified for this project network!", - new JoinString( ", ", refs ) ); - return null; - } - - for ( final ProjectVersionRef root : roots ) - { - dfsTraverse( params, traversal, root ); - } - - final Map allPathsMap = traversal.getPathMap(); - final Set paths = traversal.getPaths(); - - final Map, GraphPathInfo> result = new HashMap, GraphPathInfo>(); - for ( final JungGraphPath path : paths ) - { - result.put( path, allPathsMap.get( path ) ); - } - - return result; - } - - @Override - public ProjectVersionRef getPathTargetRef( final GraphPath path ) - { - if ( path != null && !( path instanceof JungGraphPath ) ) - { - throw new IllegalArgumentException( "Cannot get target GAV for: " + path - + ". This is not a JungGraphPath instance!" ); - } - - return ( (JungGraphPath) path ).getTargetGAV(); - } - - @Override - public List getPathRefs( final ViewParams params, final GraphPath path ) - { - if ( path != null && !( path instanceof JungGraphPath ) ) - { - throw new IllegalArgumentException( "Cannot get target GAV for: " + path - + ". This is not a JungGraphPath instance!" ); - } - - final JungGraphPath gp = (JungGraphPath) path; - final List refs = new ArrayList(); - for ( final ProjectRelationship rel : gp ) - { - if ( refs.isEmpty() ) - { - refs.add( rel.getDeclaring() ); - } - - refs.add( rel.getTarget() - .asProjectVersionRef() ); - } - - return refs; - } - - @Override - public List> getRelationships( final ViewParams params, final GraphPath path ) - { - if ( path != null && !( path instanceof JungGraphPath ) ) - { - throw new IllegalArgumentException( "Cannot get target GAV for: " + path - + ". This is not a JungGraphPath instance!" ); - } - - final JungGraphPath gp = (JungGraphPath) path; - return gp.getPathElements(); - } - - @Override - public String getWorkspaceId() - { - return workspaceId; - } - - @Override - public void addProjectError( final ProjectVersionRef ref, final String error ) - throws RelationshipGraphConnectionException - { - errors.put( ref, error ); - } - - @Override - public String getProjectError( final ProjectVersionRef ref ) - { - return errors.get( ref ); - } - - @Override - public boolean hasProjectError( final ProjectVersionRef ref ) - { - return errors.containsKey( ref ); - } - - @Override - public void clearProjectError( final ProjectVersionRef ref ) - throws RelationshipGraphConnectionException - { - errors.remove( ref ); - } - -} diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnectionFactory.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnectionFactory.java deleted file mode 100644 index ec463394..00000000 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/JungGraphConnectionFactory.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.jung; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; - -public class JungGraphConnectionFactory - implements RelationshipGraphConnectionFactory -{ - - private final Map connections = new HashMap(); - - @Override - public RelationshipGraphConnection openConnection( final String workspaceId, final boolean create ) - throws RelationshipGraphConnectionException - { - JungGraphConnection connection = connections.get( workspaceId ); - if ( connection == null && create ) - { - connection = new JungGraphConnection( workspaceId ); - connections.put( workspaceId, connection ); - } - - return connection; - } - - @Override - public Set listWorkspaces() - { - return connections.keySet(); - } - - @Override - public void flush( final RelationshipGraphConnection connection ) - throws RelationshipGraphConnectionException - { - } - - @Override - public boolean delete( final String workspaceId ) - throws RelationshipGraphConnectionException - { - return connections.remove( workspaceId ) != null; - } - - @Override - public void close() - throws IOException - { - } - - @Override - public boolean exists( final String workspaceId ) - { - return connections.containsKey( workspaceId ); - } - -} diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java deleted file mode 100644 index cd97e430..00000000 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/PathDetectionTraversal.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.jung; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; -import org.commonjava.maven.atlas.graph.spi.jung.model.JungGraphPath; -import org.commonjava.maven.atlas.graph.traverse.AbstractTraversal; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; - -final class PathDetectionTraversal - extends AbstractTraversal -{ - // private final Logger logger = new Logger( getClass() ); - - private final Set to; - - private final Map pathMap = new HashMap(); - - private final Set paths = new HashSet(); - - private final ViewParams params; - - private final RelationshipGraphConnection connection; - - PathDetectionTraversal( final RelationshipGraphConnection connection, final ViewParams params, - final ProjectVersionRef[] refs ) - { - this.connection = connection; - this.params = params; - this.to = new HashSet( Arrays.asList( refs ) ); - } - - public PathDetectionTraversal( final RelationshipGraphConnection connection, final ViewParams params, - final Set refs ) - { - this.connection = connection; - this.params = params; - this.to = refs; - } - - public Map getPathMap() - { - return pathMap; - } - - public Set getPaths() - { - return paths; - } - - @Override - public boolean preCheck( final ProjectRelationship relationship, final List> path ) - { - JungGraphPath jpath; - GraphPathInfo pathInfo; - if ( path.isEmpty() ) - { - jpath = new JungGraphPath( relationship.getDeclaring() ); - pathInfo = new GraphPathInfo( connection, params ); - } - else - { - jpath = new JungGraphPath( path ); - pathInfo = pathMap.get( jpath ); - } - - if ( pathInfo == null ) - { - return false; - } - - final ProjectRelationship selected = pathInfo.selectRelationship( relationship, jpath ); - if ( selected == null ) - { - return false; - } - - jpath = new JungGraphPath( jpath, selected ); - pathInfo = pathInfo.getChildPathInfo( relationship ); - - pathMap.put( jpath, pathInfo ); - - final ProjectVersionRef target = selected.getTarget() - .asProjectVersionRef(); - - // logger.info( "Checking path: %s to see if target: %s is in endpoints: %s", join( path, "," ), target, join( to, ", " ) ); - boolean found = false; - for ( final ProjectVersionRef t : to ) - { - if ( t.equals( target ) ) - { - paths.add( jpath ); - // logger.info( "+= %s", join( path, ", " ) ); - found = true; - } - } - - return !found; - } -} diff --git a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/model/JungGraphPath.java b/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/model/JungGraphPath.java deleted file mode 100644 index 61f1da6d..00000000 --- a/drivers/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/model/JungGraphPath.java +++ /dev/null @@ -1,175 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.jung.model; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.apache.commons.codec.digest.DigestUtils; -import org.apache.commons.lang.StringUtils; -import org.commonjava.maven.atlas.graph.model.GraphPath; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; - -public class JungGraphPath - implements GraphPath> -{ - - private final ProjectRelationship[] rels; - - private final ProjectVersionRef root; - - public JungGraphPath( final ProjectVersionRef root ) - { - this.root = root; - this.rels = new ProjectRelationship[] {}; - } - - public JungGraphPath( final ProjectRelationship... rels ) - { - this.root = null; - this.rels = rels; - } - - public JungGraphPath( final JungGraphPath parent, final ProjectRelationship child ) - { - this.root = null; - if ( parent == null ) - { - rels = new ProjectRelationship[] { child }; - } - else - { - final int parentLen = parent.rels.length; - this.rels = new ProjectRelationship[parentLen + 1]; - System.arraycopy( parent.rels, 0, this.rels, 0, parentLen ); - this.rels[parentLen] = child; - } - } - - public JungGraphPath( final List> path ) - { - this.root = null; - this.rels = path.toArray( new ProjectRelationship[path.size()] ); - } - - public ProjectVersionRef getTargetGAV() - { - if ( root != null ) - { - return root; - } - else if ( rels.length > 0 ) - { - return rels[rels.length - 1].getTarget() - .asProjectVersionRef(); - } - - return null; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + Arrays.hashCode( rels ); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( obj == null ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final JungGraphPath other = (JungGraphPath) obj; - return Arrays.equals( rels, other.rels ); - } - - @Override - public Iterator> iterator() - { - return new Iterator>() - { - private int next = 0; - - @Override - public boolean hasNext() - { - return rels.length > next; - } - - @Override - public ProjectRelationship next() - { - return rels[next++]; - } - - @Override - public void remove() - { - throw new UnsupportedOperationException( "Immutable array of GAV's. Remove not supported." ); - } - }; - } - - public List> getPathElements() - { - return rels.length == 0 ? Collections.> emptyList() : Arrays.asList( rels ); - } - - public boolean hasCycle() - { - if ( rels.length < 1 ) - { - return false; - } - - final Set declared = new HashSet( rels.length ); - for ( final ProjectRelationship item : rels ) - { - // NOTE: order is important here, in case it's a terminal parent relationship. - if ( declared.contains( item.getTarget() - .asProjectVersionRef() ) || !declared.add( item.getDeclaring() ) ) - { - return true; - } - } - - return false; - } - - @Override - public String getKey() - { - return DigestUtils.shaHex( StringUtils.join( rels, "," ) ); - } - -} diff --git a/drivers/neo4j-embedded/LICENSE.txt b/drivers/neo4j-embedded/LICENSE.txt deleted file mode 100644 index 8f49face..00000000 --- a/drivers/neo4j-embedded/LICENSE.txt +++ /dev/null @@ -1,700 +0,0 @@ -==== - Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -==== - -#------------------------------------------------------------------------------- -# Copyright (c) 2014 Red Hat, Inc.. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the GNU Public License v3.0 -# which accompanies this distribution, and is available at -# http://www.gnu.org/licenses/gpl.html -# -# Contributors: -# Red Hat, Inc. - initial API and implementation -#------------------------------------------------------------------------------- - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/drivers/neo4j-embedded/performance-todo.txt b/drivers/neo4j-embedded/performance-todo.txt deleted file mode 100644 index e72c837d..00000000 --- a/drivers/neo4j-embedded/performance-todo.txt +++ /dev/null @@ -1,46 +0,0 @@ -==== - Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -==== - -#------------------------------------------------------------------------------- -# Copyright (c) 2014 Red Hat, Inc.. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the GNU Public License v3.0 -# which accompanies this distribution, and is available at -# http://www.gnu.org/licenses/gpl.html -# -# Contributors: -# Red Hat, Inc. - initial API and implementation -#------------------------------------------------------------------------------- -0. Cycle detection still entering infinite loop, somehow!! - - Need to track that down. - -1. Lazy cycle detection with dirty flag on view. - - When updating the db, simply mark cycle detection as pending on all view nodes, instead of incurring cycle detection expense up front. Cycles are only queried in certain use cases, so this expense is best delayed. - -2. Store selections in view-specific index, managed by AtlasCollector instance. - - Selections driven by view-managed versions or mutations should NOT pollute other views' traverses. To avoid this, need to store selection in an index specific to the view, and hand this to the AtlasCollector on ctor. - -3. Store seen paths in view-specific index, managed by visitor. - - Storing in memory will lead to inevitable memory problems for really large traverses. We can page out older seen results by using an index, then delete the index when the traverse completes. - -4. Add traverseFinished() to visitor. - - Clean up seen index in this method, which MUST be called before collectAtlasRelationships(..) returns. - diff --git a/drivers/neo4j-embedded/pom.xml b/drivers/neo4j-embedded/pom.xml deleted file mode 100644 index edbfc0a4..00000000 --- a/drivers/neo4j-embedded/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - 4.0.0 - - - org.commonjava.maven.atlas - atlas-drivers-parent - 0.16.3-SNAPSHOT - - - atlas-driver-neo4j-embedded - - Atlas :: Maven Project-Graph :: Embedded Neo4J API - - - 1C - true - - - - - org.commonjava.maven.atlas - atlas-bindings-jackson-identities - - - org.commonjava.maven.atlas - atlas-bindings-jackson-relationships - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-core - - - org.neo4j - neo4j - - - commons-codec - commons-codec - - - org.slf4j - log4j-over-slf4j - - - commons-io - commons-io - - - - diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java deleted file mode 100644 index a87812ff..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4JGraphConnection.java +++ /dev/null @@ -1,2484 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.model.EProjectCycle; -import org.commonjava.maven.atlas.graph.model.GraphPath; -import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.rel.*; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.AbstractNeoProjectRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoProjectVersionRef; -import org.commonjava.maven.atlas.graph.spi.neo4j.traverse.*; -import org.commonjava.maven.atlas.graph.spi.neo4j.update.CycleCacheUpdater; -import org.commonjava.maven.atlas.graph.spi.neo4j.update.ViewUpdater; -import org.commonjava.maven.atlas.graph.traverse.RelationshipGraphTraversal; -import org.commonjava.maven.atlas.graph.traverse.TraversalType; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.util.JoinString; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; -import org.neo4j.cypher.javacompat.ExecutionEngine; -import org.neo4j.cypher.javacompat.ExecutionResult; -import org.neo4j.graphdb.*; -import org.neo4j.graphdb.factory.GraphDatabaseFactory; -import org.neo4j.graphdb.index.Index; -import org.neo4j.graphdb.index.IndexHits; -import org.neo4j.graphdb.index.RelationshipIndex; -import org.neo4j.graphdb.traversal.TraversalDescription; -import org.neo4j.graphdb.traversal.Traverser; -import org.neo4j.kernel.Traversal; -import org.neo4j.kernel.Uniqueness; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.util.*; - -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.*; -import static org.commonjava.maven.atlas.graph.spi.neo4j.traverse.TraversalUtils.getGraphRelTypes; - -public class FileNeo4JGraphConnection - implements Runnable, Neo4JGraphConnection -{ - - static final int DEFAULT_BATCH_SIZE = 500; - - private final Logger logger = LoggerFactory.getLogger( getClass() ); - - // private static final int ADD_BATCHSIZE = 50; - - private static final String ALL_RELATIONSHIPS = "all_relationships"; - - private static final String BY_GAV_IDX = "by_gav"; - - private static final String BY_GA_IDX = "by_ga"; - - private static final String CONFIG_NODES_IDX = "config_nodes"; - - private static final String VARIABLE_NODES_IDX = "variable_nodes"; - - private static final String MISSING_NODES_IDX = "missing_nodes"; - - private static final String METADATA_INDEX_PREFIX = "has_metadata_"; - - private static final String MANAGED_GA = "managed-ga"; - - private static final String MANAGED_KEY = "mkey"; - - private static final String BASE_CONFIG_NODE = "_base"; - - private static final String MKEY_FORMAT = "%d/%s/%s:%s"; - - // private static final String GRAPH_ATLAS_TYPES_CLAUSE = join( GraphRelType.atlasRelationshipTypes(), "|" ); - - /* @formatter:off */ -// private static final String CYPHER_SELECTION_RETRIEVAL = String.format( -// "CYPHER 1.8 START a=node({roots}) " -// + "\nMATCH p1=(a)-[:{}*1..]->(s), " -// + "\n p2=(a)-[:{}*1..]->(v) " -// + "\nWITH v, s, last(relationships(p1)) as r1, last(relationships(p2)) as r2 " -// + "\nWHERE v.{} = s.{} " -// + "\n AND v.{} = s.{} " -// + "\n AND has(r1.{}) " -// + "\n AND any(x in r1.{} " -// + "\n WHERE x IN {roots}) " -// + "\n AND has(r2.{}) " -// + "\n AND any(x in r2.{} " -// + "\n WHERE x IN {roots}) " -// + "\nRETURN r1,r2,v,s", -// GRAPH_ATLAS_TYPES_CLAUSE, GRAPH_ATLAS_TYPES_CLAUSE, -// Conversions.GROUP_ID, Conversions.GROUP_ID, -// Conversions.ARTIFACT_ID, Conversions.ARTIFACT_ID, -// Conversions.SELECTED_FOR, Conversions.SELECTED_FOR, -// Conversions.DESELECTED_FOR, Conversions.DESELECTED_FOR -// ); - - /* @formatter:on */ - - private boolean closed = false; - - private GraphDatabaseService graph; - - private final boolean useShutdownHook; - - private ExecutionEngine queryEngine; - - private Node configNode; - - private final GraphAdminImpl adminAccess; - - private final String workspaceId; - - private int storageBatchSize = DEFAULT_BATCH_SIZE; - - private final FileNeo4jConnectionFactory factory; - - private final File dbDir; - - FileNeo4JGraphConnection( final String workspaceId, final File dbDir, final boolean useShutdownHook, final int storageBatchSize, - final FileNeo4jConnectionFactory factory ) - { - this.workspaceId = workspaceId; - this.dbDir = dbDir; - this.storageBatchSize = storageBatchSize; - this.factory = factory; - this.adminAccess = new GraphAdminImpl( this ); - - this.graph = new GraphDatabaseFactory().newEmbeddedDatabase( dbDir.getAbsolutePath() ); - this.useShutdownHook = useShutdownHook; - - printStats(); - - if ( useShutdownHook ) - { - Runtime.getRuntime() - .addShutdownHook( new Thread( this ) ); - } - - final Transaction tx = graph.beginTx(); - try - { - graph.createNode(); - - long id = -1; - final IndexHits hits = graph.index() - .forNodes( CONFIG_NODES_IDX ) - .get( CONFIG_ID, BASE_CONFIG_NODE ); - if ( hits.hasNext() ) - { - configNode = hits.next(); - id = configNode.getId(); - } - - if ( id < 0 ) - { - configNode = graph.createNode(); - id = configNode.getId(); - - graph.index() - .forNodes( CONFIG_NODES_IDX ) - .add( configNode, CONFIG_ID, BASE_CONFIG_NODE ); - - } - - tx.success(); - } - finally - { - tx.finish(); - } - } - - protected GraphDatabaseService getGraph() - { - return graph; - } - - protected boolean isUseShutdownHook() - { - return useShutdownHook; - } - - @Override - public void printStats() - { - final StringBuilder stats = new StringBuilder(); - stats.append( "Graph in: " ) - .append( dbDir ); - stats.append( "\ncontains " ) - .append( graph.index() - .forNodes( BY_GAV_IDX ) - .query( GAV, "*" ) - .size() ) - .append( " nodes." ); - - stats.append( "\ncontains " ) - .append( graph.index() - .forRelationships( ALL_RELATIONSHIPS ) - .query( RELATIONSHIP_ID, "*" ) - .size() ) - .append( " relationships." ); - - logger.info( stats.toString() ); - } - - @Override - public Collection> getRelationshipsDeclaredBy( final ViewParams params, - final ProjectVersionRef ref ) - { - checkClosed(); - - if ( ref == null ) - { - return null; - } - - final Index index = graph.index() - .forNodes( BY_GAV_IDX ); - final IndexHits hits = index.get( GAV, ref.asProjectVersionRef() - .toString() ); - - if ( hits.hasNext() ) - { - final Node node = hits.next(); - final Iterable relationships = node.getRelationships( Direction.OUTGOING ); - return convertToRelationships( relationships ); - } - - return null; - } - - private synchronized void checkClosed() - { - if ( closed || graph == null ) - { - throw new IllegalStateException( "Graph database has been closed!" ); - } - } - - @Override - public Collection> getRelationshipsTargeting( final ViewParams params, - final ProjectVersionRef ref ) - { - checkClosed(); - - if ( registerView( params ) ) - { - final Node node = getNode( ref ); - - final Iterable relationships = node.getRelationships( Direction.INCOMING ); - final StringBuilder sb = new StringBuilder(); - for ( final Relationship r : relationships ) - { - if ( sb.length() > 0 ) - { - sb.append( ' ' ); - } - - sb.append( r.getId() ); - } - - final RelationshipIndex cachedRels = new ViewIndexes( graph.index(), params ).getCachedRelationships(); - final IndexHits hits = cachedRels.query( RID, sb.toString() ); - - final Set> result = new HashSet>(); - - while ( hits.hasNext() ) - { - final Relationship r = hits.next(); - final ProjectRelationship rel = toProjectRelationship( r ); - result.add( rel ); - } - - return result; - } - - final Index index = graph.index() - .forNodes( BY_GAV_IDX ); - final IndexHits hits = index.get( GAV, ref.asProjectVersionRef() - .toString() ); - - if ( hits.hasNext() ) - { - final Node node = hits.next(); - // FIXME: What if this params has a filter or mutator?? Without a root, that would be very strange... - final Iterable relationships = node.getRelationships( Direction.INCOMING ); - return convertToRelationships( relationships ); - } - - return null; - } - - @Override - public Set getAllProjects( final ViewParams params ) - { - checkClosed(); - - - logger.debug( "Getting all-projects for: {}", params ); - if ( registerView( params ) ) - { - final Index cachedNodes = new ViewIndexes( graph.index(), params ).getCachedNodes(); - - final Set nodes = new HashSet(); - final IndexHits nodeHits = cachedNodes.query( NID, "*" ); - while ( nodeHits.hasNext() ) - { - nodes.add( toProjectVersionRef( nodeHits.next() ).detach() ); - } - - return nodes; - } - - // FIXME: What if this params has a filter or mutator?? Without a root, that would be very strange... - return new HashSet( - convertToDetachedProjects( graph.index().forNodes( BY_GAV_IDX ).query( GAV, "*" ) ) ); - } - - private void updateView( final ViewParams params ) - { - if ( params.getRoots() == null || params.getRoots() - .isEmpty() ) - { - logger.debug( "paramss without roots are never updated." ); - return; - } - - final Node paramsNode = getViewNode( params ); - - logger.debug( "Checking whether {} ({} / {}) is in need of update.", params.getShortId(), paramsNode, params ); - final ViewIndexes indexes = new ViewIndexes( graph.index(), params ); - - if ( Conversions.isMembershipDetectionPending( paramsNode ) ) - { - logger.debug( "Traversing graph to update params membership: {} ({})", params.getShortId(), params ); - final Set roots = getRoots( params ); - if ( roots.isEmpty() ) - { - logger.debug( "{}: No root nodes found.", params.getShortId() ); - return; - } - - final ViewUpdater updater = new ViewUpdater( params, paramsNode, indexes, adminAccess ); - collectAtlasRelationships( params, updater, roots, false, Uniqueness.RELATIONSHIP_GLOBAL ); - - logger.debug( "Traverse complete for update of params: {}", params.getShortId() ); - } - else - { - logger.debug( "{}: no update pending.", params.getShortId() ); - } - } - - @Override - public Collection> getAllRelationships( final ViewParams params ) - { - checkClosed(); - - if ( registerView( params ) ) - { - final RelationshipIndex cachedRels = new ViewIndexes( graph.index(), params ).getCachedRelationships(); - - final IndexHits relHits = cachedRels.query( RID, "*" ); - final Set> rels = new HashSet>(); - while ( relHits.hasNext() ) - { - rels.add( toProjectRelationship( relHits.next() ).detach() ); - } - - return rels; - } - - final IndexHits hits = graph.index() - .forRelationships( ALL_RELATIONSHIPS ) - .query( RELATIONSHIP_ID, "*" ); - synchronized ( hits ) - { - return convertToDetachedRelationships( hits ); - } - } - - @Override - public Map, GraphPathInfo> getPathMapTargeting( final ViewParams params, - final Set refs ) - { - checkClosed(); - if ( !registerView( params ) ) - { - throw new IllegalArgumentException( - "You must specify at least one root GAV in order to retrieve path-related info." ); - } - - final Set endNodes = getNodes( refs ); - - final PathCollectingVisitor visitor = new PathCollectingVisitor( endNodes ); - collectAtlasRelationships( params, visitor, getRoots( params ), false, Uniqueness.RELATIONSHIP_GLOBAL ); - - final Map, GraphPathInfo> result = new HashMap, GraphPathInfo>(); - for ( final Neo4jGraphPath path : visitor ) - { - GraphPathInfo info = new GraphPathInfo( this, params ); - for ( final Long rid : path ) - { - final Relationship r = graph.getRelationshipById( rid ); - info = info.getChildPathInfo( toProjectRelationship( r ) ); - } - - result.put( path, info ); - } - - return result; - } - - @Override - public ProjectVersionRef getPathTargetRef( final GraphPath path ) - { - if ( path == null ) - { - return null; - } - - if ( !( path instanceof Neo4jGraphPath ) ) - { - throw new IllegalArgumentException( "GraphPath instances must be of type Neo4jGraphPath. Was: " - + path.getClass() - .getName() ); - } - - final long rid = ( (Neo4jGraphPath) path ).getLastRelationshipId(); - if ( rid < 0 ) - { - return null; - } - - final Relationship rel = graph.getRelationshipById( rid ); - final Node target = rel.getEndNode(); - - return toProjectVersionRef( target ); - } - - @Override - public Set>> getAllPathsTo( final ViewParams params, final ProjectVersionRef... refs ) - { - checkClosed(); - if ( !registerView( params ) ) - { - throw new IllegalArgumentException( - "You must specify at least one root GAV in order to retrieve path-related info." ); - } - - final Set endNodes = getNodes( refs ); - - final PathCollectingVisitor visitor = new PathCollectingVisitor( endNodes ); - collectAtlasRelationships( params, visitor, getRoots( params ), false, Uniqueness.RELATIONSHIP_GLOBAL ); - - final Set>> result = new HashSet>>(); - for ( final Neo4jGraphPath path : visitor ) - { - result.add( convertToDetachedRelationships( path, adminAccess ) ); - } - - return result; - } - - @Override - public synchronized Set> addRelationships( final ProjectRelationship... rels ) - { - final Map> createdRelationshipsMap = addRelationshipsInternal( rels ); - - logger.info( "Updating all-projects caches with {} new entries", createdRelationshipsMap.size() ); - updateCaches( createdRelationshipsMap ); - - // FIXME: We're delaying cycle detection, so there will NEVER be rejected relationships... - final Set> skipped = Collections.emptySet(); - logger.debug( "Cycle injection detected for: {}", skipped ); - logger.info( "Returning {} rejected relationships.", skipped.size() ); - - // printGraphStats(); - - return skipped; - } - - private Map> addRelationshipsInternal( final ProjectRelationship... rels ) - { - checkClosed(); - - final Map> createdRelationshipsMap = new HashMap>(); - - final List> sorted = new ArrayList>( Arrays.asList( rels ) ); - Collections.sort( sorted, RelationshipComparator.INSTANCE ); - - double batches = sorted.size() < storageBatchSize ? 1 : Math.ceil( (double) sorted.size() / (double) storageBatchSize ); - logger.info( "\n\n\nProcessing {} batches of relationships ({} total relationships)\n\n\n\n", batches, sorted.size() ); - - int processed = 0; - for ( int i = 0; i < batches; i++ ) - { - logger.info( "Starting batch #{} at: {}", i, processed ); - int upper = sorted.size(); // size() is one beyond upper index. - if ( upper - processed > storageBatchSize ) - { - upper = processed + storageBatchSize; - } - - List> batch = sorted.subList( processed, upper ); - logger.info( "\n\n\nInserting relationship batch of size: {}\n\n\n\n", batch.size() ); - insertRelationshipBatch( batch, createdRelationshipsMap ); - processed += batch.size(); - } - - return createdRelationshipsMap; - } - - private void insertRelationshipBatch( final List> rels, final Map> createdRelationshipsMap ) - { - final Transaction tx = graph.beginTx(); - try - { - // int txBatchCount = 0; - nextRel: for ( final ProjectRelationship rel : rels ) - { - if ( (rel instanceof AbstractNeoProjectRelationship ) && !( (AbstractNeoProjectRelationship) rel ).isDirty()) - { - logger.debug("Clean Neo4j-backed relationship: {} NOT being added.", rel ); - continue; - } - - logger.debug( "Checking relationship: {}", rel ); - - final Index index = graph.index() - .forNodes( BY_GAV_IDX ); - - final ProjectVersionRef declaring = rel.getDeclaring(); - final ProjectVersionRef target = rel.getTarget() - .asProjectVersionRef(); - - final Node[] nodes = new Node[2]; - int i = 0; - for ( final ProjectVersionRef ref : new ProjectVersionRef[] { declaring, target } ) - { - final IndexHits hits = index.get( GAV, ref.asProjectVersionRef() - .toString() ); - if ( !hits.hasNext() ) - { - logger.debug( "Creating new node for: {} to support addition of relationship: {}", ref, rel ); - try - { - final Node node = newProjectNode( ref ); - logger.debug( "Node: {} created for: {}", node, ref ); - nodes[i] = node; - } - catch ( final InvalidVersionSpecificationException e ) - { - // FIXME: This means we're discarding a rejected relationship without passing it back...NOT GOOD - // However, some code assumes rejects are cycles...also not good. - logger.error( String.format( "Failed to create node for project ref: %s. Reason: %s", ref, - e.getMessage() ), e ); - continue nextRel; - } - } - else - { - nodes[i] = hits.next(); - - logger.debug( "Using existing project node: {} for: {}", nodes[i], ref.asProjectVersionRef() ); - } - - i++; - } - - final RelationshipIndex relIdx = graph.index() - .forRelationships( ALL_RELATIONSHIPS ); - - final String relId = id( rel ); - Relationship relationship = getRelationship( relId ); - if ( relationship == null ) - { - final Node from = nodes[0]; - - logger.debug( "Removing missing/incomplete flag from: {} ({})", from, declaring ); - graph.index() - .forNodes( MISSING_NODES_IDX ) - .remove( from ); - - markConnected( from, true ); - - if ( from.getId() != nodes[1].getId() ) - { - final Node to = nodes[1]; - - logger.debug( "Creating graph relationship for: {} between node: {} and node: {}", rel, from, - to ); - - final GraphRelType grt = GraphRelType.map( rel.getType(), rel.isManaged() ); - - relationship = from.createRelationshipTo( to, grt ); - - // now, we set an index on the relationship of where it is in the range of ALL atlas relationships - // for this node. ProjectRelationship.getIndex() only gives the index for that TYPE, so we can't - // use it. The next value will be stored on the from node for the next go. - int nodeRelIdx = Conversions.getIntegerProperty( Conversions.ATLAS_RELATIONSHIP_COUNT, from, 0 ); - - relationship.setProperty( Conversions.ATLAS_RELATIONSHIP_INDEX, nodeRelIdx ); - from.setProperty( Conversions.ATLAS_RELATIONSHIP_COUNT, ++nodeRelIdx ); - - logger.debug( "New relationship is: {} with type: {}", relationship, grt ); - - toRelationshipProperties( rel, relationship ); - relIdx.add( relationship, RELATIONSHIP_ID, relId ); - - if ( rel.isManaged() ) - { - graph.index() - .forRelationships( MANAGED_GA ) - .add( relationship, - MANAGED_KEY, - String.format( MKEY_FORMAT, relationship.getStartNode() - .getId(), rel.getType() - .name(), rel.getTarget() - .getGroupId(), - rel.getTarget() - .getArtifactId() ) ); - } - - logger.debug( "+= {} ({})", relationship, rel ); - } - else - { - logger.info( "Self-referential relationship: {}. Skipping", rel ); - continue; - } - - if ( !( rel instanceof SimpleParentRelationship ) || !( (ParentRelationship) rel ).isTerminus() ) - { - createdRelationshipsMap.put( relationship.getId(), rel ); - } - } - else - { - logger.debug( "== {} ({})", relationship, new RelToString( relationship ) ); - - addToURISetProperty( rel.getSources(), SOURCE_URI, relationship ); - } - - // We don't really need transaction here, I don't think... - // but we're forced to use one to update the graph. - // So, to find a balance between memory consumed by a transaction - // and speed (creating/committing txns takes time), we'll batch them. - // txBatchCount++; - // if ( txBatchCount >= ADD_BATCHSIZE ) - // { - // logger.info( "Storing batch of {} relationships.", txBatchCount + 1 ); - // tx.success(); - // tx = graph.beginTx(); - // txBatchCount = 0; - // } - } - - // logger.info( "Storing final batch of {} relationships.", txBatchCount + 1 ); - tx.success(); - } - finally - { - tx.finish(); - } - } - - @Override - public boolean introducesCycle( final ViewParams params, final ProjectRelationship rel ) - { - checkClosed(); - - final ProjectVersionRef to = rel.getDeclaring(); - final ProjectVersionRef from = rel.getTarget() - .asProjectVersionRef(); - - final Node toNode = getNode( to ); - final Node fromNode = getNode( from ); - - if ( toNode == null || fromNode == null ) - { - return false; - } - - logger.debug( "Checking for existence of path from: {} to: {} in global database", fromNode, toNode ); - final PathExistenceVisitor collector = new PathExistenceVisitor( toNode ); - collectAtlasRelationships( params, collector, Collections.singleton( fromNode ), false, - Uniqueness.RELATIONSHIP_GLOBAL ); - - return collector.isFound(); - } - - private Node newProjectNode( final ProjectVersionRef ref ) - { - final Node node = graph.createNode(); - - toNodeProperties( ref, node, false ); - - final String gav = ref.asProjectVersionRef() - .toString(); - - graph.index() - .forNodes( BY_GAV_IDX ) - .add( node, GAV, gav ); - - graph.index() - .forNodes( BY_GA_IDX ) - .add( node, GA, ref.asProjectRef() - .toString() ); - - graph.index() - .forNodes( MISSING_NODES_IDX ) - .add( node, GAV, gav ); - - if ( ref.isVariableVersion() ) - { - // logger.info( "Adding {} to variable-nodes index.", ref ); - graph.index() - .forNodes( VARIABLE_NODES_IDX ) - .add( node, GAV, gav ); - } - - // logger.info( "Created project node: {} with id: {}", ref, node.getId() ); - return node; - } - - private Relationship select( final Relationship old, final ViewParams params, final Node paramsNode, - final GraphPathInfo pathInfo, final Neo4jGraphPath path ) - { - final ViewIndexes indexes = new ViewIndexes( graph.index(), params ); - - final long targetRid = Conversions.getDeselectionTarget( old.getId(), paramsNode ); - if ( targetRid > -1 ) - { - return graph.getRelationshipById( targetRid ); - } - - final ProjectRelationship oldRel = toProjectRelationship( old ); - if ( oldRel == null ) - { - return null; - } - - logger.debug( "Selecting mutated relationship for: {} with pathInfo: {}", oldRel, pathInfo ); - final ProjectRelationship selected = pathInfo == null ? oldRel : pathInfo.selectRelationship( oldRel, path ); - - if ( selected == null ) - { - return null; - } - - if ( selected != oldRel ) - { - // logger.info( "Checking for existing DB relationship for: {}", selected ); - final String selId = id( selected ); - Relationship result = getRelationship( selId ); - if ( result != null ) - { - return result; - } - - logger.debug( "Creating ad-hoc db relationship for selection: {} (replacing: {})", selected, oldRel ); - - @SuppressWarnings( "unused" ) - final Map> added = addRelationshipsInternal( selected ); - -// final Transaction tx = graph.beginTx(); - try - { - result = getRelationship( selId ); - if ( result != null ) - { - logger.debug( "Adding relationship {} to selections index", result ); - Conversions.setSelection( old.getId(), result.getId(), paramsNode ); - - // Does this imply that a whole subgraph from oldRel needs to be removed from the cache?? - // No, because that would only happen if a new selection were added to the params, which would trigger a registerViewSelection() call... - logger.debug( "Adding node {} to membership cache for {}", result.getEndNode() - .getId(), params.getShortId() ); - indexes.getCachedNodes() - .add( result.getEndNode(), NID, result.getEndNode() - .getId() ); - } - -// tx.success(); - - return result; - } - finally - { -// tx.finish(); - } - } - - return old; - } - - // private Set getProjectsRootedAt( final ViewParams params, final Set roots ) - // { - // Iterable nodes = null; - // if ( roots != null && !roots.isEmpty() ) - // { - // final RootedNodesCollector agg = new RootedNodesCollector( roots, params, false ); - // collectAtlasRelationships( params, agg, roots, false ); - // nodes = agg; - // } - // else - // { - // final IndexHits hits = graph.index() - // .forNodes( BY_GAV_IDX ) - // .query( GAV, "*" ); - // nodes = hits; - // } - // - // return new HashSet( convertToProjects( nodes ) ); - // } - - @Override - public void traverse( final RelationshipGraphTraversal traversal, final ProjectVersionRef root, - final RelationshipGraph graph, final TraversalType type ) - throws RelationshipGraphConnectionException - { - final Node rootNode = getNode( root ); - if ( rootNode == null ) - { - // logger.debug( "Root node not found! (root: {})", root ); - return; - } - - // logger.debug( "PASS: {}", i ); - - // NOTE: Changing this means some cases of morphing filters/mutators may NOT report correct results. - // TraversalDescription description = Traversal.traversal( Uniqueness.RELATIONSHIP_PATH ) - TraversalDescription description = Traversal.traversal( Uniqueness.RELATIONSHIP_GLOBAL ) - .sort( PathComparator.INSTANCE ); - - final ViewParams params = graph.getParams(); - final GraphRelType[] relTypes = getGraphRelTypes( params.getFilter() ); - for ( final GraphRelType grt : relTypes ) - { - description.relationships( grt, Direction.OUTGOING ); - } - - if ( type == TraversalType.breadth_first ) - { - description = description.breadthFirst(); - } - else - { - description = description.depthFirst(); - } - - // logger.debug( "starting traverse of: {}", net ); - traversal.startTraverse( graph ); - - final Node paramsNode = getViewNode( params ); - - @SuppressWarnings( { "rawtypes", "unchecked" } ) - final MembershipWrappedTraversalEvaluator checker = - new MembershipWrappedTraversalEvaluator( Collections.singleton( rootNode.getId() ), traversal, this, - params, paramsNode, adminAccess, relTypes ); - - description = description.expand( checker ) - .evaluator( checker ); - - Transaction tx = this.graph.beginTx(); - try - { - final Traverser traverser = description.traverse( rootNode ); - for ( final Path path : traverser ) - { - if ( path.lastRelationship() == null ) - { - continue; - } - - final List> rels = new ArrayList>(path.length()); - rels.addAll( convertToRelationships( path.relationships() ) ); - - logger.debug( "traversing path: {}", rels ); - for ( final ProjectRelationship rel : rels ) - { - logger.debug( "traverse: {}", rel ); - if ( traversal.traverseEdge( rel, rels ) ) - { - logger.debug( "traversed: {}", rel ); - traversal.edgeTraversed( rel, rels ); - } - } - } - - tx.success(); - } - finally - { - tx.finish(); - } - - traversal.endTraverse( graph ); - } - - @Override - public boolean containsProject( final ViewParams params, final ProjectVersionRef ref ) - { - checkClosed(); - - final IndexHits missing = graph.index() - .forNodes( MISSING_NODES_IDX ) - .get( GAV, ref.asProjectVersionRef() - .toString() ); - if ( missing.size() > 0 ) - { - return false; - } - - final Node node = getNode( ref ); - if ( node == null ) - { - return false; - } - - if ( registerView( params ) ) - { - final Index cachedNodes = new ViewIndexes( graph.index(), params ).getCachedNodes(); - - final IndexHits nodeHits = cachedNodes.get( NID, node.getId() ); - return nodeHits.hasNext(); - } - else - { - return getNode( ref ) != null; - } - } - - @Override - public boolean containsRelationship( final ViewParams params, final ProjectRelationship rel ) - { - checkClosed(); - - final Relationship relationship = getRelationship( rel ); - if ( relationship == null ) - { - return false; - } - - if ( registerView( params ) ) - { - return new ViewIndexes( graph.index(), params ).getCachedRelationships() - .get( RID, relationship.getId() ) - .hasNext(); - } - else - { - return true; - } - } - - private Set getNodes( final Set refs ) - { - final Set nodes = new HashSet( refs.size() ); - for ( final ProjectVersionRef ref : refs ) - { - final Node node = getNode( ref ); - if ( node != null ) - { - nodes.add( node ); - } - } - - return nodes; - } - - private Set getNodes( final ProjectVersionRef... refs ) - { - final Set nodes = new HashSet( refs.length ); - for ( final ProjectVersionRef ref : refs ) - { - final Node node = getNode( ref ); - if ( node != null ) - { - nodes.add( node ); - } - } - - return nodes; - } - - protected Node getNode( final ProjectVersionRef ref ) - { - checkClosed(); - - final Index idx = graph.index() - .forNodes( BY_GAV_IDX ); - - final IndexHits hits = idx.get( GAV, ref.asProjectVersionRef() - .toString() ); - - if ( hits.size() < 1 ) - { - return null; - } - - final Node node = hits.next(); - - return node; - } - - protected Relationship getRelationship( final ProjectRelationship rel ) - { - return getRelationship( id( rel ) ); - } - - Relationship getRelationship( final String relId ) - { - checkClosed(); - - final RelationshipIndex idx = graph.index() - .forRelationships( ALL_RELATIONSHIPS ); - - final IndexHits hits = idx.get( RELATIONSHIP_ID, relId ); - synchronized ( hits ) - { - return hits.hasNext() ? hits.next() : null; - } - } - - private static final int SHUTDOWN_WAIT = 5; - - @Override - public synchronized void close() - throws IOException - { - closed = true; - - factory.connectionClosing( workspaceId ); - - if ( graph != null ) - { - try - { - logger.info( "Shutting down graph..." ); - printStats(); - - graph.shutdown(); - - logger.info( "Waiting for shutdown..." ); - if ( graph.isAvailable( 1000 * SHUTDOWN_WAIT ) ) - { - throw new IOException( "Failed to shutdown graph: " + dbDir ); - } - - graph = null; - - logger.info( "...graph shutdown complete." ); - } - catch ( final Exception e ) - { - throw new IOException( "Failed to shutdown: " + e.getMessage(), e ); - } - } - - } - - @Override - public boolean isClosed() - { - return closed; - } - - @Override - public void run() - { - try - { - close(); - } - catch ( final IOException e ) - { - // new Logger( getClass() ).debug( "Failed to shutdown graph database. Reason: {}", e, e.getMessage() ); - } - } - - @SuppressWarnings( "unused" ) - private boolean isMissing( final Node node ) - { - return !isConnected( node ); - } - - @Override - public boolean isMissing( final ViewParams params, final ProjectVersionRef ref ) - { - final IndexHits hits = graph.index() - .forNodes( MISSING_NODES_IDX ) - .get( GAV, ref.asProjectVersionRef() - .toString() ); - - return hits.size() > 0; - // final IndexHits hits = graph.index() - // .forNodes( BY_GAV_IDX ) - // .get( GAV, ref.asProjectVersionRef().toString() ); - // - // if ( hits.size() > 0 ) - // { - // return !isConnected( hits.next() ); - // } - // - // return false; - } - - @Override - public boolean hasMissingProjects( final ViewParams params ) - { - return hasIndexedProjects( params, MISSING_NODES_IDX ); - } - - @Override - public Set getMissingProjects( final ViewParams params ) - { - logger.debug( "Getting missing projects for: {}", params.getShortId() ); - return getIndexedProjects( params, MISSING_NODES_IDX ); - } - - private Set getIndexedProjects( final ViewParams params, final String indexName ) - { - checkClosed(); - - final IndexHits hits = graph.index() - .forNodes( indexName ) - .query( GAV, "*" ); - - final Set result = new HashSet(); - - if ( registerView( params ) ) - { - final Index cachedNodes = new ViewIndexes( graph.index(), params ).getCachedNodes(); - - for ( final Node node : hits ) - { - logger.debug( "Checking for membership: {} ({})", node, node.getProperty( GAV ) ); - final IndexHits cacheHits = cachedNodes.get( NID, node.getId() ); - if ( cacheHits.hasNext() ) - { - logger.debug( "Including: {}", node ); - result.add( toProjectVersionRef( node ) ); - } - } - } - else - { - for ( final Node node : hits ) - { - logger.debug( "Including: {}", node ); - result.add( toProjectVersionRef( node ) ); - } - } - - return result; - } - - private boolean hasIndexedProjects( final ViewParams params, final String indexName ) - { - checkClosed(); - - final IndexHits hits = graph.index() - .forNodes( indexName ) - .query( GAV, "*" ); - - if ( registerView( params ) ) - { - final Index cachedNodes = new ViewIndexes( graph.index(), params ).getCachedNodes(); - - for ( final Node node : hits ) - { - final IndexHits cacheHits = cachedNodes.get( NID, node.getId() ); - if ( cacheHits.hasNext() ) - { - return true; - } - } - } - else - { - if ( hits.hasNext() ) - { - return true; - } - } - - return false; - } - - private Set getRoots( final ViewParams params ) - { - return getRoots( params, true ); - } - - private Set getRoots( final ViewParams params, final boolean defaultToAll ) - { - final Set rootRefs = params.getRoots(); - if ( ( rootRefs == null || rootRefs.isEmpty() ) && defaultToAll ) - { - return Collections.emptySet(); - // final Set connectedNodes = Conversions.toSet( graph.index() - // .forNodes( BY_GAV_IDX ) - // .query( GAV, "*" ) ); - // connectedNodes.removeAll( Conversions.toSet( graph.index() - // .forNodes( MISSING_NODES_IDX ) - // .query( GAV, "*" ) ) ); - // connectedNodes.removeAll( Conversions.toSet( graph.index() - // .forNodes( VARIABLE_NODES_IDX ) - // .query( GAV, "*" ) ) ); - // - // return connectedNodes; - } - - final Set nodes = new HashSet( rootRefs.size() ); - for ( final ProjectVersionRef ref : rootRefs ) - { - final Node n = getNode( ref ); - if ( n != null ) - { - nodes.add( n ); - } - } - - return nodes; - } - - private void collectAtlasRelationships( final ViewParams params, final TraverseVisitor visitor, - final Set start, final boolean sorted, final Uniqueness uniqueness ) - { - if ( start == null || start.isEmpty() ) - { - throw new UnsupportedOperationException( - "Cannot collect atlas nodes/relationships via traversal without at least one 'from' node!" ); - } - - // logger.info( "Traversing for aggregation using: {} from roots: {}", checker.getClass() - // .getName(), from ); - - TraversalDescription description = Traversal.traversal( uniqueness ); - if ( sorted ) - { - description = description.sort( PathComparator.INSTANCE ); - } - - final GraphRelType[] relTypes = getGraphRelTypes( params.getFilter() ); - for ( final GraphRelType grt : relTypes ) - { - description.relationships( grt, Direction.OUTGOING ); - } - - description = description.breadthFirst(); - - final Node paramsNode = getViewNode( params ); - - final AtlasCollector checker = - new AtlasCollector( visitor, start, this, params, paramsNode, adminAccess, relTypes ); - - description = description.expand( checker ) - .evaluator( checker ); - - Transaction tx = graph.beginTx(); - try - { - final Traverser traverser = description.traverse( start.toArray( new Node[start.size()] ) ); - for ( @SuppressWarnings( "unused" ) - final Path path : traverser ) - { - // logger.info( "Aggregating path: {}", path ); - // Don't need this, but we need to iterate the traverser. - } - tx.success(); - } - finally - { - visitor.traverseComplete( checker ); - tx.finish(); - } - } - - @Override - public boolean hasVariableProjects( final ViewParams params ) - { - return hasIndexedProjects( params, VARIABLE_NODES_IDX ); - } - - @Override - public Set getVariableProjects( final ViewParams params ) - { - logger.debug( "Getting variable projects for: {}", params.getShortId() ); - return getIndexedProjects( params, VARIABLE_NODES_IDX ); - } - - @Override - public boolean addCycle( final EProjectCycle cycle ) - { - // NOP, auto-detected. - return false; - } - - @Override - public Set getCycles( final ViewParams params ) - { - checkClosed(); - - final ViewIndexes indexes = new ViewIndexes( graph.index(), params ); - - if ( !registerView( params ) ) - { - logger.warn( "Skipping cycle detection on {}. View doesn't declare a root GAV, and this is prohibitively expensive! (params info: {})", - params.getShortId(), params ); - return null; - } - - final Transaction tx = graph.beginTx(); - Node paramsNode; - try - { - paramsNode = getViewNode( params ); - - if ( Conversions.isCycleDetectionPending( paramsNode ) ) - { - logger.debug( "Cycle-detection is pending for: {}", params.getShortId() ); - - Set nodes; - // if ( global ) - // { - // // FIXME: This seems to be VERY expensive - // nodes = Conversions.toSet( graph.index() - // .forNodes( BY_GAV_IDX ) - // .query( GAV, "*" ) ); - // } - // else - // { - nodes = Conversions.toSet( indexes.getCachedNodes() - .query( NID, "*" ) ); - // } - - logger.info( "Traversing graph to find cycles for params {}", params.getShortId() ); - final CycleCacheUpdater cycleUpdater = new CycleCacheUpdater( params, paramsNode, adminAccess ); - // NOTE: Changing this means some cases of morphing filters/mutators may NOT report correct results. - // collectAtlasRelationships( params, cycleUpdater, nodes, false, global ? Uniqueness.RELATIONSHIP_GLOBAL : Uniqueness.RELATIONSHIP_PATH ); - collectAtlasRelationships( params, cycleUpdater, nodes, false, Uniqueness.RELATIONSHIP_GLOBAL ); - - final int cycleCount = cycleUpdater.getCycleCount(); - logger.info( "Registered {} cycles in params {}'s cycle cache.", cycleCount, params.getShortId() ); - - return cycleUpdater.getCycles(); - } - - tx.success(); - } - finally - { - tx.finish(); - } - - final Set cyclePaths = Conversions.getCachedCyclePaths( paramsNode ); - logger.debug( "Retrieved the following cached cycle paths:\n {}", new JoinString( "\n ", cyclePaths ) ); - - // final IndexHits hits = graph.index() - // .forRelationships( CYCLE_INJECTION_IDX ) - // .query( RELATIONSHIP_ID, "*" ); - // - // final Map targetNodes = new HashMap(); - // for ( final Relationship hit : hits ) - // { - // targetNodes.put( hit.getStartNode(), hit ); - // } - // - // final Set paths = getPathsTo( params, targetNodes.keySet() ); - - final Set cycles = new HashSet(); - for ( final CyclePath cyclicPath : cyclePaths ) - { - final List> cycle = new ArrayList>( cyclicPath.length() + 1 ); - for ( final long id : cyclicPath.getRelationshipIds() ) - { - final Relationship r = graph.getRelationshipById( id ); - ProjectRelationship rel = toProjectRelationship( r ); - cycle.add( rel ); - } - - logger.debug( "[cache] CYCLES += {}", cycle ); - cycles.add( new EProjectCycle( cycle ) ); - } - - return cycles; - } - - @Override - public boolean isCycleParticipant( final ViewParams params, final ProjectRelationship rel ) - { - for ( final EProjectCycle cycle : getCycles( params ) ) - { - if ( cycle.contains( rel ) ) - { - return true; - } - } - - return false; - } - - @Override - public boolean isCycleParticipant( final ViewParams params, final ProjectVersionRef ref ) - { - for ( final EProjectCycle cycle : getCycles( params ) ) - { - if ( cycle.contains( ref ) ) - { - return true; - } - } - - return false; - } - - @Override - public void recomputeIncompleteSubgraphs() - { - // NOP, handled automatically. - } - - @Override - public Map getMetadata( final ProjectVersionRef ref ) - { - final Node node = getNode( ref ); - if ( node == null ) - { - return null; - } - - return getMetadataMap( node ); - } - - @Override - public Map getMetadata( final ProjectVersionRef ref, final Set keys ) - { - final Node node = getNode( ref ); - if ( node == null ) - { - return null; - } - - return getMetadataMap( node, keys ); - } - - @Override - public void addMetadata( final ProjectVersionRef ref, final String key, final String value ) - { - final Transaction tx = graph.beginTx(); - try - { - final Node node = getNode( ref ); - if ( node == null ) - { - tx.failure(); - return; - } - - Conversions.setMetadata( key, value, node ); - tx.success(); - } - finally - { - tx.finish(); - } - } - - @Override - public void setMetadata( final ProjectVersionRef ref, final Map metadata ) - { - final Transaction tx = graph.beginTx(); - try - { - final Node node = getNode( ref ); - if ( node == null ) - { - tx.failure(); - return; - } - - Conversions.setMetadata( metadata, node ); - tx.success(); - } - finally - { - tx.finish(); - } - } - - @Override - public ExecutionResult executeFrom( final String cypher, final ProjectVersionRef... roots ) - throws RelationshipGraphConnectionException - { - return executeFrom( cypher, null, roots ); - } - - @Override - public ExecutionResult executeFrom( final String cypher, final Map params, - final ProjectVersionRef... roots ) - throws RelationshipGraphConnectionException - { - if ( cypher.startsWith( "START" ) ) - { - throw new RelationshipGraphConnectionException( - "Leave off the START clause when supplying ProjectVersionRef instances as query roots:\n'{}'", - cypher ); - } - - final StringBuilder sb = new StringBuilder(); - for ( final ProjectVersionRef root : roots ) - { - final Node node = getNode( root ); - if ( node != null ) - { - if ( sb.length() > 0 ) - { - sb.append( ", " ); - } - sb.append( node.getId() ); - } - } - - if ( sb.length() < 1 ) - { - sb.append( "*" ); - } - - return execute( String.format( "START n=node(%s) %s", sb, cypher ), params ); - } - - @Override - public ExecutionResult executeFrom( final String cypher, final ProjectRelationship rootRel ) - throws RelationshipGraphConnectionException - { - return executeFrom( cypher, null, rootRel ); - } - - @Override - public ExecutionResult executeFrom( final String cypher, final Map params, - final ProjectRelationship rootRel ) - throws RelationshipGraphConnectionException - { - if ( cypher.startsWith( "START" ) ) - { - throw new RelationshipGraphConnectionException( - "Leave off the START clause when supplying ProjectRelationship instances as query roots:\n'{}'", - cypher ); - } - - String id = "*"; - if ( rootRel != null ) - { - final Relationship r = getRelationship( rootRel ); - if ( r != null ) - { - id = Long.toString( r.getId() ); - } - } - - return execute( String.format( "START r=relationship(%s) %s", id, cypher ), params ); - } - - @Override - public ExecutionResult execute( final String cypher ) - { - return execute( cypher, null ); - } - - @Override - public ExecutionResult execute( final String cypher, final Map params ) - { - checkExecutionEngine(); - - logger.debug( "Running query:\n\n{}\n\nWith params:\n\n{}\n\n", cypher, params ); - - final String query = cypher.replaceAll( "(\\s)\\s+", "$1" ); - - final ExecutionResult result = - params == null ? queryEngine.execute( query ) : queryEngine.execute( query, params ); - - // logger.info( "Execution plan:\n{}", result.executionPlanDescription() ); - - return result; - } - - private void checkExecutionEngine() - { - if ( queryEngine == null ) - { - queryEngine = new ExecutionEngine( graph ); - } - } - - @Override - public void reindex() - throws RelationshipGraphConnectionException - { - final Transaction tx = graph.beginTx(); - try - { - final IndexHits nodes = graph.index() - .forNodes( BY_GAV_IDX ) - .query( GAV, "*" ); - for ( final Node node : nodes ) - { - reindexNode( node ); - } - - tx.success(); - } - finally - { - tx.finish(); - } - } - - @Override - public void reindex( final ProjectVersionRef ref ) - { - final Node node = getNode( ref ); - if ( node == null ) - { - return; - } - - final Transaction tx = graph.beginTx(); - try - { - reindexNode( node ); - tx.success(); - } - finally - { - tx.finish(); - } - } - - private void reindexNode( final Node node ) - { - final String gav = getStringProperty( GAV, node ); - if ( gav == null ) - { - return; - } - - final Map md = getMetadataMap( node ); - if ( md == null || md.isEmpty() ) - { - return; - } - - for ( final String key : md.keySet() ) - { - graph.index() - .forNodes( METADATA_INDEX_PREFIX + key ) - .add( node, GAV, gav ); - } - } - - @Override - public Set getProjectsWithMetadata( final ViewParams params, final String key ) - { - checkClosed(); - - final IndexHits nodes = graph.index() - .forNodes( METADATA_INDEX_PREFIX + key ) - .query( GAV, "*" ); - - if ( registerView( params ) ) - { - final Index cachedNodes = new ViewIndexes( graph.index(), params ).getCachedNodes(); - - final Set result = new HashSet(); - for ( final Node node : nodes ) - { - if ( cachedNodes.get( NID, node.getId() ) - .hasNext() ) - { - result.add( toProjectVersionRef( node ) ); - } - } - - return result; - } - else - { - return new HashSet( convertToProjects( nodes ) ); - } - } - - @Override - public void addDisconnectedProject( final ProjectVersionRef ref ) - { - if ( !containsProject( null, ref ) ) - { - final Transaction tx = graph.beginTx(); - try - { - logger.debug( "Creating new node to account for disconnected project: {}", ref ); - newProjectNode( ref ); - - tx.success(); - } - finally - { - tx.finish(); - } - } - } - - @Deprecated - @Override - public Set> getDirectRelationshipsFrom( final ViewParams params, - final ProjectVersionRef from, - final boolean includeManagedInfo, - final RelationshipType... types ) - { - return getDirectRelationshipsFrom( params, from, includeManagedInfo, true, types ); - } - - @Override - public Set> getDirectRelationshipsFrom( final ViewParams params, - final ProjectVersionRef from, - final boolean includeManagedInfo, - final boolean includeConcreteInfo, - final RelationshipType... types ) - { - final Node node = getNode( from ); - if ( node == null ) - { - return null; - } - - final Set grts = new HashSet( types.length * 2 ); - for ( final RelationshipType relType : types ) - { - if ( includeConcreteInfo ) - { - grts.add( GraphRelType.map( relType, false ) ); - } - - if ( includeManagedInfo ) - { - grts.add( GraphRelType.map( relType, true ) ); - } - } - - final Iterable relationships = - node.getRelationships( Direction.OUTGOING, grts.toArray( new GraphRelType[grts.size()] ) ); - - if ( relationships != null ) - { - final Set> result = new HashSet>(); - - for ( final Relationship r : relationships ) - { - if ( TraversalUtils.acceptedInView( r, params ) ) - { - final ProjectRelationship rel = toProjectRelationship( r ); - if ( rel != null ) - { - result.add( rel ); - } - } - } - - return result; - } - - return null; - } - - @Override - public Set> getDirectRelationshipsTo( final ViewParams params, final ProjectVersionRef to, - final boolean includeManagedInfo, - final boolean includeConcreteInfo, - final RelationshipType... types ) - { - logger.debug( "Finding relationships targeting: {} (filter: {}, managed: {}, types: {})", to, - params.getFilter(), includeManagedInfo, Arrays.asList( types ) ); - final Node node = getNode( to ); - if ( node == null ) - { - return null; - } - - final Set grts = new HashSet( types.length * 2 ); - for ( final RelationshipType relType : types ) - { - if ( includeConcreteInfo ) - { - final GraphRelType graphType = GraphRelType.map( relType, false ); - if ( graphType != null ) - { - grts.add( graphType ); - } - } - - if ( includeManagedInfo ) - { - final GraphRelType graphType = GraphRelType.map( relType, true ); - if ( graphType != null ) - { - grts.add( graphType ); - } - } - } - - logger.debug( "Using graph-relationship types: {}", grts ); - - final Iterable relationships = - node.getRelationships( Direction.INCOMING, grts.toArray( new GraphRelType[grts.size()] ) ); - - if ( relationships != null ) - { - final Set> result = new HashSet>(); - for ( final Relationship r : relationships ) - { - logger.debug( "Examining relationship: {}", r ); - if ( TraversalUtils.acceptedInView( r, params ) ) - { - final ProjectRelationship rel = toProjectRelationship( r ); - if ( rel != null ) - { - result.add( rel ); - } - } - } - - return result; - } - - return null; - } - - @Override - public Set getProjectsMatching( final ViewParams params, final ProjectRef projectRef ) - { - final IndexHits hits = graph.index() - .forNodes( BY_GA_IDX ) - .query( GA, projectRef.asProjectRef() - .toString() ); - return new HashSet( convertToProjects( hits ) ); - } - - @Override - public void deleteRelationshipsDeclaredBy( final ProjectVersionRef ref ) - throws RelationshipGraphConnectionException - { - checkClosed(); - - if ( ref == null ) - { - return; - } - - final Index index = graph.index() - .forNodes( BY_GAV_IDX ); - - final String gav = ref.asProjectVersionRef() - .toString(); - - final IndexHits hits = index.get( GAV, gav ); - - if ( hits.hasNext() ) - { - final Transaction tx = graph.beginTx(); - try - { - final Node node = hits.next(); - final Iterable relationships = node.getRelationships( Direction.OUTGOING ); - if ( relationships != null ) - { - for ( final Relationship r : relationships ) - { - r.delete(); - } - } - - graph.index() - .forNodes( MISSING_NODES_IDX ) - .add( node, GAV, gav ); - - tx.success(); - } - finally - { - tx.finish(); - } - } - } - - @Override - public ProjectVersionRef getManagedTargetFor( final ProjectVersionRef target, final GraphPath path, - final RelationshipType type ) - { - if ( path == null ) - { - return null; - } - - if ( !( path instanceof Neo4jGraphPath ) ) - { - throw new IllegalArgumentException( "GraphPath instances must be of type Neo4jGraphPath. Was: " - + path.getClass() - .getName() ); - } - - final RelationshipIndex idx = graph.index() - .forRelationships( MANAGED_GA ); - - // logger.info( "Searching for managed override of: {} in: {}", target, path ); - final Neo4jGraphPath neopath = (Neo4jGraphPath) path; - - for ( final Long id : neopath ) - { - final Relationship r = graph.getRelationshipById( id ); - - final String mkey = - String.format( MKEY_FORMAT, r.getStartNode() - .getId(), type.name(), target.getGroupId(), target.getArtifactId() ); - - // logger.info( "Searching for m-key: {}", mkey ); - - final IndexHits hits = idx.get( MANAGED_KEY, mkey ); - if ( hits != null && hits.hasNext() ) - { - final Relationship hit = hits.next(); - final ProjectVersionRef ref = toProjectVersionRef( hit.getEndNode() ); - - logger.debug( "[MUTATION] {} => {} (via: {})", target, ref, new RelToString( hit ) ); - - return ref; - } - - // final Node node = graph.getNodeById( id ); - // final Iterable relationships = node.getRelationships( Direction.OUTGOING, GraphRelType.map( type, true ) ); - // if ( relationships != null ) - // { - // for ( final Relationship r : relationships ) - // { - // if ( r.hasProperty( GROUP_ID ) && r.getProperty( GROUP_ID ) - // .equals( target.getGroupId() ) && r.hasProperty( ARTIFACT_ID ) - // && r.getProperty( ARTIFACT_ID ) - // .equals( target.getArtifactId() ) ) - // { - // return toProjectVersionRef( r.getEndNode() ); - // } - // } - // } - } - - return null; - } - - @Override - public List getPathRefs( final ViewParams params, final GraphPath path ) - { - if ( path != null && !( path instanceof Neo4jGraphPath ) ) - { - throw new IllegalArgumentException( "Cannot get refs for: " + path - + ". This is not a Neo4jGraphPathKey instance!" ); - } - - final Neo4jGraphPath gp = (Neo4jGraphPath) path; - final List> rels = convertToRelationships( gp, adminAccess ); - final List refs = new ArrayList( rels.size() + 2 ); - for ( final ProjectRelationship rel : rels ) - { - if ( refs.isEmpty() ) - { - refs.add( rel.getDeclaring() ); - } - - refs.add( rel.getTarget() - .asProjectVersionRef() ); - } - - if ( refs.isEmpty() ) - { - final Node node = graph.getNodeById( gp.getStartNodeId() ); - final ProjectVersionRef ref = toProjectVersionRef( node ); - if ( ref != null ) - { - refs.add( ref ); - } - } - - return refs; - } - - @Override - public List> getRelationships( final ViewParams params, final GraphPath path ) - { - if ( path != null && !( path instanceof Neo4jGraphPath ) ) - { - throw new IllegalArgumentException( "Cannot get refs for: " + path - + ". This is not a Neo4jGraphPathKey instance!" ); - } - - final Neo4jGraphPath gp = (Neo4jGraphPath) path; - return (List) convertToRelationships( gp, adminAccess ); - } - - @Override - public GraphPath createPath( final ProjectRelationship... rels ) - { - if ( rels.length < 1 ) - { - return null; - } - - final Relationship[] rs = new Relationship[rels.length]; - for ( int i = 0; i < rels.length; i++ ) - { - final Relationship r = getRelationship( rels[i] ); - if ( r == null ) - { - return null; - } - - rs[i] = r; - } - - return new Neo4jGraphPath( rs ); - } - - @Override - public GraphPath createPath( final GraphPath parent, final ProjectRelationship rel ) - { - if ( parent != null && !( parent instanceof Neo4jGraphPath ) ) - { - throw new IllegalArgumentException( "Cannot get child path-key for: " + parent - + ". This is not a Neo4jGraphPathKey instance!" ); - } - - Relationship r = getRelationship( rel ); - if ( r == null ) - { - final Transaction tx = graph.beginTx(); - try - { - logger.debug( "Creating new node to account for missing project referenced in path: {}", r ); - - addRelationshipsInternal( rel ); - - // FIXME: Restore cycle detection somehow... - // if ( rejected != null && !rejected.isEmpty() ) - // { - // tx.failure(); - // throw new IllegalArgumentException( "Cannot create missing relationship for: " + rel + ". It creates a relationship cycle." ); - // } - - r = getRelationship( rel ); - - tx.success(); - if ( r == null ) - { - return null; - } - } - finally - { - tx.finish(); - } - } - - return new Neo4jGraphPath( (Neo4jGraphPath) parent, r ); - } - - @Override - public boolean registerView( final ViewParams params ) - { - checkClosed(); - - if ( params == null ) - { - return false; - } - - if ( params.getRoots() == null || params.getRoots() - .isEmpty() ) - { - logger.info( "Cannot track membership in params! It has no root GAVs.\nView: {} (short id: {})", - params.getLongId(), params.getShortId() ); - return false; - } - - updateView( params ); - - return true; - } - - private Node getViewNode( final ViewParams params ) - { - // if ( params.equals( globalView ) ) - // { - // return configNode; - // } - - final Index confIdx = graph.index() - .forNodes( CONFIG_NODES_IDX ); - - final IndexHits hits = confIdx.get( VIEW_ID, params.getShortId() ); - if ( hits.hasNext() ) - { - logger.debug( "View already registered: {} (short id: {})", params.getLongId(), params.getShortId() ); - return hits.next(); - } - else - { - logger.debug( "Registering new params: {} (short id: {})", params.getLongId(), params.getShortId() ); - - final Transaction tx = graph.beginTx(); - try - { - final Node paramsNode; - paramsNode = graph.createNode(); - Conversions.storeView( params, paramsNode ); - - confIdx.add( paramsNode, VIEW_ID, params.getShortId() ); - - logger.debug( "Setting cycle-detection PENDING for new paramsNode: {} of: {}", paramsNode, - params.getShortId() ); - Conversions.setCycleDetectionPending( paramsNode, true ); - Conversions.setMembershipDetectionPending( paramsNode, true ); - - final ViewIndexes indexes = new ViewIndexes( graph.index(), params ); - final Index cachedNodes = indexes.getCachedNodes(); - - for ( final ProjectVersionRef rootRef : params.getRoots() ) - { - Node rootNode = getNode( rootRef ); - if ( rootNode == null ) - { - logger.info( "Creating node for root: {}", rootRef ); - rootNode = newProjectNode( rootRef ); - } - - cachedNodes.add( rootNode, NID, rootNode.getId() ); - } - - tx.success(); - - return paramsNode; - } - finally - { - tx.finish(); - } - } - } - - @Override - public void registerViewSelection( final ViewParams params, final ProjectRef ref, - final ProjectVersionRef projectVersionRef ) - { - checkClosed(); - if ( !registerView( params ) ) - { - return; - } - - IndexHits nodeHits; - if ( ref instanceof ProjectVersionRef ) - { - nodeHits = graph.index() - .forNodes( BY_GAV_IDX ) - .get( GAV, ( (ProjectVersionRef) ref ).asProjectVersionRef() - .toString() ); - } - else - { - nodeHits = graph.index() - .forNodes( BY_GA_IDX ) - .get( GA, ref.asProjectRef() ); - } - - final Set viaNodes = new HashSet(); - for ( final Node node : nodeHits ) - { - viaNodes.add( node.getId() ); - } - - logger.debug( "Searching for sub-paths to de-select (via): {}", viaNodes ); - - final Set toUncacheNode = new HashSet(); - final Set toUncache = new HashSet(); - final Set toUnselect = new HashSet(); - - final Transaction tx = graph.beginTx(); - try - { - final SubPathsCollectingVisitor visitor = new SubPathsCollectingVisitor( viaNodes, adminAccess ); - collectAtlasRelationships( params, visitor, getRoots( params ), false, Uniqueness.RELATIONSHIP_GLOBAL ); - - for ( final Neo4jGraphPath path : visitor ) - { - boolean uncache = false; - for ( final Long id : path ) - { - final Relationship r = graph.getRelationshipById( id ); - - // first relationship in the sub-path. - if ( !uncache ) - { - logger.debug( "Uncaching subgraph: {}", r.getEndNode() ); - logger.debug( "Uncaching: {}", r ); - toUncache.add( r ); - uncache = true; - } - else - { - logger.debug( "Uncaching: {}", r ); - toUncacheNode.add( r.getStartNode() ); - toUncacheNode.add( r.getEndNode() ); - toUncache.add( r ); - } - } - } - - final ViewIndexes indexes = new ViewIndexes( graph.index(), params ); - final Index nodes = indexes.getCachedNodes(); - for ( final Node uncache : toUncacheNode ) - { - logger.debug( "Uncache: {}", uncache ); - nodes.remove( uncache ); - } - - final RelationshipIndex rels = indexes.getCachedRelationships(); - for ( final Relationship uncache : toUncache ) - { - logger.debug( "Uncache: {}", uncache ); - rels.remove( uncache ); - } - - final Node paramsNode = getViewNode( params ); - for ( final Relationship unsel : toUnselect ) - { - Conversions.removeSelectionByTarget( unsel.getId(), paramsNode ); - } - - Conversions.setMembershipDetectionPending( paramsNode, true ); - Conversions.setCycleDetectionPending( paramsNode, true ); - - tx.success(); - } - finally - { - tx.finish(); - } - } - - private void updateCaches( final Map> newRelationships ) - { - if ( newRelationships.isEmpty() ) - { - return; - } - - final Index confIdx = graph.index() - .forNodes( CONFIG_NODES_IDX ); - - final IndexHits hits = confIdx.query( VIEW_ID, "*" ); - - Transaction tx = graph.beginTx(); - try - { - logger.debug( "Setting global cycle-detection as PENDING" ); - Conversions.setCycleDetectionPending( configNode, true ); - - tx.success(); - } - finally - { - tx.finish(); - } - - for ( final Node paramsNode : hits ) - { - final ViewParams params = Conversions.retrieveView( paramsNode, adminAccess ); - logger.debug( "Updating params: {} ({})", params.getShortId(), paramsNode ); - - // if ( params == null || params.getShortId() - // .equals( globalView.getShortId() ) || params.getRoots() == null - // || params.getRoots() - // .isEmpty() ) - // { - // logger.debug( "nevermind; it's the global params." ); - // continue; - // } - - if ( getRoots( params, false ).isEmpty() ) - { - tx = graph.beginTx(); - try - { - Conversions.setCycleDetectionPending( paramsNode, true ); - // Conversions.setMembershipDetectionPending( paramsNode, true ); - tx.success(); - continue; - } - finally - { - tx.finish(); - } - } - - final ViewIndexes vi = new ViewIndexes( graph.index(), params ); - final ViewUpdater vu = new ViewUpdater( params, paramsNode, vi, adminAccess ); - vu.cacheRoots( getRoots( params, false ) ); - if ( vu.processAddedRelationships( newRelationships ) ) - { - logger.debug( "{} ({}) marked for update.", params.getShortId(), paramsNode ); - } - else - { - logger.debug( "{} ({}) NOT marked for update.", params.getShortId(), paramsNode ); - } - } - } - - private static class GraphAdminImpl - implements GraphAdmin - { - - private final FileNeo4JGraphConnection driver; - - GraphAdminImpl( final FileNeo4JGraphConnection driver ) - { - this.driver = driver; - } - - @Override - public FileNeo4JGraphConnection getDriver() - { - return driver; - } - - @Override - public Relationship getRelationship( final long rid ) - { - return driver.graph.getRelationshipById( rid ); - } - - @Override - public Relationship select( final Relationship r, final ViewParams params, final Node paramsNode, - final GraphPathInfo paramsPathInfo, final Neo4jGraphPath paramsPath ) - { - return driver.select( r, params, paramsNode, paramsPathInfo, paramsPath ); - } - - @Override - public RelationshipIndex getRelationshipIndex( final String name ) - { - return driver.graph.index() - .forRelationships( name ); - } - - @Override - public Index getNodeIndex( final String name ) - { - return driver.graph.index() - .forNodes( name ); - } - - @Override - public Transaction beginTransaction() - { - return driver.graph.beginTx(); - } - - @Override - public boolean isSelection( final Relationship r, final Node paramsNode ) - { - return Conversions.getDeselectionTarget( r.getId(), paramsNode ) > -1; - } - - } - - @Override - public String getWorkspaceId() - { - return workspaceId; - } - - @Override - public void addProjectError( final ProjectVersionRef ref, final String error ) - throws RelationshipGraphConnectionException - { - final Transaction tx = graph.beginTx(); - try - { - Node node = getNode( ref ); - if ( node == null ) - { - node = newProjectNode( ref ); - } - - Conversions.storeError( node, error ); - - tx.success(); - } - finally - { - tx.finish(); - } - } - - @Override - public String getProjectError( final ProjectVersionRef ref ) - { - final Node node = getNode( ref ); - if ( node == null ) - { - return null; - } - - return Conversions.getError( node ); - } - - @Override - public boolean hasProjectError( final ProjectVersionRef ref ) - { - final Node node = getNode( ref ); - if ( node == null ) - { - return false; - } - - return node.hasProperty( Conversions.PROJECT_ERROR ); - } - - @Override - public void clearProjectError( final ProjectVersionRef ref ) - throws RelationshipGraphConnectionException - { - final Node node = getNode( ref ); - if ( node == null || !node.hasProperty( Conversions.PROJECT_ERROR ) ) - { - return; - } - - node.removeProperty( Conversions.PROJECT_ERROR ); - } - - @Override - public Set> getDirectRelationshipsTo( final ViewParams params, final ProjectVersionRef to, - final boolean includeManagedInfo, - final RelationshipType... types ) - { - return getDirectRelationshipsFrom( params, to, includeManagedInfo, true, types ); - } - - public synchronized boolean isOpen() - { - return !closed; - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java deleted file mode 100644 index f7ede2c1..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/FileNeo4jConnectionFactory.java +++ /dev/null @@ -1,229 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.neo4j.kernel.StoreLockException; -import org.neo4j.kernel.lifecycle.LifecycleException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.nio.channels.OverlappingFileLockException; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -public class FileNeo4jConnectionFactory - implements RelationshipGraphConnectionFactory -{ - private final Map openConnections = - new HashMap(); - - private final File dbBaseDirectory; - - private final boolean useShutdownHook; - - private final Logger logger = LoggerFactory.getLogger( getClass() ); - - private int storageBatchSize = FileNeo4JGraphConnection.DEFAULT_BATCH_SIZE; - - public FileNeo4jConnectionFactory( final File dbBaseDirectory, final boolean useShutdownHook, final int storageBatchSize ) - { - this.dbBaseDirectory = dbBaseDirectory; - this.useShutdownHook = useShutdownHook; - this.storageBatchSize = storageBatchSize; - } - - public FileNeo4jConnectionFactory( final File dbBaseDirectory, final boolean useShutdownHook ) - { - this.dbBaseDirectory = dbBaseDirectory; - this.useShutdownHook = useShutdownHook; - } - - @Override - public synchronized RelationshipGraphConnection openConnection( final String workspaceId, final boolean create ) - throws RelationshipGraphConnectionException - { - final File db = new File( dbBaseDirectory, workspaceId ); - if ( !db.exists() ) - { - if ( !create ) - { - throw new RelationshipGraphConnectionException( "Workspace does not exist: %s.", workspaceId ); - } - else if ( !db.mkdirs() ) - { - throw new RelationshipGraphConnectionException( - "Failed to create workspace directory for: %s. (dir: %s)", - workspaceId, db ); - } - // - // try - // { - // Thread.sleep( 20 ); - // } - // catch ( final InterruptedException e ) - // { - // Thread.currentThread() - // .interrupt(); - // return null; - // } - } - - FileNeo4JGraphConnection conn = openConnections.get( workspaceId ); - if ( conn == null || !conn.isOpen() ) - { - conn = null; - int attempt = 0; - - while ( conn == null ) - { - attempt++; - try - { - conn = new FileNeo4JGraphConnection( workspaceId, db, useShutdownHook, storageBatchSize, this ); - } - catch ( RuntimeException ex ) - { - if ( ex.getCause() instanceof LifecycleException - && ex.getCause().getCause() instanceof StoreLockException - && ex.getCause().getCause().getCause() instanceof OverlappingFileLockException - && attempt < 3 ) - { - logger.warn( "Tried to connect to DB which is not closed (yet). {} Retrying in 5s.", ex.toString() ); - try - { - Thread.sleep(5000); - } - catch ( InterruptedException ez ) - { - logger.error( "The wait delay was interrupted.", ex ); - } - } - else - { - throw ex; - } - } - } - - openConnections.put( workspaceId, conn ); - } - - return conn; - } - - @Override - public Set listWorkspaces() - { - if( !dbBaseDirectory.exists() ) - { - return Collections.emptySet(); - } - - String[] listing = dbBaseDirectory.list(); - if ( listing == null ) - { - return Collections.emptySet(); - } - - return new HashSet( Arrays.asList( listing ) ); - } - - @Override - public void flush( final RelationshipGraphConnection connection ) - throws RelationshipGraphConnectionException - { - // TODO How do I flush the graph to disk while other views may be modifying it?? - } - - @Override - public boolean delete( final String workspaceId ) - throws RelationshipGraphConnectionException - { - final File db = new File( dbBaseDirectory, workspaceId ); - if ( !db.exists() || !db.isDirectory() ) - { - return false; - } - - try - { - final FileNeo4JGraphConnection connection = openConnections.remove( workspaceId ); - if ( connection != null ) - { - connection.close(); - } - - FileUtils.forceDelete( db ); - return !db.exists(); - } - catch ( final IOException e ) - { - throw new RelationshipGraphConnectionException( "Failed to delete: %s. Reason: %s", e, db, e.getMessage() ); - } - } - - @Override - public synchronized void close() - throws IOException - { - final Logger logger = LoggerFactory.getLogger( getClass() ); - - final Set failedClose = new HashSet(); - for ( final FileNeo4JGraphConnection conn : new HashSet( openConnections.values() ) ) - { - try - { - conn.close(); - } - catch ( final IOException e ) - { - failedClose.add( conn.getWorkspaceId() ); - logger.error( "Failed to close: " + conn.getWorkspaceId() + ".", e ); - } - } - - openConnections.clear(); - - if ( !failedClose.isEmpty() ) - { - throw new IOException( "Failed to close: " + StringUtils.join( failedClose, ", " ) ); - } - } - - @Override - public boolean exists( final String workspaceId ) - { - final File db = new File( dbBaseDirectory, workspaceId ); - return db.exists() && db.isDirectory(); - } - - public synchronized void connectionClosing( final String workspaceId ) - { - openConnections.remove( workspaceId ); - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphAdmin.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphAdmin.java deleted file mode 100644 index 6ed9be3c..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphAdmin.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j; - -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Relationship; -import org.neo4j.graphdb.Transaction; -import org.neo4j.graphdb.index.Index; -import org.neo4j.graphdb.index.RelationshipIndex; - -public interface GraphAdmin -{ - - FileNeo4JGraphConnection getDriver(); - - Relationship getRelationship( long rid ); - - Relationship select( Relationship r, ViewParams view, Node viewNode, GraphPathInfo viewPathInfo, - Neo4jGraphPath viewPath ); - - RelationshipIndex getRelationshipIndex( String name ); - - Index getNodeIndex( String name ); - - Transaction beginTransaction(); - - boolean isSelection( Relationship r, Node viewNode ); - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphRelType.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphRelType.java deleted file mode 100644 index df0f428f..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/GraphRelType.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j; - -import java.util.HashSet; -import java.util.Set; - -import org.neo4j.graphdb.RelationshipType; - -public enum GraphRelType - implements RelationshipType -{ - PARENT( org.commonjava.maven.atlas.graph.rel.RelationshipType.PARENT ), - BOM( org.commonjava.maven.atlas.graph.rel.RelationshipType.BOM ), - C_DEPENDENCY( org.commonjava.maven.atlas.graph.rel.RelationshipType.DEPENDENCY ), - C_PLUGIN( org.commonjava.maven.atlas.graph.rel.RelationshipType.PLUGIN ), - C_PLUGIN_DEP( org.commonjava.maven.atlas.graph.rel.RelationshipType.PLUGIN_DEP ), - M_DEPENDENCY( org.commonjava.maven.atlas.graph.rel.RelationshipType.DEPENDENCY, true ), - M_PLUGIN( org.commonjava.maven.atlas.graph.rel.RelationshipType.PLUGIN, true ), - M_PLUGIN_DEP( org.commonjava.maven.atlas.graph.rel.RelationshipType.PLUGIN_DEP, true ), - EXTENSION( org.commonjava.maven.atlas.graph.rel.RelationshipType.EXTENSION ), - CYCLE, - CACHED_PATH_RELATIONSHIP, - CACHED_CYCLE_RELATIONSHIP; - - private org.commonjava.maven.atlas.graph.rel.RelationshipType atlasType; - - private boolean managed = false; - - GraphRelType() - { - } - - GraphRelType( final org.commonjava.maven.atlas.graph.rel.RelationshipType atlasType ) - { - this.atlasType = atlasType; - } - - GraphRelType( final org.commonjava.maven.atlas.graph.rel.RelationshipType atlasType, final boolean managed ) - { - this.atlasType = atlasType; - this.managed = managed; - } - - public boolean isManaged() - { - return managed; - } - - public boolean isAtlasRelationship() - { - return atlasType != null; - } - - public org.commonjava.maven.atlas.graph.rel.RelationshipType atlasType() - { - return atlasType; - } - - public static GraphRelType map( final org.commonjava.maven.atlas.graph.rel.RelationshipType type, - final boolean managed ) - { - for ( final GraphRelType mapper : values() ) - { - if ( mapper.atlasType == type && managed == mapper.managed ) - { - return mapper; - } - } - - return null; - } - - public static GraphRelType[] atlasRelationshipTypes() - { - final Set types = new HashSet(); - for ( final GraphRelType type : values() ) - { - if ( type.isAtlasRelationship() ) - { - types.add( type ); - } - } - - return types.toArray( new GraphRelType[types.size()] ); - } - - public static GraphRelType[] concreteAtlasRelationshipTypes() - { - final Set types = new HashSet(); - for ( final GraphRelType type : values() ) - { - if ( type.isAtlasRelationship() && !type.managed ) - { - types.add( type ); - } - } - - return types.toArray( new GraphRelType[types.size()] ); - } - - public static GraphRelType[] managedAtlasRelationshipTypes() - { - final Set types = new HashSet(); - for ( final GraphRelType type : values() ) - { - if ( type.isAtlasRelationship() && type.managed ) - { - types.add( type ); - } - } - - return types.toArray( new GraphRelType[types.size()] ); - } -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/Neo4JGraphConnection.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/Neo4JGraphConnection.java deleted file mode 100644 index 9e269954..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/Neo4JGraphConnection.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j; - -import java.util.Map; - -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.neo4j.cypher.javacompat.ExecutionResult; - -public interface Neo4JGraphConnection - extends RelationshipGraphConnection -{ - - ExecutionResult executeFrom( String cypher, ProjectVersionRef... roots ) - throws RelationshipGraphConnectionException; - - ExecutionResult executeFrom( String cypher, ProjectRelationship rootRel ) - throws RelationshipGraphConnectionException; - - ExecutionResult execute( String cypher ) - throws RelationshipGraphConnectionException; - - ExecutionResult executeFrom( String cypher, Map params, ProjectVersionRef... roots ) - throws RelationshipGraphConnectionException; - - ExecutionResult executeFrom( String cypher, Map params, ProjectRelationship rootRel ) - throws RelationshipGraphConnectionException; - - ExecutionResult execute( String cypher, Map params ) - throws RelationshipGraphConnectionException; - - // Node getNode( ProjectVersionRef ref ) - // throws GraphDriverException; - // - // Relationship getRelationship( ProjectRelationship rel ) - // throws GraphDriverException; - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeToString.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeToString.java deleted file mode 100644 index eeba6ba8..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeToString.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j; - -import org.neo4j.graphdb.Node; - -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.toProjectVersionRef; - -/** - * Created by jdcasey on 8/20/15. - */ -public class NodeToString -{ - private final Node node; - - public NodeToString( Node node ) - { - this.node = node; - } - - public String toString() - { - return toProjectVersionRef( node ).toString(); - } -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeType.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeType.java deleted file mode 100644 index d92874c1..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/NodeType.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j; - -public enum NodeType -{ - - PROJECT, CYCLE - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java deleted file mode 100644 index b3398e1d..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/PathComparator.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j; - -import org.commonjava.maven.atlas.graph.rel.RelationshipPathComparator; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; -import org.neo4j.graphdb.Path; -import org.neo4j.graphdb.Relationship; - -import java.util.Comparator; -import java.util.Iterator; - -import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.POM_ROOT_URI; - -public final class PathComparator - implements Comparator -{ - - public static final PathComparator INSTANCE = new PathComparator(); - - private final RelationshipPathComparator pathComparator = RelationshipPathComparator.INSTANCE; - - private PathComparator() - { - } - - @Override - public int compare( final Path first, final Path second ) - { - final int commonLen = Math.min( first.length(), second.length() ); - - if ( first.length() > commonLen ) - { - return 1; - } - else if ( second.length() > commonLen ) - { - return -1; - } - - Iterator firstRels = first.relationships().iterator(); - Iterator secondRels = second.relationships().iterator(); - for ( int i = 0; i < commonLen; i++ ) - { - Relationship f = firstRels.next(); - Relationship s = secondRels.next(); - - final int result = compareTypes( f, s ); - if ( result != 0 ) - { - return result; - } - } - - firstRels = first.relationships().iterator(); - secondRels = second.relationships().iterator(); - for ( int i = 0; i < commonLen; i++ ) - { - Relationship f = firstRels.next(); - Relationship s = secondRels.next(); - - final int result = compareRels( f, s ); - if ( result != 0 ) - { - return result; - } - } - - return 0; - } - - private int compareTypes( final Relationship f, final Relationship s ) - { - GraphRelType ft = GraphRelType.valueOf( f.getType().name() ); - GraphRelType st = GraphRelType.valueOf( s.getType().name() ); - return ft.ordinal() - st.ordinal(); - } - - private int compareRels( final Relationship first, final Relationship second ) - { - if ( first.getType() == second.getType() ) - { - String firstSrc = Conversions.getStringProperty( Conversions.POM_LOCATION_URI, first ); - String secSrc = Conversions.getStringProperty( Conversions.POM_LOCATION_URI, second ); - - if ( firstSrc.equals( POM_ROOT_URI ) && !secSrc.equals( POM_ROOT_URI ) ) - { - return -1; - } - else if ( !firstSrc.equals( POM_ROOT_URI ) && secSrc.equals( POM_ROOT_URI ) ) - { - return 1; - } - - int res = ( (Long) first.getStartNode().getId() ).compareTo( second.getStartNode().getId() ); - if ( res == 0 ) - { - res = Conversions.getIntegerProperty( Conversions.INDEX, first ) - - Conversions.getIntegerProperty( Conversions.INDEX, second ); - } - - return res; - } - else - { - // really, we can't reach this because of the way the main compare method works... - return compareTypes( first, second ); - } - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelToString.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelToString.java deleted file mode 100644 index cf4253c2..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/RelToString.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j; - -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; -import org.neo4j.graphdb.Relationship; - -/** - * Created by jdcasey on 8/20/15. - */ -public class RelToString -{ - private Relationship rel; - - public RelToString( Relationship rel ) - { - this.rel = rel; - } - - public String toString() - { - return Conversions.toProjectRelationship( rel ).toString(); - } -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/ViewIndexes.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/ViewIndexes.java deleted file mode 100644 index 99152e1c..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/ViewIndexes.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j; - -import org.commonjava.maven.atlas.graph.ViewParams; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.index.Index; -import org.neo4j.graphdb.index.IndexManager; -import org.neo4j.graphdb.index.RelationshipIndex; - -public class ViewIndexes -{ - - private static final String REL_CACHE_PREFIX = "rel_cache_for_"; - - private static final String NODE_CACHE_PREFIX = "node_cache_for_"; - - // private static final String SELECTION_CACHE_PREFIX = "selection_cache_for_"; - - private final IndexManager indexMgr; - - private final ViewParams view; - - public ViewIndexes( final IndexManager indexMgr, final ViewParams view ) - { - this.indexMgr = indexMgr; - this.view = view; - } - - public RelationshipIndex getCachedRelationships() - { - return indexMgr.forRelationships( REL_CACHE_PREFIX + view.getShortId() ); - } - - // public RelationshipIndex getSelections() - // { - // return indexMgr.forRelationships( SELECTION_CACHE_PREFIX + view.getShortId() ); - // } - - public Index getCachedNodes() - { - return indexMgr.forNodes( NODE_CACHE_PREFIX + view.getShortId() ); - } - - public void delete() - { - getCachedRelationships().delete(); - // getSelections().delete(); - getCachedNodes().delete(); - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java deleted file mode 100644 index 964c9b5d..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Conversions.java +++ /dev/null @@ -1,1199 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.io; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import org.apache.commons.codec.digest.DigestUtils; -import org.apache.commons.io.IOUtils; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.jackson.ProjectRelationshipSerializerModule; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.GraphAdmin; -import org.commonjava.maven.atlas.graph.spi.neo4j.GraphRelType; -import org.commonjava.maven.atlas.graph.spi.neo4j.NodeType; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.AbstractNeoProjectRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoArtifactRef; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoBomRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoDependencyRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoExtensionRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoParentRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoPluginDependencyRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoPluginRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoProjectVersionRef; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoTypeAndClassifier; -import org.commonjava.maven.atlas.ident.jackson.ProjectVersionRefSerializerModule; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.PropertyContainer; -import org.neo4j.graphdb.Relationship; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static org.apache.commons.lang.StringUtils.join; - -public final class Conversions -{ - - public static final String RELATIONSHIP_ID = "relationship_id"; - - public static final String GROUP_ID = "groupId"; - - public static final String ARTIFACT_ID = "artifactId"; - - public static final String VERSION = "version"; - - public static final String GAV = "gav"; - - public static final String GA = "ga"; - - public static final String INDEX = "index"; - - public static final String IS_REPORTING_PLUGIN = "reporting"; - - public static final String IS_MANAGED = "managed"; - - public static final String IS_INHERITED = "inherited"; - - public static final String IS_MIXIN = "mixin"; - - public static final String PLUGIN_GROUP_ID = "plugin_groupId"; - - public static final String PLUGIN_ARTIFACT_ID = "plugin_artifactId"; - - public static final String TYPE = "type"; - - public static final String CLASSIFIER = "classifier"; - - public static final String SCOPE = "scope"; - - public static final String OPTIONAL = "optional"; - - public static final String EXCLUDES = "excludes"; - - public static final String CYCLE_ID = "cycle_id"; - - public static final String CYCLE_RELATIONSHIPS = "relationship_participants"; - - public static final String CYCLE_PROJECTS = "project_participants"; - - public static final String PROJECT_ERROR = "_error"; - - private static final String METADATA_PREFIX = "_metadata_"; - - public static final String NODE_TYPE = "_node_type"; - - public static final String CYCLE_MEMBERSHIP = "cycle_membership"; - - public static final String VARIABLE = "_variable"; - - public static final String CONNECTED = "_connected"; - - public static final String CYCLE_INJECTION = "_cycle_injection"; - - public static final String CYCLES_INJECTED = "_cycles"; - - public static final String SOURCE_URI = "source_uri"; - - public static final String POM_LOCATION_URI = "pom_location_uri"; - - public static final String LAST_ACCESS_DATE = "last_access"; - - // graph-level configuration. - - public static final String LAST_ACCESS = "last_access"; - - public static final String ACTIVE_POM_LOCATIONS = "active-pom-locations"; - - public static final String ACTIVE_SOURCES = "active-pom-sources"; - - public static final String CONFIG_PROPERTY_PREFIX = "_p_"; - - public static final String VIEW_SHORT_ID = "view_sid"; - - private static final String VIEW_DATA = "view_data"; - - // cached path tracking...ONLY handled by Conversions, since the info is inlined. - - private static final String CYCLE_PATH_PREFIX = "cached_cycle_"; - - // handled by other things, like updaters. - - public static final String RID = "rel_id"; - - public static final String NID = "node_id"; - - public static final String CONFIG_ID = "config_id"; - - public static final String VIEW_ID = "view_id"; - - public static final String CYCLE_DETECTION_PENDING = "cycle_detect_pending"; - - private static final String MEMBERSHIP_DETECTION_PENDING = "member_detect_pending"; - - private Conversions() - { - } - - public static int countArrayElements( final String property, final PropertyContainer container ) - { - if ( !container.hasProperty( property ) ) - { - return -1; - } - - final Object value = container.getProperty( property ); - if ( value.getClass().isArray() ) - { - final Object[] elements = (Object[]) value; - return elements.length; - } - - return 1; - } - - public static List convertToDetachedProjects( final Iterable nodes ) - { - final List refs = new ArrayList(); - for ( final Node node : nodes ) - { - if ( node.getId() == 0 ) - { - continue; - } - - if ( !Conversions.isType( node, NodeType.PROJECT ) ) - { - continue; - } - - refs.add( Conversions.toProjectVersionRef( node ).detach() ); - } - - return refs; - } - - public static List convertToProjects( final Iterable nodes ) - { - final List refs = new ArrayList(); - for ( final Node node : nodes ) - { - if ( node.getId() == 0 ) - { - continue; - } - - if ( !Conversions.isType( node, NodeType.PROJECT ) ) - { - continue; - } - - refs.add( Conversions.toProjectVersionRef( node ) ); - } - - return refs; - } - - /** - * Converts an iterable of relationships to project relationships detached from database. - * - * @param relationships iterable of {@link AbstractNeoProjectRelationship} or {@link Relationship} - * @return list of detached relationships - * @throws IllegalArgumentException if an iterable of unsupported classes is passed - */ - public static List> convertToDetachedRelationships( final Iterable relationships ) - { - final List> rels = new ArrayList>(); - Iterator iterator = relationships.iterator(); - while ( iterator.hasNext() ) - { - final AbstractNeoProjectRelationship rel; - Object next = iterator.next(); - if ( next instanceof AbstractNeoProjectRelationship ) - { - rel = ( AbstractNeoProjectRelationship) next; - } - else if ( next instanceof Relationship ) - { - rel = Conversions.toProjectRelationship( ( Relationship ) next ); - } - else - { - throw new IllegalArgumentException( "Relationship class " + next.getClass().getCanonicalName() - + " cannot be converted to detached relationship." ); - } - if ( rel != null ) - { - rels.add( rel.detach() ); - } - } - - return rels; - } - - public static List> convertToRelationships( final Iterable relationships ) - { - final List> rels = new ArrayList>(); - for ( final Relationship relationship : relationships ) - { - final AbstractNeoProjectRelationship rel = Conversions.toProjectRelationship( relationship ); - if ( rel != null ) - { - rels.add( rel ); - } - } - - return rels; - } - - public static List> convertToDetachedRelationships( final Iterable relationships, - final GraphAdmin admin ) - { - final List> rels = new ArrayList>(); - for ( final Long rid : relationships ) - { - final Relationship relationship = admin.getRelationship( rid ); - final ProjectRelationship rel = toProjectRelationship( relationship ).detach(); - if ( rel != null ) - { - rels.add( rel ); - } - } - - return rels; - } - - public static List> convertToRelationships( final Iterable relationships, - final GraphAdmin admin ) - { - final List> rels = new ArrayList>(); - for ( final Long rid : relationships ) - { - final Relationship relationship = admin.getRelationship( rid ); - final AbstractNeoProjectRelationship rel = toProjectRelationship( relationship ); - if ( rel != null ) - { - rels.add( rel ); - } - } - - return rels; - } - - public static void toNodeProperties( final ProjectVersionRef ref, final Node node, final boolean connected ) - { - Logger logger = LoggerFactory.getLogger( Conversions.class ); - - logger.debug( "Adding {} (type: {}) to node: {}", ref, ref.getClass().getSimpleName(), node ); - if ( !( ref instanceof NeoProjectVersionRef ) || ( (NeoProjectVersionRef) ref ).isDirty() ) - { - final String g = ref.getGroupId(); - final String a = ref.getArtifactId(); - final String v = ref.getVersionString(); - - if ( empty( g ) || empty( a ) || empty( v ) ) - { - throw new IllegalArgumentException( String.format( "GAV cannot contain nulls: %s:%s:%s", g, a, v ) ); - } - - node.setProperty( ARTIFACT_ID, a ); - node.setProperty( GROUP_ID, g ); - - logger.debug( "Setting property: {} with value: {} for node: {}", VERSION, v, node.getId() ); - node.setProperty( VERSION, v ); - - node.setProperty( GAV, ref.toString() ); - } - - node.setProperty( NODE_TYPE, NodeType.PROJECT.name() ); - - if ( ref.isVariableVersion() ) - { - node.setProperty( VARIABLE, true ); - } - - markConnected( node, connected ); - // - // logger.debug( "groupId of {} is:\nNeoIdentityUtils: {}\nConversions: {}\nDirect access: {}", node, - // NeoIdentityUtils.getStringProperty( node, GROUP_ID, null, null ), - // getStringProperty( GROUP_ID, node ), node.hasProperty( GROUP_ID ) ? node.getProperty( GROUP_ID ) : null ); - } - - public static boolean isAtlasType( final Relationship rel ) - { - return GraphRelType.valueOf( rel.getType().name() ).isAtlasRelationship(); - } - - public static boolean isType( final Node node, final NodeType type ) - { - final String nt = getStringProperty( NODE_TYPE, node ); - return nt != null && type == NodeType.valueOf( nt ); - } - - // public static ProjectVersionRef toProjectVersionRef( final Node node ) - // { - // return toProjectVersionRef( node, null ); - // } - - public static NeoProjectVersionRef toProjectVersionRef( final Node node ) - { - if ( node == null ) - { - return null; - } - - if ( !isType( node, NodeType.PROJECT ) ) - { - throw new IllegalArgumentException( "Node " + node.getId() + " is not a project reference." ); - } - - final NeoProjectVersionRef result = new NeoProjectVersionRef( node ); - return result; - } - - private static boolean empty( final String val ) - { - return val == null || val.trim().length() < 1; - } - - @SuppressWarnings( "incomplete-switch" ) - public static void toRelationshipProperties( final ProjectRelationship rel, final Relationship relationship ) - { - relationship.setProperty( INDEX, rel.getIndex() ); - String[] srcs = toStringArray( rel.getSources() ); - Logger logger = LoggerFactory.getLogger( Conversions.class ); - logger.debug( "Storing rel: {}\nwith sources: {}\n in property: {}\nRelationship: {}", rel, - Arrays.toString( srcs ), SOURCE_URI, relationship ); - relationship.setProperty( SOURCE_URI, srcs ); - relationship.setProperty( POM_LOCATION_URI, rel.getPomLocation().toString() ); - relationship.setProperty( IS_INHERITED, rel.isInherited() ); - - switch ( rel.getType() ) - { - case BOM: - relationship.setProperty( IS_MIXIN, rel.isMixin() ); - break; - case DEPENDENCY: - { - final DependencyRelationship specificRel = (DependencyRelationship) rel; - toRelationshipProperties( (ArtifactRef) rel.getTarget(), relationship ); - relationship.setProperty( IS_MANAGED, specificRel.isManaged() ); - relationship.setProperty( SCOPE, specificRel.getScope().realName() ); - relationship.setProperty( OPTIONAL, specificRel.isOptional() ); - - final Set excludes = specificRel.getExcludes(); - if ( excludes != null && !excludes.isEmpty() ) - { - final StringBuilder sb = new StringBuilder(); - for ( final ProjectRef exclude : excludes ) - { - if ( sb.length() > 0 ) - { - sb.append( "," ); - } - - sb.append( exclude.getGroupId() ).append( ":" ).append( exclude.getArtifactId() ); - } - - relationship.setProperty( EXCLUDES, sb.toString() ); - } - - break; - } - case PLUGIN_DEP: - { - toRelationshipProperties( (ArtifactRef) rel.getTarget(), relationship ); - - final PluginDependencyRelationship specificRel = (PluginDependencyRelationship) rel; - - final ProjectRef plugin = specificRel.getPlugin(); - relationship.setProperty( PLUGIN_ARTIFACT_ID, plugin.getArtifactId() ); - relationship.setProperty( PLUGIN_GROUP_ID, plugin.getGroupId() ); - relationship.setProperty( IS_MANAGED, specificRel.isManaged() ); - - break; - } - case PLUGIN: - { - final PluginRelationship specificRel = (PluginRelationship) rel; - relationship.setProperty( IS_MANAGED, specificRel.isManaged() ); - relationship.setProperty( IS_REPORTING_PLUGIN, specificRel.isReporting() ); - - break; - } - } - } - - public static String[] toStringArray( final Collection sources ) - { - final Set result = new LinkedHashSet( sources.size() ); - for ( final Object object : sources ) - { - if ( object == null ) - { - continue; - } - - result.add( object.toString() ); - } - - return result.toArray( new String[result.size()] ); - } - - // public static ProjectRelationship toProjectRelationship( final Relationship rel ) - // { - // return toProjectRelationship( rel, null ); - // } - - public static AbstractNeoProjectRelationship toProjectRelationship( final Relationship rel ) - { - if ( rel == null ) - { - return null; - } - - final GraphRelType mapper = GraphRelType.valueOf( rel.getType().name() ); - - // LOGGER.debug( "Converting relationship of type: {} (atlas type: {})", mapper, - // mapper.atlasType() ); - - if ( !mapper.isAtlasRelationship() ) - { - return null; - } - - if ( rel.getStartNode() == null || rel.getEndNode() == null || !isType( rel.getStartNode(), NodeType.PROJECT ) - || !isType( rel.getEndNode(), NodeType.PROJECT ) ) - { - return null; - } - - AbstractNeoProjectRelationship result = null; - switch ( mapper.atlasType() ) - { - case DEPENDENCY: - { - result = new NeoDependencyRelationship( rel ); - break; - } - case PLUGIN_DEP: - { - result = new NeoPluginDependencyRelationship( rel ); - break; - } - case PLUGIN: - { - result = new NeoPluginRelationship( rel ); - break; - } - case EXTENSION: - { - result = new NeoExtensionRelationship( rel ); - break; - } - case BOM: - { - result = new NeoBomRelationship( rel ); - break; - } - case PARENT: - { - result = new NeoParentRelationship( rel ); - break; - } - default: - { - throw new IllegalArgumentException( - "I don't know how to construct the atlas relationship for type: " + mapper.atlasType() ); - } - } - - // LOGGER.debug( "Returning project relationship: {}", result ); - return result; - } - - public static String id( final ProjectRelationship rel ) - { - try - { - String json = newMapper().writeValueAsString( rel ); - - // FIXME: Rookie mistake! You can't add debug info to toString() with this here. - return DigestUtils.shaHex( json ); - } - catch ( JsonProcessingException e ) - { - throw new IllegalArgumentException( "Cannot serialize relationship for ID generation: " + e.getMessage(), - e ); - } - } - - private static ObjectMapper newMapper() - { - ObjectMapper mapper = new ObjectMapper(); - mapper.registerModules( ProjectVersionRefSerializerModule.INSTANCE, - ProjectRelationshipSerializerModule.INSTANCE, - NeoSpecificProjectRelationshipSerializerModule.INSTANCE, - NeoSpecificProjectVersionRefSerializerModule.INSTANCE ); - - mapper.disable( SerializationFeature.WRITE_NULL_MAP_VALUES, SerializationFeature.WRITE_EMPTY_JSON_ARRAYS ); - mapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES ); - - return mapper; - } - - private static ArtifactRef toArtifactRef( final ProjectVersionRef ref, final Relationship rel ) - { - if ( ref == null ) - { - return null; - } - - return new NeoArtifactRef( ref, new NeoTypeAndClassifier( rel ) ); - } - - private static void toRelationshipProperties( final ArtifactRef target, final Relationship relationship ) - { - Logger logger = LoggerFactory.getLogger( Conversions.class ); - logger.debug( "Type of artifact: {} (type: {}) is: {}", target, target.getClass().getSimpleName(), - target.getType() ); - relationship.setProperty( TYPE, target.getType() ); - - if ( target.getClassifier() != null ) - { - relationship.setProperty( CLASSIFIER, target.getClassifier() ); - } - } - - public static String getStringProperty( final String prop, final PropertyContainer container ) - { - if ( container.hasProperty( prop ) ) - { - return (String) container.getProperty( prop ); - } - return null; - } - - public static Set getURISetProperty( final String prop, final PropertyContainer container, - final URI defaultValue ) - { - final Set result = new HashSet(); - - if ( container.hasProperty( prop ) ) - { - final String[] uris = (String[]) container.getProperty( prop ); - for ( final String uri : uris ) - { - try - { - final URI u = new URI( uri ); - if ( !result.contains( u ) ) - { - result.add( u ); - } - } - catch ( final URISyntaxException e ) - { - Logger logger = LoggerFactory.getLogger( Conversions.class ); - logger.warn( - String.format( "Failed to construct URI from: %s\nContainer: %s\nReason: %s", container, - uri, e.getMessage() ), e ); - } - } - } - - if ( defaultValue != null && result.isEmpty() ) - { - result.add( defaultValue ); - } - - return result; - } - - public static void addToURISetProperty( final Collection uris, final String prop, - final PropertyContainer container ) - { - if ( uris == null || uris.isEmpty() ) - { - return; - } - - final Set existing = getURISetProperty( prop, container, null ); - for ( final URI uri : uris ) - { - existing.add( uri ); - } - - container.setProperty( prop, toStringArray( existing ) ); - } - - public static void removeFromURISetProperty( final Collection uris, final String prop, - final PropertyContainer container ) - { - if ( uris == null || uris.isEmpty() || !container.hasProperty( prop ) ) - { - return; - } - - final Set existing = getURISetProperty( prop, container, null ); - for ( final URI uri : uris ) - { - existing.remove( uri ); - } - - if ( existing.isEmpty() ) - { - container.removeProperty( prop ); - } - else - { - container.setProperty( prop, toStringArray( existing ) ); - } - } - - public static URI getURIProperty( final String prop, final PropertyContainer container, final URI defaultValue ) - { - URI result = defaultValue; - - if ( container.hasProperty( prop ) ) - { - try - { - result = new URI( (String) container.getProperty( prop ) ); - } - catch ( final URISyntaxException e ) - { - } - } - - return result; - } - - public static Boolean getBooleanProperty( final String prop, final PropertyContainer container ) - { - if ( container.hasProperty( prop ) ) - { - return (Boolean) container.getProperty( prop ); - } - return null; - } - - public static Boolean getBooleanProperty( final String prop, final PropertyContainer container, - final Boolean defaultValue ) - { - if ( container.hasProperty( prop ) ) - { - return (Boolean) container.getProperty( prop ); - } - - return defaultValue; - } - - public static Integer getIntegerProperty( final String prop, final PropertyContainer container ) - { - if ( container.hasProperty( prop ) ) - { - return (Integer) container.getProperty( prop ); - } - return null; - } - - public static Integer getIntegerProperty( final String prop, final PropertyContainer container, - final int defaultValue ) - { - if ( container.hasProperty( prop ) ) - { - return (Integer) container.getProperty( prop ); - } - - return defaultValue; - } - - public static Long getLongProperty( final String prop, final PropertyContainer container, final long defaultValue ) - { - if ( container.hasProperty( prop ) ) - { - return (Long) container.getProperty( prop ); - } - - return defaultValue; - } - - public static String setConfigProperty( final String key, final String value, final PropertyContainer container ) - { - final String pkey = CONFIG_PROPERTY_PREFIX + key; - final String old = container.hasProperty( pkey ) ? (String) container.getProperty( pkey ) : null; - - container.setProperty( pkey, value ); - - return old; - } - - public static String removeConfigProperty( final String key, final PropertyContainer container ) - { - final String pkey = CONFIG_PROPERTY_PREFIX + key; - String old = null; - if ( container.hasProperty( pkey ) ) - { - old = (String) container.getProperty( pkey ); - - container.removeProperty( pkey ); - } - - return old; - } - - public static String getConfigProperty( final String key, final PropertyContainer container, - final String defaultValue ) - { - final String result = getStringProperty( CONFIG_PROPERTY_PREFIX + key, container ); - - return result == null ? defaultValue : result; - } - - public static void setMetadata( final String key, final String value, final PropertyContainer container ) - { - container.setProperty( METADATA_PREFIX + key, value ); - } - - public static void setMetadata( final Map metadata, final PropertyContainer container ) - { - final Map metadataMap = getMetadataMap( container ); - - if ( metadataMap != null ) - { - for ( final String key : metadataMap.keySet() ) - { - container.removeProperty( key ); - } - } - - for ( final Map.Entry entry : metadata.entrySet() ) - { - container.setProperty( METADATA_PREFIX + entry.getKey(), entry.getValue() ); - } - } - - public static Map getMetadataMap( final PropertyContainer container ) - { - return getMetadataMap( container, null ); - } - - public static Map getMetadataMap( final PropertyContainer container, final Set matching ) - { - final Iterable keys = container.getPropertyKeys(); - final Map md = new HashMap(); - for ( final String key : keys ) - { - if ( !key.startsWith( METADATA_PREFIX ) ) - { - continue; - } - - final String k = key.substring( METADATA_PREFIX.length() ); - if ( matching != null && !matching.contains( k ) ) - { - continue; - } - - final String value = getStringProperty( key, container ); - - md.put( k, value ); - } - - return md.isEmpty() ? null : md; - } - - public static String getMetadata( final String key, final PropertyContainer container ) - { - return getStringProperty( METADATA_PREFIX + key, container ); - } - - public static void toNodeProperties( final String cycleId, final String rawCycleId, - final Set refs, final Node node ) - { - node.setProperty( NODE_TYPE, NodeType.CYCLE.name() ); - node.setProperty( CYCLE_ID, cycleId ); - node.setProperty( CYCLE_RELATIONSHIPS, rawCycleId ); - node.setProperty( CYCLE_PROJECTS, join( refs, "," ) ); - } - - public static boolean isConnected( final Node node ) - { - return getBooleanProperty( CONNECTED, node ); - } - - public static void markConnected( final Node node, final boolean connected ) - { - // LOGGER.info( "Marking as connected (non-missing): {}", node.getProperty( GAV ) ); - node.setProperty( CONNECTED, connected ); - } - - public static void markCycleInjection( final Relationship relationship, final Set> cycles ) - { - relationship.setProperty( CYCLE_INJECTION, true ); - final List collapsed = new ArrayList(); - final Set> existing = getInjectedCycles( relationship ); - if ( existing != null && !existing.isEmpty() ) - { - for ( final List cycle : existing ) - { - if ( !collapsed.isEmpty() ) - { - collapsed.add( -1L ); - } - - collapsed.addAll( cycle ); - } - } - - for ( final List cycle : cycles ) - { - if ( existing.contains( cycle ) ) - { - continue; - } - - if ( !collapsed.isEmpty() ) - { - collapsed.add( -1L ); - } - - boolean containsGivenRelationship = false; - for ( final Relationship r : cycle ) - { - final long rid = r.getId(); - - collapsed.add( rid ); - if ( rid == relationship.getId() ) - { - containsGivenRelationship = true; - } - } - - if ( !containsGivenRelationship ) - { - collapsed.add( relationship.getId() ); - } - } - - final long[] arry = new long[collapsed.size()]; - int i = 0; - for ( final Long l : collapsed ) - { - arry[i] = l; - i++; - } - - relationship.setProperty( CYCLES_INJECTED, arry ); - } - - public static Set> getInjectedCycles( final Relationship relationship ) - { - final Set> cycles = new HashSet>(); - - if ( relationship.hasProperty( CYCLES_INJECTED ) ) - { - final long[] collapsed = (long[]) relationship.getProperty( CYCLES_INJECTED ); - - List currentCycle = new ArrayList(); - for ( final long id : collapsed ) - { - if ( id == -1 ) - { - if ( !currentCycle.isEmpty() ) - { - cycles.add( currentCycle ); - currentCycle = new ArrayList(); - } - } - else - { - currentCycle.add( id ); - } - } - - if ( !currentCycle.isEmpty() ) - { - cycles.add( currentCycle ); - } - } - - return cycles; - } - - public static void removeProperty( final String key, final PropertyContainer container ) - { - if ( container.hasProperty( key ) ) - { - container.removeProperty( key ); - } - } - - public static Set

toProjectedSet( final Iterable src, final Projector projector ) - { - final Set

set = new HashSet

(); - for ( final T t : src ) - { - set.add( projector.project( t ) ); - } - - return set; - } - - public static Set toSet( final Iterable src ) - { - final Set set = new HashSet(); - for ( final T t : src ) - { - set.add( t ); - } - - return set; - } - - public static List toList( final Iterable src ) - { - final List set = new ArrayList(); - for ( final T t : src ) - { - set.add( t ); - } - - return set; - } - - public static void cloneRelationshipProperties( final Relationship from, final Relationship to ) - { - final Iterable keys = from.getPropertyKeys(); - for ( final String key : keys ) - { - to.setProperty( key, from.getProperty( key ) ); - } - } - - public static void storeCachedCyclePath( final CyclePath path, final Node viewNode ) - { - viewNode.setProperty( CYCLE_PATH_PREFIX + path.getKey(), path.getRelationshipIds() ); - } - - public static Set getCachedCyclePaths( final Node viewNode ) - { - final Set cycles = new HashSet(); - for ( final String key : viewNode.getPropertyKeys() ) - { - if ( key.startsWith( CYCLE_PATH_PREFIX ) ) - { - final long[] ids = (long[]) viewNode.getProperty( key ); - cycles.add( new CyclePath( ids ) ); - } - } - - return cycles; - } - - public static void storeView( final ViewParams params, final Node viewNode ) - { - viewNode.setProperty( Conversions.VIEW_SHORT_ID, params.getShortId() ); - - ObjectOutputStream oos = null; - try - { - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - oos = new ObjectOutputStream( baos ); - oos.writeObject( params ); - - viewNode.setProperty( VIEW_DATA, baos.toByteArray() ); - } - catch ( final IOException e ) - { - throw new IllegalStateException( "Cannot construct ObjectOutputStream to wrap ByteArrayOutputStream!", e ); - } - finally - { - IOUtils.closeQuietly( oos ); - } - } - - // public static GraphView retrieveView( final Node viewNode, final AbstractNeo4JEGraphDriver driver ) - // { - // return retrieveView( viewNode, null, driver ); - // } - - public static ViewParams retrieveView( final Node viewNode, final GraphAdmin maint ) - { - if ( !viewNode.hasProperty( VIEW_DATA ) ) - { - return null; - } - - final byte[] data = (byte[]) viewNode.getProperty( VIEW_DATA ); - - ObjectInputStream ois = null; - try - { - ois = new ObjectInputStream( new ByteArrayInputStream( data ) ); - final ViewParams view = (ViewParams) ois.readObject(); - - return view; - } - catch ( final IOException e ) - { - throw new IllegalStateException( - "Cannot construct ObjectInputStream to wrap ByteArrayInputStream containing " + data.length - + " bytes!", e ); - } - catch ( final ClassNotFoundException e ) - { - throw new IllegalStateException( "Cannot read ViewParams. A class was missing: " + e.getMessage(), e ); - } - finally - { - IOUtils.closeQuietly( ois ); - } - } - - public static boolean isCycleDetectionPending( final Node viewNode ) - { - return getBooleanProperty( CYCLE_DETECTION_PENDING, viewNode, Boolean.FALSE ); - } - - public static void setCycleDetectionPending( final Node viewNode, final boolean pending ) - { - viewNode.setProperty( CYCLE_DETECTION_PENDING, pending ); - } - - public static boolean isMembershipDetectionPending( final Node viewNode ) - { - return getBooleanProperty( MEMBERSHIP_DETECTION_PENDING, viewNode, Boolean.FALSE ); - } - - public static void setMembershipDetectionPending( final Node viewNode, final boolean pending ) - { - viewNode.setProperty( MEMBERSHIP_DETECTION_PENDING, pending ); - } - - private static final String SELECTION_ORIGIN_PREFIX = "_selection_origin_"; - - private static final String DESELECTION_TARGET_PREFIX = "_deselection_target_"; - - public static final String ATLAS_RELATIONSHIP_COUNT = "_atlas_relationship_count"; - - public static final String ATLAS_RELATIONSHIP_INDEX = "_atlas_relationship_index"; - - public static long getDeselectionTarget( final long originRid, final Node viewNode ) - { - return getLongProperty( DESELECTION_TARGET_PREFIX + originRid, viewNode, -1 ); - } - - public static long getSelectionOrigin( final long targetRid, final Node viewNode ) - { - return getLongProperty( SELECTION_ORIGIN_PREFIX + targetRid, viewNode, -1 ); - } - - public static void setSelection( final long originRid, final long targetRid, final Node viewNode ) - { - Logger logger = LoggerFactory.getLogger( Conversions.class ); - logger.info( "Setting selection. Deselecting: {} in favor of: {} (view-node: {})", originRid, targetRid, - viewNode ); - viewNode.setProperty( DESELECTION_TARGET_PREFIX + originRid, targetRid ); - viewNode.setProperty( SELECTION_ORIGIN_PREFIX + targetRid, originRid ); - } - - public static void removeSelectionByTarget( final long targetRid, final Node viewNode ) - { - final String selKey = SELECTION_ORIGIN_PREFIX + targetRid; - final long originRid = getLongProperty( selKey, viewNode, -1 ); - - if ( originRid > -1 ) - { - viewNode.removeProperty( selKey ); - } - else - { - return; - } - - final String deKey = DESELECTION_TARGET_PREFIX + originRid; - if ( viewNode.hasProperty( deKey ) ) - { - viewNode.removeProperty( deKey ); - } - } - - public static void removeSelectionByOrigin( final long originRid, final Node viewNode ) - { - final String deKey = DESELECTION_TARGET_PREFIX + originRid; - final long targetRid = getLongProperty( deKey, viewNode, -1 ); - if ( targetRid > -1 ) - { - viewNode.removeProperty( deKey ); - } - else - { - return; - } - - final String selKey = SELECTION_ORIGIN_PREFIX + targetRid; - if ( viewNode.hasProperty( selKey ) ) - { - viewNode.removeProperty( selKey ); - } - } - - public static void storeError( final Node node, final String error ) - { - node.setProperty( PROJECT_ERROR, error ); - } - - public static String getError( final Node node ) - { - if ( !node.hasProperty( PROJECT_ERROR ) ) - { - return null; - } - - return (String) node.getProperty( PROJECT_ERROR ); - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoSpecificProjectRelationshipSerializerModule.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoSpecificProjectRelationshipSerializerModule.java deleted file mode 100644 index 3b34516f..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoSpecificProjectRelationshipSerializerModule.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.io; - -import com.fasterxml.jackson.databind.module.SimpleModule; -import org.commonjava.maven.atlas.graph.jackson.ProjectRelationshipDeserializer; -import org.commonjava.maven.atlas.graph.jackson.ProjectRelationshipSerializer; -import org.commonjava.maven.atlas.graph.rel.*; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -/** - * Created by jdcasey on 8/26/15. - */ -public class NeoSpecificProjectRelationshipSerializerModule - extends SimpleModule -{ - - private static final long serialVersionUID = 1L; - - private static final Set> REL_CLASSES; - - static - { - REL_CLASSES = Collections.unmodifiableSet( new HashSet>( - Arrays.asList( NeoBomRelationship.class, NeoDependencyRelationship.class, - NeoExtensionRelationship.class, NeoParentRelationship.class, - NeoPluginDependencyRelationship.class, NeoPluginRelationship.class ) ) ); - } - - public static final NeoSpecificProjectRelationshipSerializerModule INSTANCE = new NeoSpecificProjectRelationshipSerializerModule(); - - public NeoSpecificProjectRelationshipSerializerModule() - { - super( "ProjectRelationship Serializer" ); - - for ( Class cls : REL_CLASSES ) - { - register( cls ); - } - } - - private void register( Class cls ) - { - Logger logger = LoggerFactory.getLogger( getClass() ); - logger.debug( "Registering serializer/deserializer for: {}", cls.getSimpleName() ); - - addSerializer( cls, new ProjectRelationshipSerializer( cls ) ); - addDeserializer( cls, new ProjectRelationshipDeserializer() ); - } - - @Override - public int hashCode() - { - return getClass().getSimpleName().hashCode() + 17; - } - - @Override - public boolean equals( final Object other ) - { - return getClass().equals( other.getClass() ); - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoSpecificProjectVersionRefSerializerModule.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoSpecificProjectVersionRefSerializerModule.java deleted file mode 100644 index 363ed116..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoSpecificProjectVersionRefSerializerModule.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.io; - -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.KeyDeserializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.fasterxml.jackson.databind.module.SimpleModule; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoArtifactRef; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoProjectRef; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoProjectVersionRef; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoVersionlessArtifactRef; -import org.commonjava.maven.atlas.ident.jackson.ProjectRefSerializer; -import org.commonjava.maven.atlas.ident.jackson.SerializerIdentityUtils; -import org.commonjava.maven.atlas.ident.ref.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -public class NeoSpecificProjectVersionRefSerializerModule - extends SimpleModule -{ - - private static final long serialVersionUID = 1L; - - private static final Set> REF_CLASSES; - - static - { - REF_CLASSES = Collections.unmodifiableSet( new HashSet>( - Arrays.asList( NeoProjectRef.class, NeoProjectVersionRef.class, NeoArtifactRef.class, - NeoVersionlessArtifactRef.class ) ) ); - } - - public static final NeoSpecificProjectVersionRefSerializerModule INSTANCE = new NeoSpecificProjectVersionRefSerializerModule(); - - public NeoSpecificProjectVersionRefSerializerModule() - { - super( "ProjectRef (with variants) Serializer" ); - - for ( Class cls: REF_CLASSES ) - { - register( cls ); - } - } - - private void register( Class cls ) - { - Logger logger = LoggerFactory.getLogger( getClass() ); - logger.debug( "Registering {} serializers", cls.getSimpleName() ); - - addSerializer( cls, new ProjectRefSerializer( cls, false ) ); - addKeySerializer( cls, new ProjectRefSerializer( cls, true ) ); -// -// addDeserializer( cls, new ProjectRefDeserializer( cls ) ); -// addKeyDeserializer( cls, new ProjectRefKeyDeserializer( cls ) ); - } - - @Override - public int hashCode() - { - return getClass().getSimpleName().hashCode() + 17; - } - - @Override - public boolean equals( final Object other ) - { - return getClass().equals( other.getClass() ); - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NodeIdProjector.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NodeIdProjector.java deleted file mode 100644 index 59cfdf51..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NodeIdProjector.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.io; - -import org.neo4j.graphdb.Node; - -public class NodeIdProjector - implements Projector -{ - - public Long project( final Node item ) - { - return item.getId(); - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Projector.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Projector.java deleted file mode 100644 index 637be81c..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/Projector.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.io; - -public interface Projector -{ - - P project( T item ); - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/RelationshipIdProjector.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/RelationshipIdProjector.java deleted file mode 100644 index d425833f..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/RelationshipIdProjector.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.io; - -import org.neo4j.graphdb.Relationship; - -public class RelationshipIdProjector - implements Projector -{ - - public Long project( final Relationship item ) - { - return item.getId(); - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java deleted file mode 100644 index aa4d905b..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/AbstractNeoProjectRelationship.java +++ /dev/null @@ -1,227 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.model; - -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.neo4j.graphdb.Relationship; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.net.URI; -import java.util.Collection; -import java.util.Collections; -import java.util.Set; - -/** - * Created by jdcasey on 8/24/15. - */ -public abstract class AbstractNeoProjectRelationship, I extends ProjectRelationship, T extends ProjectVersionRef> - implements ProjectRelationship -{ - protected Relationship rel; - - private RelationshipType type; - - protected ProjectVersionRef declaring; - - private boolean dirty; - - protected T target; - - protected Set sources; - - protected AbstractNeoProjectRelationship( final Relationship rel, final RelationshipType type ) - { - this.rel = rel; - this.type = type; - } - - protected R cloneDirtyState( final R old ) - { - this.dirty = old.isDirty(); - this.declaring = old.declaring; - this.target = old.target; - this.sources = old.sources; - return (R) this; - } - - protected R withDeclaring( final ProjectVersionRef declaring ) - { - this.declaring = declaring; - this.dirty = true; - return (R) this; - } - - protected R withTarget( final T target ) - { - this.target = target; - this.dirty = true; - return (R) this; - } - - protected R withSources( final Set sources ) - { - this.sources = sources; - this.dirty = true; - return (R) this; - } - - public boolean isDirty() - { - return dirty; - } - - @Override - public synchronized I cloneFor( final ProjectVersionRef projectRef ) - { - return selectDeclaring( projectRef ); - } - - @Override - public int getIndex() - { - return NeoIdentityUtils.getIntegerProperty( rel, Conversions.INDEX, null, 0 ); - } - - @Override - public RelationshipType getType() - { - return type; - } - - @Override - public ProjectVersionRef getDeclaring() - { - return declaring == null ? new NeoProjectVersionRef( rel.getStartNode() ) : declaring; - } - - @Override - public ArtifactRef getTargetArtifact() - { - return getTarget().asPomArtifact(); - } - - @Override - public boolean isManaged() - { - return NeoIdentityUtils.getBooleanProperty( rel, Conversions.IS_MANAGED, null, false ); - } - - @Override - public boolean isInherited() - { - return NeoIdentityUtils.getBooleanProperty( rel, Conversions.IS_INHERITED, null, false ); - } - - @Override - public boolean isMixin() - { - return NeoIdentityUtils.getBooleanProperty( rel, Conversions.IS_MIXIN, null, false ); - } - - @Override - public Set getSources() - { - if ( sources != null ) - { - return sources; - } - - Set srcs = Conversions.getURISetProperty( Conversions.SOURCE_URI, rel, RelationshipUtils.UNKNOWN_SOURCE_URI ); - Logger logger = LoggerFactory.getLogger( getClass() ); - logger.debug("Got source URIs from relationship: {} of: {}", rel, srcs ); - - if ( srcs != null ) - { - return srcs; - } - - return Collections.emptySet(); - } - - @Override - public URI getPomLocation() - { - URI pl = Conversions.getURIProperty( Conversions.POM_LOCATION_URI, rel, RelationshipUtils.POM_ROOT_URI ); - if ( pl != null ) - { - return pl; - } - - return RelationshipUtils.POM_ROOT_URI; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ( ( getDeclaring() == null ) ? 0 : getDeclaring().hashCode() ); - result = prime * result + ( ( getTarget() == null ) ? 0 : getTarget().hashCode() ); - result = prime * result + ( ( getType() == null ) ? 0 : getType().hashCode() ); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( obj == null ) - { - return false; - } - if ( !(obj instanceof ProjectRelationship) ) - { - return false; - } - final ProjectRelationship other = (ProjectRelationship) obj; - if ( getDeclaring() == null ) - { - if ( other.getDeclaring() != null ) - { - return false; - } - } - else if ( !getDeclaring().equals( other.getDeclaring() ) ) - { - return false; - } - if ( getTarget() == null ) - { - if ( other.getTarget() != null ) - { - return false; - } - } - else if ( !getTarget().equals( other.getTarget() ) ) - { - return false; - } - return getType() == other.getType(); - } - - public abstract I detach(); - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/CyclePath.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/CyclePath.java deleted file mode 100644 index abef6357..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/CyclePath.java +++ /dev/null @@ -1,333 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.model; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - -import org.neo4j.graphdb.Path; -import org.neo4j.graphdb.Relationship; - -public class CyclePath - implements Iterable -{ - - public static final class CycleIterator - implements Iterator - { - - private final long[] ids; - - private int next; - - private final int start; - - public CycleIterator( final long[] ids, final int entryPoint ) - { - this.ids = ids; - start = entryPoint; - next = entryPoint; - } - - @Override - public boolean hasNext() - { - if ( next >= ids.length ) - { - if ( start > 0 ) - { - next = 0; - return true; - } - - return false; - } - else if ( next == -1 ) - { - return false; - } - - return true; - } - - @Override - public Long next() - { - if ( hasNext() ) - { - final long id = ids[next++]; - if ( next == start ) - { - next = -1; - } - - return id; - } - else if ( next == start ) - { - throw new IndexOutOfBoundsException( next + " is the starting point for this iteration!" ); - } - - throw new IndexOutOfBoundsException( next + " is the next index, but the array has only " + ids.length - + " items!" ); - } - - @Override - public void remove() - { - throw new UnsupportedOperationException( "Cannot remove id; CyclePath is immutable." ); - } - - } - - private int entryPoint = 0; - - private final long[] ids; - - public CyclePath( final long[] ids ) - { - this.ids = ids; - } - - public CyclePath( final List ids ) - { - this.ids = new long[ids.size()]; - for ( int i = 0; i < ids.size(); i++ ) - { - this.ids[i] = ids.get( i ); - } - } - - public CyclePath( final Path path ) - { - final List ids = new ArrayList(); - for ( final Relationship r : path.relationships() ) - { - ids.add( r.getId() ); - } - - this.ids = new long[ids.size()]; - for ( int i = 0; i < ids.size(); i++ ) - { - this.ids[i] = ids.get( i ); - } - } - - public void setEntryPoint( final long entryPoint ) - { - for ( int i = 0; i < ids.length; i++ ) - { - if ( ids[i] == entryPoint ) - { - this.entryPoint = i; - return; - } - } - } - - public void clearEntryPoint() - { - entryPoint = 0; - } - - @Override - public Iterator iterator() - { - return new CycleIterator( ids, entryPoint ); - } - - public long getLastRelationshipId() - { - final int last = entryPoint > 0 ? entryPoint - 1 : ids.length - 1; - - return ids[last]; - } - - public long getFirstRelationshipId() - { - return ids[entryPoint]; - } - - public long[] getRelationshipIds() - { - // if ( entryPoint == 0 ) - // { - // return getRawRelationshipIds(); - // } - - final long[] ids = new long[this.ids.length]; - final Iterator iterator = iterator(); - - int i = 0; - while ( iterator.hasNext() ) - { - ids[i++] = iterator.next(); - } - - return ids; - } - - @Override - public int hashCode() - { - final int prime = 37; - - if ( ids.length == 0 ) - { - return prime; - } - - final CycleIterator it = identityIterator(); - - int result = prime; - - int i = 0; - while ( it.hasNext() ) - { - if ( i % 2 == 1 ) - { - result += it.next() - .hashCode(); - } - else - { - result -= it.next() - .hashCode(); - } - - i++; - } - - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( !super.equals( obj ) ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final CyclePath other = (CyclePath) obj; - - if ( ids.length != other.ids.length ) - { - return false; - } - else if ( ids.length == 0 ) - { - return true; - } - - final CycleIterator it = identityIterator(); - final CycleIterator oit = other.identityIterator(); - - while ( it.hasNext() ) - { - if ( it.next() != oit.next() ) - { - return false; - } - } - - return true; - } - - public CycleIterator identityIterator() - { - final long[] sorted = new long[ids.length]; - - System.arraycopy( ids, 0, sorted, 0, ids.length ); - Arrays.sort( sorted ); - - int entry = 0; - for ( int i = 0; i < ids.length; i++ ) - { - if ( ids[i] == sorted[0] ) - { - entry = i; - break; - } - } - - return new CycleIterator( ids, entry ); - } - - private long[] getRawRelationshipIds() - { - return ids; - } - - public CyclePath reorientToEntryPoint() - { - if ( entryPoint == 0 ) - { - return this; - } - - final long[] ids = getRawRelationshipIds(); - final long[] reoriented = new long[ids.length]; - - final CycleIterator it = new CycleIterator( ids, entryPoint ); - int i = 0; - while ( it.hasNext() ) - { - reoriented[i++] = it.next(); - } - - return new CyclePath( reoriented ); - } - - public String getKey() - { - final StringBuilder sb = new StringBuilder(); - - final CycleIterator it = identityIterator(); - while ( it.hasNext() ) - { - if ( sb.length() > 0 ) - { - sb.append( ',' ); - } - - sb.append( it.next() ); - } - - return sb.toString(); - } - - @Override - public String toString() - { - return "CyclePath [" + getKey() + "]"; - } - - public int length() - { - return ids.length; - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java deleted file mode 100644 index b43e41e9..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/Neo4jGraphPath.java +++ /dev/null @@ -1,299 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.model; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - -import org.apache.commons.codec.digest.DigestUtils; -import org.commonjava.maven.atlas.graph.model.GraphPath; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Path; -import org.neo4j.graphdb.Relationship; - -public class Neo4jGraphPath - implements GraphPath -{ - - private final long[] relationships; - - private final long startNode; - - private final long endNode; - - public Neo4jGraphPath( final Neo4jGraphPath parent, final Relationship... relationships ) - { - if ( parent == null ) - { - throw new NullPointerException( "Parent path cannot be null" ); - } - - this.startNode = parent.startNode; - if ( relationships.length > 0 ) - { - this.endNode = relationships[relationships.length - 1].getEndNode() - .getId(); - } - else - { - this.endNode = parent.endNode; - } - - final int parentLen = parent.relationships.length; - - this.relationships = new long[parentLen + relationships.length]; - - if ( parentLen > 0 ) - { - System.arraycopy( parent.relationships, 0, this.relationships, 0, parent.relationships.length ); - } - - if ( this.relationships.length > 0 ) - { - for ( int i = parentLen; i < this.relationships.length; i++ ) - { - this.relationships[i] = relationships[i - parentLen].getId(); - } - } - } - - public Neo4jGraphPath( final Path path ) - { - this.startNode = path.startNode() - .getId(); - this.endNode = path.endNode() - .getId(); - - final List ids = new ArrayList(); - for ( final Relationship r : path.relationships() ) - { - ids.add( r.getId() ); - } - - this.relationships = new long[ids.size()]; - for ( int i = 0; i < ids.size(); i++ ) - { - this.relationships[i] = ids.get( i ); - } - } - - public Neo4jGraphPath( final Node start, final Node end, final long[] rids ) - { - this.startNode = start.getId(); - this.endNode = end.getId(); - this.relationships = rids; - } - - public Neo4jGraphPath( final Relationship[] relationships ) - { - if ( relationships.length > 0 ) - { - this.startNode = relationships[0].getStartNode() - .getId(); - - this.endNode = relationships[relationships.length - 1].getEndNode() - .getId(); - } - else - { - throw new IllegalArgumentException( - "Cannot initialize path with zero relationships and no explicit start node!" ); - } - - this.relationships = new long[relationships.length]; - - final int i = 0; - for ( final Relationship relationship : relationships ) - { - this.relationships[i] = relationship.getId(); - } - } - - private Neo4jGraphPath( final Neo4jGraphPath parent, final long endNode, final long[] newRelationships ) - { - this.startNode = parent.startNode; - this.endNode = endNode; - - final int parentLen = parent.relationships.length; - - this.relationships = new long[parentLen + newRelationships.length]; - - System.arraycopy( parent.relationships, 0, this.relationships, 0, parentLen ); - System.arraycopy( newRelationships, 0, this.relationships, parentLen, newRelationships.length ); - } - - public Neo4jGraphPath append( final Neo4jGraphPath childPath ) - { - if ( length() > 0 && getLastRelationshipId() != childPath.getFirstRelationshipId() ) - { - throw new IllegalArgumentException( "Cannot splice " + childPath + " onto " + this - + ". They don't overlap on last/first relationshipId!" ); - } - - if ( childPath.length() < 2 ) - { - return this; - } - - final long[] ids = new long[childPath.length() - 1]; - System.arraycopy( childPath.getRelationshipIds(), 1, ids, 0, ids.length ); - - return new Neo4jGraphPath( this, childPath.endNode, ids ); - } - - public long getStartNodeId() - { - return startNode; - } - - public long getEndNodeId() - { - return endNode; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + Long.valueOf( startNode ).hashCode(); - result = prime * result + Long.valueOf( endNode ).hashCode(); - result = prime * result + Arrays.hashCode( relationships ); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( obj == null ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final Neo4jGraphPath other = (Neo4jGraphPath) obj; - if ( startNode != other.startNode ) - { - return false; - } - if ( endNode != other.endNode ) - { - return false; - } - return Arrays.equals( relationships, other.relationships ); - } - - @Override - public Iterator iterator() - { - return new Iterator() - { - private int next = 0; - - @Override - public boolean hasNext() - { - return relationships.length > next; - } - - @Override - public Long next() - { - return relationships[next++]; - } - - @Override - public void remove() - { - throw new UnsupportedOperationException( "Immutable array of relationship ID's. Remove not supported." ); - } - }; - } - - @Override - public String toString() - { - return String.format( "%s [relationships=%s, from=%s, to=%s]", getClass().getSimpleName(), - Arrays.toString( relationships ), startNode, endNode ); - } - - @Override - public String getKey() - { - final StringBuilder sb = new StringBuilder(); - for ( final long id : relationships ) - { - if ( sb.length() > 0 ) - { - sb.append( ',' ); - } - sb.append( id ); - } - - return DigestUtils.shaHex( sb.toString() ); - } - - public long getLastRelationshipId() - { - if ( relationships.length < 1 ) - { - return -1; - } - - return relationships[relationships.length - 1]; - } - - public long getFirstRelationshipId() - { - if ( relationships.length < 1 ) - { - return -1; - } - - return relationships[0]; - } - - public long[] getRelationshipIds() - { - return relationships; - } - - public int length() - { - return relationships.length; - } - - public boolean contains( final long id ) - { - for ( final long rid : relationships ) - { - if ( rid == id ) - { - return true; - } - } - return false; - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java deleted file mode 100644 index bcb528c0..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoArtifactRef.java +++ /dev/null @@ -1,229 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.model; - -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.InvalidRefException; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.TypeAndClassifier; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; -import org.commonjava.maven.atlas.ident.version.SingleVersion; -import org.commonjava.maven.atlas.ident.version.VersionSpec; -import org.neo4j.graphdb.Node; - -import java.io.Serializable; - -import static org.apache.commons.lang.StringUtils.isEmpty; - -/** - * Represents an artifact, in Maven parlance. A tangible result of a build, which is typically made available in a Maven repository for others - * to consume. NOTE: a POM file is both a piece of metadata AND an artifact in the Maven world! - * - * Artifacts are based on the GAV coordinate for the project release, but also contain a type and optionally, a classifier. Type defaults to 'jar'. - * - * @see {@link NeoProjectRef} - * @see {@link NeoProjectVersionRef} - * - * @author jdcasey - */ -public class NeoArtifactRef - extends NeoProjectVersionRef - implements Serializable, ArtifactRef -{ - - private static final long serialVersionUID = 1L; - - private NeoTypeAndClassifier tc; - - public NeoArtifactRef( final String groupId, final String artifactId, final VersionSpec version, final String type, - final String classifier ) - { - super( groupId, artifactId, version ); - this.tc = new NeoTypeAndClassifier( type, classifier ); - } - - public NeoArtifactRef( final NeoProjectVersionRef ref, final String type, final String classifier ) - { - this( ref, new NeoTypeAndClassifier( type, classifier ) ); - } - - public NeoArtifactRef( final NeoProjectVersionRef ref ) - { - this( ref, new NeoTypeAndClassifier( "pom", null ) ); - } - - public NeoArtifactRef( final ProjectVersionRef ref, final NeoTypeAndClassifier tc ) - { - super( ref ); - this.tc = tc; - } - - public NeoArtifactRef( final Node node, final NeoTypeAndClassifier tc ) - { - super( node ); - this.tc = tc; - } - - public NeoArtifactRef( final String groupId, final String artifactId, final String versionSpec, final String type, - final String classifier ) - throws InvalidVersionSpecificationException - { - super( groupId, artifactId, versionSpec ); - this.tc = new NeoTypeAndClassifier( type, classifier ); - } - - @Override - public String toString() - { - return String.format( "%s:%s:%s:%s%s", getGroupId(), getArtifactId(), getType(), getVersionString(), - ( getClassifier() == null ? "" : ":" + getClassifier() ) ); - } - - public static NeoArtifactRef parse( final String spec ) - { - final String[] parts = spec.split( ":" ); - - if ( parts.length < 3 || isEmpty( parts[0] ) || isEmpty( parts[1] ) || isEmpty( parts[2] ) ) - { - throw new InvalidRefException( - "SimpleArtifactRef must contain AT LEAST non-empty groupId, artifactId, AND version. (Given: '" - + spec + "')" ); - } - - final String g = parts[0]; - final String a = parts[1]; - - // assume we're actually parsing a GAV into a POM artifact... - String v = parts[2]; - String t = "pom"; - String c = null; - - if ( parts.length > 3 ) - { - // oops, it's a type, not a version...see toString() for the specification. - t = v; - v = parts[3]; - - if ( parts.length > 4 ) - { - c = parts[4]; - } - } - - // assume non-optional, because it might not matter if you're parsing a string like this...you'd be more careful if you were reading something - // that had an optional field, because it's not in the normal GATV[C] spec. - return new NeoArtifactRef( g, a, v, t, c ); - } - - @Override - public NeoArtifactRef newRef( final String groupId, final String artifactId, final SingleVersion version ) - { - return new NeoArtifactRef( groupId, artifactId, version, tc.getType(), tc.getClassifier() ); - } - - @Override - public String getType() - { - return tc.getType(); - } - - @Override - public String getClassifier() - { - return tc.getClassifier(); - } - - @Override - public TypeAndClassifier getTypeAndClassifier() - { - return tc; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ( ( tc == null ) ? 0 : tc.hashCode() ); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( !super.equals( obj ) ) - { - return false; - } - if ( !(obj instanceof ArtifactRef) ) - { - return false; - } - final ArtifactRef other = (ArtifactRef) obj; - - return artifactFieldsEqual( other ); - } - - private boolean artifactFieldsEqual( final ArtifactRef other ) - { - if ( tc == null ) - { - if ( other.getTypeAndClassifier() != null ) - { - return false; - } - } - else if ( !tc.equals( other.getTypeAndClassifier() ) ) - { - return false; - } - return true; - } - - @Override - public boolean versionlessEquals( final ProjectVersionRef other ) - { - if ( !super.versionlessEquals( other ) ) - { - return false; - } - - if ( !( other instanceof ArtifactRef ) ) - { - // compare vs. POM reference. - return "pom".equals(tc.getType()) && null == tc.getClassifier(); - } - - return artifactFieldsEqual( (ArtifactRef) other ); - } - - @Override - public boolean isDirty() - { - return super.isDirty() || tc.isDirty(); - } - - @Override - public T detach() - { - return (T) new SimpleArtifactRef( this ); - } -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoBomRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoBomRelationship.java deleted file mode 100644 index b9e8b993..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoBomRelationship.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.model; - -import org.commonjava.maven.atlas.graph.rel.AbstractSimpleProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.BomRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.graph.rel.SimpleBomRelationship; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.neo4j.graphdb.Relationship; - -import java.net.URI; -import java.util.Collection; -import java.util.Set; - -/** NOTE: BOM relationships are actually marked as concrete. - * This may be somewhat counter-intuitive, but they are structural (like a parent POM). - * Therefore, managed isn't correct (despite Maven's unfortunate choice for location). - */ -public class NeoBomRelationship - extends AbstractNeoProjectRelationship - implements BomRelationship -{ - - private static final long serialVersionUID = 1L; - - public NeoBomRelationship( final Relationship rel ) - { - super( rel, RelationshipType.BOM ); - } - - @Override - public BomRelationship selectDeclaring( final ProjectVersionRef ref ) - { - return new NeoBomRelationship( rel ).cloneDirtyState( this ).withDeclaring( ref ); - } - - @Override - public BomRelationship selectTarget( final ProjectVersionRef ref ) - { - return new NeoBomRelationship( rel ).cloneDirtyState( this ).withTarget( ref ); - } - - @Override - public BomRelationship addSource( URI source ) - { - Set sources = getSources(); - if ( sources.add( source ) ) - { - return new NeoBomRelationship( rel ).cloneDirtyState( this ).withSources( sources ); - } - - return this; - } - - @Override - public BomRelationship addSources( Collection sources ) - { - Set srcs = getSources(); - boolean changed = false; - for ( URI src : sources ) - { - changed = srcs.add( src ) || changed; - } - - if ( changed ) - { - return new NeoBomRelationship( rel ).cloneDirtyState( this ).withSources( srcs ); - } - - return this; - } - - @Override - public ProjectVersionRef getTarget() - { - return target == null ? new NeoProjectVersionRef( rel.getEndNode() ) : target; - } - - @Override - public String toString() - { - return String.format( "BomRelationship [%s => %s, rel=%d]", getDeclaring(), getTarget(), rel.getId() ); - } - - @Override - public BomRelationship detach() - { - return new SimpleBomRelationship( this ); - } -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java deleted file mode 100644 index c8c5a9f3..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoDependencyRelationship.java +++ /dev/null @@ -1,196 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.model; - -import org.commonjava.maven.atlas.graph.rel.AbstractSimpleProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.BomRelationship; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.neo4j.graphdb.Relationship; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.Serializable; -import java.net.URI; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -public final class NeoDependencyRelationship - extends AbstractNeoProjectRelationship - implements Serializable, DependencyRelationship -{ - - private static final long serialVersionUID = 1L; - - public NeoDependencyRelationship( final Relationship rel ) - { - super(rel, RelationshipType.DEPENDENCY); - } - - @Override - public final DependencyScope getScope() - { - final String scopeStr = Conversions.getStringProperty( Conversions.SCOPE, rel ); - Logger logger = LoggerFactory.getLogger( getClass() ); - logger.debug("Got scope from relationship: {} of: {}", rel, scopeStr ); - - DependencyScope scope = DependencyScope.getScope( scopeStr ); - return scope == null ? DependencyScope.compile : scope; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ( isManaged() ? 1231 : 1237 ); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( !super.equals( obj ) ) - { - return false; - } - if ( !( obj instanceof DependencyRelationship ) ) - { - return false; - } - final DependencyRelationship other = (DependencyRelationship) obj; - return isManaged() == other.isManaged(); - } - - @Override - public DependencyRelationship detach() - { - return new SimpleDependencyRelationship( this ); - } - - @Override - public String toString() - { - return String.format( "DependencyRelationship [%s => %s (managed=%s, scope=%s, index=%s)]", getDeclaring(), - getTarget(), isManaged(), getScope(), getIndex() ); - } - - @Override - public ArtifactRef getTarget() - { - return target == null ? new NeoArtifactRef( rel.getEndNode(), new NeoTypeAndClassifier( rel ) ) : target; - } - - @Override - public ArtifactRef getTargetArtifact() - { - return getTarget(); - } - - @Override - public Set getExcludes() - { - final String excludeStr = Conversions.getStringProperty( Conversions.EXCLUDES, rel ); - final Set excludes = new HashSet(); - if ( excludeStr != null ) - { - final String[] e = excludeStr.split( "\\s*,\\s*" ); - for ( final String ex : e ) - { - final String[] parts = ex.split( ":" ); - if ( parts.length != 2 ) - { - // LOGGER.error( "In: {} -> {} skipping invalid exclude specification: '{}'", from, artifact, ex ); - } - else - { - excludes.add( new NeoProjectRef( parts[0], parts[1] ) ); - } - } - } - - return excludes; - } - - @Override - public DependencyRelationship selectDeclaring( final ProjectVersionRef ref ) - { - return new NeoDependencyRelationship( rel ).cloneDirtyState( this ).withDeclaring( ref ); - } - - @Override - public DependencyRelationship selectTarget( final ProjectVersionRef ref ) - { - return new NeoDependencyRelationship( rel ).cloneDirtyState( this ).withTarget( NeoIdentityUtils.newNeoArtifactRef( - ref, getTarget() ) ); - } - - @Override - public DependencyRelationship addSource( final URI source ) - { - Set sources = getSources(); - if ( sources.add( source ) ) - { - return new NeoDependencyRelationship( rel ).cloneDirtyState( this ).withSources( sources ); - } - - return this; - } - - @Override - public DependencyRelationship addSources( final Collection sources ) - { - Set srcs = getSources(); - boolean changed = false; - for ( URI src: sources ) - { - changed = srcs.add( src ) || changed; - } - - if ( changed ) - { - return new NeoDependencyRelationship( rel ).cloneDirtyState( this ).withSources( srcs ); - } - - return this; - } - - @Override - public boolean isBOM() - { - return DependencyScope._import == getScope() && "pom".equals( getTargetArtifact().getType() ); - } - - @Override - public boolean isOptional() - { - return Conversions.getBooleanProperty( Conversions.OPTIONAL, rel ); - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoExtensionRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoExtensionRelationship.java deleted file mode 100644 index 2ae012f5..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoExtensionRelationship.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.model; - -import org.commonjava.maven.atlas.graph.rel.AbstractSimpleProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.graph.rel.SimpleExtensionRelationship; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.neo4j.graphdb.Relationship; - -import java.io.Serializable; -import java.net.URI; -import java.util.Collection; -import java.util.Set; - -public final class NeoExtensionRelationship - extends AbstractNeoProjectRelationship - implements Serializable, ExtensionRelationship -{ - - private static final long serialVersionUID = 1L; - - public NeoExtensionRelationship( final Relationship rel ) - { - super( rel, RelationshipType.EXTENSION ); - } - - @Override - public String toString() - { - return String.format( "ExtensionRelationship [%s => %s (index=%s)]", getDeclaring(), getTarget(), getIndex() ); - } - - @Override - public ProjectVersionRef getTarget() - { - return target == null ? new NeoProjectVersionRef( rel.getEndNode() ) : target; - } - - @Override - public ArtifactRef getTargetArtifact() - { - return getTarget().asJarArtifact(); - } - - @Override - public ExtensionRelationship detach() - { - return new SimpleExtensionRelationship( this ); - } - - @Override - public ExtensionRelationship selectDeclaring( final ProjectVersionRef ref ) - { - return new NeoExtensionRelationship( rel ).cloneDirtyState( this ).withDeclaring( ref ); - } - - @Override - public ExtensionRelationship selectTarget( final ProjectVersionRef ref ) - { - return new NeoExtensionRelationship( rel ).cloneDirtyState( this ).withTarget( ref ); - } - - @Override - public ExtensionRelationship addSource( URI source ) - { - Set sources = getSources(); - if ( sources.add( source ) ) - { - return new NeoExtensionRelationship( rel ).cloneDirtyState( this ).withSources( sources ); - } - - return this; - } - - @Override - public ExtensionRelationship addSources( Collection sources ) - { - Set srcs = getSources(); - boolean changed = false; - for ( URI src: sources ) - { - changed = srcs.add( src ) || changed; - } - - if ( changed ) - { - return new NeoExtensionRelationship( rel ).cloneDirtyState( this ).withSources( srcs ); - } - - return this; - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentityUtils.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentityUtils.java deleted file mode 100644 index 46b69aa6..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentityUtils.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.model; - -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.InvalidRefException; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.PropertyContainer; -import org.neo4j.graphdb.Relationship; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Created by jdcasey on 8/24/15. - */ -public final class NeoIdentityUtils -{ - - private NeoIdentityUtils(){} - - public static String getStringProperty( final PropertyContainer container, final String named, final String memVal ) - { - if ( memVal != null ) - { - return memVal; - } - - String v = container == null ? null : Conversions.getStringProperty( named, container ); - if ( v == null ) - { - throw new InvalidRefException( named + " cannot both be null!" ); - } - - return v; - } - - public static String getStringProperty( final PropertyContainer container, final String named, final String memVal, final String defaultVal ) - { -// Logger logger = LoggerFactory.getLogger( NeoIdentityUtils.class ); -// logger.debug( "Looking for property: {} in: {}.\nMemory value: {}\nDefault value: {}", named, container, memVal, defaultVal); - if ( memVal == null ) - { - String v = container == null ? null : Conversions.getStringProperty(named, container); -// logger.debug( "From container: {}, value: {}", container, v ); - return v == null ? defaultVal : v; - } - -// logger.debug("Returning memVal: {}", memVal); - return memVal; - } - - public static boolean getBooleanProperty( final PropertyContainer container, final String named, final Boolean memVal, final boolean defaultVal ) - { - if ( memVal != null ) - { - return memVal; - } - - Boolean v = container == null ? null : Conversions.getBooleanProperty( named, container); - return v == null ? defaultVal : v; - } - - public static ArtifactRef newNeoArtifactRef( final ProjectVersionRef ref, final ArtifactRef target ) - { - NeoTypeAndClassifier tc; - if ( target instanceof NeoArtifactRef ) - { - tc = (NeoTypeAndClassifier) target.getTypeAndClassifier(); - } - else - { - tc = new NeoTypeAndClassifier( target.getType(), target.getClassifier() ); - } - return new NeoArtifactRef( ref, tc ); - } - - public static int getIntegerProperty( final PropertyContainer container, final String named, final Integer memVal, final int defaultVal ) - { - if ( memVal != null ) - { - return memVal; - } - - Integer v = container == null ? null : Conversions.getIntegerProperty( named, container); - return v == null ? defaultVal : v; - } -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoParentRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoParentRelationship.java deleted file mode 100644 index 9a8af8e4..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoParentRelationship.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.model; - -import org.commonjava.maven.atlas.graph.rel.AbstractSimpleProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.neo4j.graphdb.Relationship; - -import java.io.Serializable; -import java.net.URI; -import java.util.Collection; -import java.util.Collections; -import java.util.Set; - -public final class NeoParentRelationship - extends AbstractNeoProjectRelationship - implements Serializable, ParentRelationship -{ - - private static final long serialVersionUID = 1L; - - /** - * Ancestry terminus. This is to signify that the declaring project has NO parent relationship. - */ - public NeoParentRelationship( final Relationship rel ) - { - super( rel, RelationshipType.PARENT ); - } - - @Override - public String toString() - { - return String.format( "ParentRelationship [%s => %s]", getDeclaring(), getTarget() ); - } - - @Override - public ProjectVersionRef getTarget() - { - return target == null ? new NeoProjectVersionRef( rel.getEndNode() ) : target; - } - - @Override - public ArtifactRef getTargetArtifact() - { - return getTarget().asPomArtifact(); - } - - @Override - public boolean isTerminus() - { - if ( declaring != null || target != null ) - { - return getDeclaring().equals( getTarget() ); - } - - return rel.getStartNode().getId() == rel.getEndNode().getId(); - } - - @Override - public ParentRelationship selectDeclaring( final ProjectVersionRef ref ) - { - return new NeoParentRelationship( rel ).cloneDirtyState( this ).withDeclaring( ref ); - } - - @Override - public ParentRelationship selectTarget( final ProjectVersionRef ref ) - { - return new NeoParentRelationship( rel ).cloneDirtyState( this ).withTarget( ref ); - } - - @Override - public ParentRelationship addSource( URI source ) - { - Set sources = getSources(); - if ( sources.add( source ) ) - { - return new NeoParentRelationship( rel ).cloneDirtyState( this ).withSources( sources ); - } - - return this; - } - - @Override - public ParentRelationship addSources( Collection sources ) - { - Set srcs = getSources(); - boolean changed = false; - for ( URI src : sources ) - { - changed = srcs.add( src ) || changed; - } - - if ( changed ) - { - return new NeoParentRelationship( rel ).cloneDirtyState( this ).withSources( srcs ); - } - - return this; - } - - @Override - public Set getSources() - { - return isTerminus() ? - Collections.singleton( RelationshipUtils.TERMINAL_PARENT_SOURCE_URI ) : - super.getSources(); - } - - @Override - public ParentRelationship detach() - { - return new SimpleParentRelationship( this ); - } -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java deleted file mode 100644 index 05ad2a94..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginDependencyRelationship.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.model; - -import org.commonjava.maven.atlas.graph.rel.AbstractSimpleProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.graph.rel.SimplePluginDependencyRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.neo4j.graphdb.Relationship; - -import java.io.Serializable; -import java.net.URI; -import java.util.Collection; -import java.util.Set; - -public final class NeoPluginDependencyRelationship - extends AbstractNeoProjectRelationship - implements Serializable, PluginDependencyRelationship -{ - - private static final long serialVersionUID = 1L; - - public NeoPluginDependencyRelationship( final Relationship rel ) - { - super( rel, RelationshipType.PLUGIN_DEP ); - } - - @Override - public final ProjectRef getPlugin() - { - return new NeoProjectRef( rel, Conversions.PLUGIN_GROUP_ID, Conversions.PLUGIN_ARTIFACT_ID ); - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ( isManaged() ? 1231 : 1237 ); - result = prime * result + ( ( getPlugin() == null ) ? 0 : getPlugin().hashCode() ); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( !super.equals( obj ) ) - { - return false; - } - if ( !(obj instanceof PluginDependencyRelationship) ) - { - return false; - } - final PluginDependencyRelationship other = (PluginDependencyRelationship) obj; - if ( isManaged() != other.isManaged() ) - { - return false; - } - if ( getPlugin() == null ) - { - if ( other.getPlugin() != null ) - { - return false; - } - } - else if ( !getPlugin().equals( other.getPlugin() ) ) - { - return false; - } - return true; - } - - @Override - public PluginDependencyRelationship detach() - { - return new SimplePluginDependencyRelationship( this ); - } - - @Override - public String toString() - { - return String.format( "PluginDependencyRelationship [%s -> (%s) => %s (managed=%s, index=%s)]", getDeclaring(), - getPlugin(), getTarget(), isManaged(), getIndex() ); - } - - @Override - public ArtifactRef getTarget() - { - return target == null ? new NeoArtifactRef( rel.getEndNode(), new NeoTypeAndClassifier( rel ) ) : target; - } - - @Override - public ArtifactRef getTargetArtifact() - { - return getTarget(); - } - - @Override - public PluginDependencyRelationship selectDeclaring( final ProjectVersionRef ref ) - { - return new NeoPluginDependencyRelationship( rel ).cloneDirtyState( this ).withDeclaring( ref ); - } - - @Override - public PluginDependencyRelationship selectTarget( final ProjectVersionRef ref ) - { - ArtifactRef t = getTarget(); - return new NeoPluginDependencyRelationship( rel ).cloneDirtyState( this ).withTarget( NeoIdentityUtils.newNeoArtifactRef( ref, t ) ); - } - - @Override - public PluginDependencyRelationship addSource( final URI source ) - { - Set sources = getSources(); - if ( sources.add( source ) ) - { - return new NeoPluginDependencyRelationship( rel ).cloneDirtyState( this ).withSources( sources ); - } - - return this; - } - - @Override - public PluginDependencyRelationship addSources( final Collection sources ) - { - Set srcs = getSources(); - boolean changed = false; - for ( URI src: sources ) - { - changed = srcs.add( src ) || changed; - } - - if ( changed ) - { - return new NeoPluginDependencyRelationship( rel ).cloneDirtyState( this ).withSources( srcs ); - } - - return this; - } - - @Override - public boolean isOptional() - { - return Conversions.getBooleanProperty( Conversions.OPTIONAL, rel ); - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java deleted file mode 100644 index d155bddf..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoPluginRelationship.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.model; - -import org.commonjava.maven.atlas.graph.rel.AbstractSimpleProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.neo4j.graphdb.Relationship; - -import java.io.Serializable; -import java.net.URI; -import java.util.Collection; -import java.util.Set; - -public final class NeoPluginRelationship - extends AbstractNeoProjectRelationship - implements Serializable, PluginRelationship -{ - - private static final long serialVersionUID = 1L; - - public NeoPluginRelationship( final Relationship rel ) - { - super( rel, RelationshipType.PLUGIN ); - } - - @Override - public final boolean isReporting() - { - return Conversions.getBooleanProperty( Conversions.IS_REPORTING_PLUGIN, rel ); - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ( isManaged() ? 1231 : 1237 ); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( !super.equals( obj ) ) - { - return false; - } - if ( !(obj instanceof PluginRelationship) ) - { - return false; - } - final PluginRelationship other = (PluginRelationship) obj; - return isManaged() == other.isManaged(); - } - - @Override - public PluginRelationship detach() - { - return new SimplePluginRelationship( this ); - } - - @Override - public String toString() - { - return String.format( "PluginRelationship [%s => %s (managed=%s, index=%s)]", getDeclaring(), getTarget(), - isManaged(), getIndex() ); - } - - @Override - public ProjectVersionRef getTarget() - { - return target == null ? new NeoProjectVersionRef( rel.getEndNode() ) : target; - } - - @Override - public ArtifactRef getTargetArtifact() - { - return new SimpleArtifactRef( getTarget(), "maven-plugin", null ); - } - - @Override - public PluginRelationship selectDeclaring( final ProjectVersionRef ref ) - { - return new NeoPluginRelationship( rel ).cloneDirtyState( this ).withDeclaring( ref ); - } - - @Override - public PluginRelationship selectTarget( final ProjectVersionRef ref ) - { - return new NeoPluginRelationship( rel ).cloneDirtyState( this ).withTarget( ref ); - } - - @Override - public PluginRelationship addSource( URI source ) - { - Set sources = getSources(); - if ( sources.add( source ) ) - { - return new NeoPluginRelationship( rel ).cloneDirtyState( this ).withSources( sources ); - } - - return this; - } - - @Override - public PluginRelationship addSources( Collection sources ) - { - Set srcs = getSources(); - boolean changed = false; - for ( URI src: sources ) - { - changed = srcs.add( src ) || changed; - } - - if ( changed ) - { - return new NeoPluginRelationship( rel ).cloneDirtyState( this ).withSources( srcs ); - } - - return this; - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java deleted file mode 100644 index ed62105f..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRef.java +++ /dev/null @@ -1,251 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.model; - -import static org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoIdentityUtils.getStringProperty; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; -import org.commonjava.maven.atlas.ident.ref.InvalidRefException; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; -import org.commonjava.maven.atlas.ident.ref.TypeAndClassifier; -import org.commonjava.maven.atlas.ident.ref.VersionlessArtifactRef; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.PropertyContainer; -import org.neo4j.graphdb.Relationship; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.apache.commons.lang.StringUtils.isEmpty; - -/** - * Reference to a whole project (or module, in terms of Maven builds). This reference is not specific to a release of the project (see {@link NeoProjectVersionRef}). - * - * @author jdcasey - */ -public class NeoProjectRef - implements ProjectRef -{ - - private static final long serialVersionUID = 1L; - - private String groupId; - - private String artifactId; - - protected PropertyContainer container; - - private String groupIdProperty = Conversions.GROUP_ID; - - private String artifactIdProperty = Conversions.ARTIFACT_ID; - - public NeoProjectRef(final ProjectRef ref) - { - if ( ref instanceof NeoProjectRef) - { - NeoProjectRef npr = (NeoProjectRef) ref; - container = npr.container; - this.groupId = npr.groupId; - this.artifactId = npr.artifactId; - this.groupIdProperty = npr.groupIdProperty; - this.artifactIdProperty = npr.artifactIdProperty; - } - else - { - groupId = ref.getGroupId(); - artifactId = ref.getArtifactId(); - } - } - - public NeoProjectRef( final String groupId, final String artifactId ) - { - this.groupId = groupId; - this.artifactId = artifactId; - - if ( isEmpty( getGroupId() ) || isEmpty( getArtifactId() ) ) - { - throw new InvalidRefException( "ProjectId must contain non-empty groupId AND artifactId. (Given: '" - + groupId + "':'" + artifactId + "')" ); - } - } - - public NeoProjectRef( final Node container ) - { - this.container = container; - if ( isEmpty( getGroupId() ) || isEmpty( getArtifactId() ) ) - { - throw new InvalidRefException( "ProjectId must contain non-empty groupId AND artifactId. (Given: '" - + getGroupId() + "':'" + getArtifactId() + "', db-node=" + container.getId() + ")" ); - } - } - - public NeoProjectRef( final PropertyContainer container, final String groupIdProperty, final String artifactIdProperty ) - { - Logger logger = LoggerFactory.getLogger( getClass() ); - logger.debug( "setting up project ref on container: {} with gid prop: {} and aid prop: {}", container, - groupIdProperty, artifactIdProperty ); - - this.container = container; - this.groupIdProperty = groupIdProperty; - this.artifactIdProperty = artifactIdProperty; - } - - public static ProjectRef parse( final String ga ) - { - final String[] parts = ga.split( ":" ); - if ( parts.length < 2 || isEmpty( parts[0] ) || isEmpty( parts[1] ) ) - { - throw new InvalidRefException( "ProjectRef must contain non-empty groupId AND artifactId. (Given: '" + ga - + "')" ); - } - - return new NeoProjectRef( parts[0], parts[1] ); - } - - @Override - public final String getGroupId() - { - return getStringProperty( container, groupIdProperty, groupId, null ); - } - - @Override - public final String getArtifactId() - { - return getStringProperty( container, artifactIdProperty, artifactId, null ); - } - - @Override - public ProjectRef asProjectRef() - { - return NeoProjectRef.class.equals( getClass() ) ? this : new NeoProjectRef( getGroupId(), getArtifactId() ); - } - - @Override - public VersionlessArtifactRef asVersionlessPomArtifact() - { - return asVersionlessArtifactRef( "pom", null ); - } - - @Override - public VersionlessArtifactRef asVersionlessJarArtifact() - { - return asVersionlessArtifactRef( "jar", null ); - } - - @Override - public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier ) - { - return new NeoVersionlessArtifactRef( this, type, classifier ); - } - - @Override - public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc ) - { - return new NeoVersionlessArtifactRef( this, tc ); - } - - @Override - public String toString() - { - return String.format( "%s:%s", getGroupId(), getArtifactId() ); - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + getArtifactId().hashCode(); - result = prime * result + getGroupId().hashCode(); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( obj == null ) - { - return false; - } - if ( !(obj instanceof ProjectRef) ) - { - return false; - } - final ProjectRef other = (ProjectRef) obj; - if ( !getArtifactId().equals( other.getArtifactId() ) ) - { - return false; - } - return getGroupId().equals( other.getGroupId() ); - } - - @Override - public int compareTo( final ProjectRef o ) - { - int comp = getGroupId().compareTo( o.getGroupId() ); - if ( comp == 0 ) - { - comp = getArtifactId().compareTo( o.getArtifactId() ); - } - - return comp; - } - - @Override - public boolean matches( final ProjectRef ref ) - { - if ( equals( ref ) ) - { - return true; - } - - final String gidPattern = toWildcard( getGroupId() ); - if ( !ref.getGroupId() - .matches( gidPattern ) ) - { - return false; - } - - final String aidPattern = toWildcard( getArtifactId() ); - return ref.getArtifactId().matches( aidPattern ); - - } - - private String toWildcard( final String val ) - { - return val.replaceAll( "\\.", "\\." ) - .replaceAll( "\\*", ".*" ); - } - - public PropertyContainer getContainer() - { - return container; - } - - public boolean isDirty() - { - return groupId != null || artifactId != null; - } - - public T detach() - { - return (T) new SimpleProjectRef( this ); - } -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java deleted file mode 100644 index 12db8da9..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectVersionRef.java +++ /dev/null @@ -1,366 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.model; - -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; -import org.commonjava.maven.atlas.ident.ref.*; -import org.commonjava.maven.atlas.ident.util.VersionUtils; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; -import org.commonjava.maven.atlas.ident.version.SingleVersion; -import org.commonjava.maven.atlas.ident.version.VersionSpec; -import org.neo4j.graphdb.Node; - -import static org.apache.commons.lang.StringUtils.isEmpty; -import static org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoIdentityUtils.getStringProperty; - -/** - * Reference to a particular release of a project (or module, in terms of Maven builds). A release may contain many artifacts (see {@link NeoArtifactRef}). - * - * @see {@link NeoProjectRef} - * @see {@link NeoArtifactRef} - * - * @author jdcasey - */ -public class NeoProjectVersionRef - extends NeoProjectRef - implements ProjectVersionRef -{ - - private static final long serialVersionUID = 1L; - - // NEVER null - private VersionSpec versionSpec; - - private String versionString; - - public NeoProjectVersionRef( final Node node ) - { - super( node ); - } - - public NeoProjectVersionRef( final ProjectRef ref, final String versionSpec ) - throws InvalidVersionSpecificationException - { - this( ref.getGroupId(), ref.getArtifactId(), versionSpec ); - } - - NeoProjectVersionRef( final String groupId, final String artifactId, final VersionSpec versionSpec, - final String versionString ) - { - super( groupId, artifactId ); - if ( versionSpec == null && versionString == null ) - { - throw new InvalidRefException( - "Version spec AND string cannot both be null for '" + groupId + ":" + artifactId + "'" ); - } - - this.versionString = versionString; - this.versionSpec = versionSpec; - } - - public NeoProjectVersionRef( final String groupId, final String artifactId, final VersionSpec versionSpec ) - { - this( groupId, artifactId, versionSpec, null ); - } - - public NeoProjectVersionRef( final String groupId, final String artifactId, final String versionString ) - throws InvalidVersionSpecificationException - { - this( groupId, artifactId, null, versionString ); - } - - public NeoProjectVersionRef( final ProjectVersionRef ref ) - { - super( ref ); - if ( container == null ) - { - this.versionString = ref.getVersionStringRaw(); - this.versionSpec = ref.getVersionSpecRaw(); - } - else if ( ref instanceof NeoProjectVersionRef ) - { - this.versionString = ((NeoProjectVersionRef)ref).versionString; - this.versionSpec = ((NeoProjectVersionRef)ref).versionSpec; - } - } - - public static ProjectVersionRef parse( final String gav ) - { - final String[] parts = gav.split( ":" ); - if ( parts.length < 3 || isEmpty( parts[0] ) || isEmpty( parts[1] ) || isEmpty( parts[2] ) ) - { - throw new InvalidRefException( - "ProjectVersionRef must contain non-empty groupId, artifactId, AND version. (Given: '" + gav - + "')" ); - } - - return new NeoProjectVersionRef( parts[0], parts[1], parts[2] ); - } - - @Override - public ProjectVersionRef asProjectVersionRef() - { - return NeoProjectVersionRef.class.equals( getClass() ) ? - this : - new NeoProjectVersionRef( this ); - } - - @Override - public ArtifactRef asPomArtifact() - { - return asArtifactRef( "pom", null ); - } - - @Override - public ArtifactRef asJarArtifact() - { - return asArtifactRef( "jar", null ); - } - - @Override - public ArtifactRef asArtifactRef( final String type, final String classifier ) - { - return new NeoArtifactRef( this, type, classifier ); - } - - @Override - public ArtifactRef asArtifactRef( final TypeAndClassifier tc ) - { - NeoTypeAndClassifier ntc = ( tc instanceof NeoTypeAndClassifier ) ? - (NeoTypeAndClassifier) tc : - new NeoTypeAndClassifier( tc.getType(), tc.getClassifier() ); - - return new NeoArtifactRef( this, ntc ); - } - - @Override - public VersionSpec getVersionSpecRaw() - { - return versionSpec; - } - - @Override - public String getVersionStringRaw() - { - String v = getStringProperty( container, Conversions.VERSION, versionString, null ); - return v; - } - - @Override - public boolean isRelease() - { - return getVersionSpec().isRelease(); - } - - @Override - public boolean isSpecificVersion() - { - return getVersionSpec().isSingle(); - } - - @Override - public boolean matchesVersion( final SingleVersion version ) - { - return getVersionSpec().contains( version ); - } - - @Override - public NeoProjectVersionRef selectVersion( final String version ) - { - final SingleVersion single = VersionUtils.createSingleVersion( version ); - return selectVersion( single, false ); - } - - @Override - public NeoProjectVersionRef selectVersion( final String version, final boolean force ) - { - final SingleVersion single = VersionUtils.createSingleVersion( version ); - return selectVersion( single, force ); - } - - @Override - public NeoProjectVersionRef selectVersion( final SingleVersion version ) - { - return selectVersion( version, false ); - } - - @Override - public NeoProjectVersionRef selectVersion( final SingleVersion version, final boolean force ) - { - final VersionSpec versionSpec = getVersionSpec(); - if ( versionSpec.equals( version ) ) - { - return this; - } - - if ( !force && !versionSpec.contains( version ) ) - { - throw new IllegalArgumentException( - "Specified version: " + version.renderStandard() + " is not contained in spec: " - + versionSpec.renderStandard() ); - } - - return newRef( getGroupId(), getArtifactId(), version ); - } - - @Override - public NeoProjectVersionRef newRef( final String groupId, final String artifactId, final SingleVersion version ) - { - return new NeoProjectVersionRef( groupId, artifactId, version ); - } - - @Override - public VersionSpec getVersionSpec() - { - if ( versionSpec == null ) - { - versionSpec = VersionUtils.createFromSpec( getVersionStringRaw() ); - } - return versionSpec; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ( ( getVersionString() == null ) ? 0 : getVersionString().hashCode() ); - return result; - } - - @Override - public boolean versionlessEquals( final ProjectVersionRef other ) - { - return this == other || super.equals( other ); - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( !super.equals( obj ) ) - { - return false; - } - if ( !( obj instanceof ProjectVersionRef ) ) - { - return false; - } - - final ProjectVersionRef other = (ProjectVersionRef) obj; - boolean result = true; - try - { - if ( getVersionSpec() == null ) - { - if ( other.getVersionSpec() != null ) - { - result = false; - } - } - else if ( !getVersionSpec().equals( other.getVersionSpec() ) ) - { - result = false; - } - } - catch ( final InvalidVersionSpecificationException e ) - { - if ( getVersionString() == null ) - { - if ( other.getVersionString() != null ) - { - result = false; - } - } - else if ( !getVersionString().equals( other.getVersionString() ) ) - { - result = false; - } - } - - return result; - } - - @Override - public String toString() - { - String msg = String.format( "%s:%s:%s", getGroupId(), getArtifactId(), getVersionString() ); - return msg; - } - - @Override - public boolean isCompound() - { - return !getVersionSpec().isSingle(); - } - - @Override - public boolean isSnapshot() - { - return getVersionSpec().isSnapshot(); - } - - @Override - public String getVersionString() - { - if ( versionString == null ) - { - String v = getVersionStringRaw(); - if ( v == null ) - { - return versionSpec.renderStandard(); - } - - return v; - } - - return versionString; - } - - @Override - public boolean isVariableVersion() - { - return isCompound() || ( isSpecificVersion() && ( (SingleVersion) getVersionSpec() ).isLocalSnapshot() ); - } - - @Override - public int compareTo( final ProjectRef o ) - { - int comp = super.compareTo( o ); - if ( comp == 0 && ( o instanceof ProjectVersionRef ) ) - { - final ProjectVersionRef or = (ProjectVersionRef) o; - comp = getVersionString().compareTo( or.getVersionString() ); - } - - return comp; - } - - @Override - public boolean isDirty() - { - return super.isDirty() || versionString != null; - } - - @Override - public T detach() - { - return (T) new SimpleProjectVersionRef( this ); - } -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoTypeAndClassifier.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoTypeAndClassifier.java deleted file mode 100644 index d5002d86..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoTypeAndClassifier.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.model; - -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; -import org.commonjava.maven.atlas.ident.ref.SimpleTypeAndClassifier; -import org.commonjava.maven.atlas.ident.ref.TypeAndClassifier; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Relationship; - -import static org.apache.commons.lang.StringUtils.isEmpty; - -public class NeoTypeAndClassifier - implements TypeAndClassifier -{ - private static final long serialVersionUID = 1L; - - private String type; - - private String classifier; - - private Relationship rel; - - public NeoTypeAndClassifier( final String type, final String classifier ) - { - this.type = type == null ? "jar" : type; - this.classifier = isEmpty( classifier ) ? null : classifier; - } - - public NeoTypeAndClassifier( final String type ) - { - this( type, null ); - } - - public NeoTypeAndClassifier() - { - this( null, null ); - } - - public NeoTypeAndClassifier( final Relationship rel ) - { - this.rel = rel; - } - - @Override - public String getType() - { - String t; - if ( rel == null ) - { - t = type; - } - else - { - t = Conversions.getStringProperty( Conversions.TYPE, rel ); - } - - return t == null ? "jar" : t; - } - - @Override - public String getClassifier() - { - if ( rel == null ) - { - return classifier; - } - else - { - return Conversions.getStringProperty( Conversions.CLASSIFIER, rel ); - } - } - - @Override - public String toString() - { - return String.format( "%s%s", type, ( classifier == null ? "" : ":" + classifier ) ); - } - - @Override - // FIXME: Expensive!! - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ( ( getClassifier() == null ) ? 0 : getClassifier().hashCode() ); - result = prime * result + ( ( getType() == null ) ? 0 : getType().hashCode() ); - return result; - } - - @Override - // FIXME: Expensive!! - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( obj == null ) - { - return false; - } - if ( !(obj instanceof TypeAndClassifier) ) - { - return false; - } - final TypeAndClassifier other = (TypeAndClassifier) obj; - if ( getClassifier() == null ) - { - if ( other.getClassifier() != null ) - { - return false; - } - } - else if ( !getClassifier().equals( other.getClassifier() ) ) - { - return false; - } - if ( getType() == null ) - { - if ( other.getType() != null ) - { - return false; - } - } - else if ( !getType().equals( other.getType() ) ) - { - return false; - } - return true; - } - - public boolean isDirty() - { - return type != null || classifier != null; - } - - public TypeAndClassifier detach() - { - return new SimpleTypeAndClassifier( this ); - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java deleted file mode 100644 index 7e7922d5..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoVersionlessArtifactRef.java +++ /dev/null @@ -1,213 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.model; - -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.InvalidRefException; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.SimpleVersionlessArtifactRef; -import org.commonjava.maven.atlas.ident.ref.TypeAndClassifier; -import org.commonjava.maven.atlas.ident.ref.VersionlessArtifactRef; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; - -import static org.apache.commons.lang.StringUtils.isEmpty; - -/** - * Special implementation of {@link NeoArtifactRef} that forces all versions to ZERO, to allow calculation of transitive - * dependency graphs, where version collisions of the same project are likely. - * - * @author jdcasey - */ -public class NeoVersionlessArtifactRef - extends NeoProjectRef - implements VersionlessArtifactRef -{ - - private static final long serialVersionUID = 1L; - - private TypeAndClassifier tc; - - public NeoVersionlessArtifactRef( final ArtifactRef ref ) - { - super( ref.getGroupId(), ref.getArtifactId() ); - this.tc = ref.getTypeAndClassifier(); - } - - public NeoVersionlessArtifactRef( final ProjectRef ref, final String type, final String classifier ) - { - super( ref.getGroupId(), ref.getArtifactId() ); - this.tc = new NeoTypeAndClassifier( type, classifier ); - } - - public NeoVersionlessArtifactRef( final ProjectRef ref, final TypeAndClassifier tc ) - { - super( ref.getGroupId(), ref.getArtifactId() ); - this.tc = tc == null ? new NeoTypeAndClassifier() : tc; - } - - public NeoVersionlessArtifactRef( final String groupId, final String artifactId, final String type, - final String classifier, final boolean optional ) - throws InvalidVersionSpecificationException - { - super( groupId, artifactId ); - this.tc = new NeoTypeAndClassifier( type, classifier ); - } - - @Override - public String toString() - { - return String.format( "%s:%s:%s", getGroupId(), getArtifactId(), getTypeAndClassifier() ); - } - - public static VersionlessArtifactRef parse( final String spec ) - { - final String[] parts = spec.split( ":" ); - - if ( parts.length < 2 || isEmpty( parts[0] ) || isEmpty( parts[1] ) ) - { - throw new InvalidRefException( - "VersionlessArtifactRef must contain AT LEAST non-empty groupId and artifactId. (Given: '" + spec - + "')" ); - } - - final String g = parts[0]; - final String a = parts[1]; - - String t = "pom"; - String c = null; - - if ( parts.length > 2 ) - { - // we probably have a type in there. - t = parts[2]; - - if ( parts.length > 3 ) - { - // we have a classifier? What if it's GATV?? - // assume it's just a classifier... - c = parts[3]; - - if ( parts.length > 4 ) - { - // okay, wtf? It's a GATVC, and we need to shift to eliminate the V... - c = parts[4]; - } - } - } - - // assume non-optional, because it might not matter if you're parsing a string like this...you'd be more careful if you were reading something - // that had an optional field, because it's not in the normal GATV[C] spec. - return new NeoVersionlessArtifactRef( g, a, t, c, false ); - } - - @Override - public String getType() - { - return tc.getType(); - } - - @Override - public String getClassifier() - { - return tc.getClassifier(); - } - - @Override - public TypeAndClassifier getTypeAndClassifier() - { - return tc; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ( ( tc == null ) ? 0 : tc.hashCode() ); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( !super.equals( obj ) ) - { - return false; - } - if ( !( obj instanceof VersionlessArtifactRef ) ) - { - return false; - } - final VersionlessArtifactRef other = (VersionlessArtifactRef) obj; - if ( tc == null ) - { - if ( other.getTypeAndClassifier() != null ) - { - return false; - } - } - else if ( !tc.equals( other.getTypeAndClassifier() ) ) - { - return false; - } - return true; - } - - @Override - public VersionlessArtifactRef asVersionlessPomArtifact() - { - return asVersionlessArtifactRef( "pom", null ); - } - - @Override - public VersionlessArtifactRef asVersionlessJarArtifact() - { - return asVersionlessArtifactRef( "jar", null ); - } - - @Override - public VersionlessArtifactRef asVersionlessArtifactRef( final String type, final String classifier ) - { - final TypeAndClassifier tc = new NeoTypeAndClassifier( type, classifier ); - if ( NeoVersionlessArtifactRef.class.equals( getClass() ) && this.tc.equals( tc ) ) - { - return this; - } - - return super.asVersionlessArtifactRef( type, classifier ); - } - - @Override - public VersionlessArtifactRef asVersionlessArtifactRef( final TypeAndClassifier tc ) - { - if ( NeoVersionlessArtifactRef.class.equals( getClass() ) && this.tc.equals( tc ) ) - { - return this; - } - - return super.asVersionlessArtifactRef( tc ); - } - - @Override - public T detach() - { - return (T) new SimpleVersionlessArtifactRef( this ); - } -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AbstractTraverseVisitor.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AbstractTraverseVisitor.java deleted file mode 100644 index 35e7cb27..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AbstractTraverseVisitor.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; - -import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; -import org.neo4j.graphdb.Path; -import org.neo4j.graphdb.Relationship; - -public abstract class AbstractTraverseVisitor - implements TraverseVisitor -{ - - @Override - public void configure( final AtlasCollector collector ) - { - } - - @Override - public boolean isEnabledFor( final Path path ) - { - return true; - } - - @Override - public void cycleDetected( final CyclePath path, final Relationship injector ) - { - } - - @Override - public boolean includeChildren( final Path path, final Neo4jGraphPath graphPath, final GraphPathInfo pathInfo ) - { - return true; - } - - @Override - public void includingChild( final Relationship child, final Neo4jGraphPath childPath, - final GraphPathInfo childPathInfo, final Path parentPath ) - { - } - - @Override - public void traverseComplete( final AtlasCollector collector ) - { - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java deleted file mode 100644 index 94bfd037..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasCollector.java +++ /dev/null @@ -1,283 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; - -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.toProjectRelationship; -import static org.commonjava.maven.atlas.graph.spi.neo4j.traverse.TraversalUtils.accepted; - -import java.util.Collections; -import java.util.Set; -import java.util.TreeSet; - -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; -import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; -import org.commonjava.maven.atlas.graph.spi.neo4j.GraphAdmin; -import org.commonjava.maven.atlas.graph.spi.neo4j.GraphRelType; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; -import org.commonjava.maven.atlas.graph.spi.neo4j.update.CycleCacheUpdater; -import org.commonjava.maven.atlas.ident.util.JoinString; -import org.neo4j.graphdb.Direction; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Path; -import org.neo4j.graphdb.PathExpander; -import org.neo4j.graphdb.Relationship; -import org.neo4j.graphdb.traversal.BranchState; -import org.neo4j.graphdb.traversal.Evaluation; -import org.neo4j.graphdb.traversal.Evaluator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public final class AtlasCollector - implements Evaluator, PathExpander -{ - - private final Logger logger = LoggerFactory.getLogger( getClass() ); - - private Direction direction = Direction.OUTGOING; - - private final Set startNodes; - - private ViewParams view; - - private TraverseVisitor visitor; - - private GraphAdmin admin; - - private boolean useSelections = true; - - private Node viewNode; - - private GraphRelType[] types; - - private RelationshipGraphConnection connection; - - public AtlasCollector( final TraverseVisitor visitor, final Node start, - final RelationshipGraphConnection connection, final ViewParams view, final Node viewNode, - final GraphAdmin admin, final GraphRelType... types ) - { - this( visitor, Collections.singleton( start ), connection, view, viewNode, admin ); - this.types = types; - } - - public AtlasCollector( final TraverseVisitor visitor, final Set startNodes, - final RelationshipGraphConnection connection, final ViewParams view, final Node viewNode, - final GraphAdmin admin, final GraphRelType... types ) - { - this.visitor = visitor; - this.connection = connection; - this.viewNode = viewNode; - this.admin = admin; - this.types = types; - visitor.configure( this ); - - this.startNodes = startNodes; - - this.view = view; - } - - public AtlasCollector( final TraverseVisitor visitor, final Set startNodes, - final RelationshipGraphConnection connection, final ViewParams view, final Node viewNode, - final GraphAdmin admin, final GraphRelType[] types, final Direction direction ) - { - this( visitor, startNodes, connection, view, viewNode, admin, types ); - this.direction = direction; - } - - public void setUseSelections( final boolean useSelections ) - { - this.useSelections = useSelections; - } - - @Override - @SuppressWarnings( "rawtypes" ) - public final Iterable expand( final Path path, final BranchState state ) - { - if ( !visitor.isEnabledFor( path ) ) - { - logger.debug( "Disabled, NOT expanding: {}", path ); - return Collections.emptySet(); - } - - if ( !startNodes.isEmpty() ) - { - final Node startNode = path.startNode(); - if ( !startNodes.contains( startNode ) ) - { - logger.debug( "Rejecting path; it does not start with one of our roots:\n\t{}", path ); - return Collections.emptySet(); - } - } - - final Neo4jGraphPath graphPath = new Neo4jGraphPath( path ); - - GraphPathInfo pathInfo = new GraphPathInfo( connection, view ); - // if we're here, we're pre-cleared to blindly construct this pathInfo (see child iteration below) - for ( final Long rid : graphPath ) - { - final Relationship r = admin.getRelationship( rid ); - pathInfo = pathInfo.getChildPathInfo( toProjectRelationship( r ) ); - } - - logger.debug( "For {}, using pathInfo: {}", graphPath, pathInfo ); - - final CyclePath cyclePath = CycleCacheUpdater.getTerminatingCycle( path ); - if ( cyclePath != null ) - { - final Relationship injector = path.lastRelationship(); - logger.debug( "Detected cycle in progress for path: {} at relationship: {}\n Cycle path is: {}", path, - injector, cyclePath ); - - visitor.cycleDetected( cyclePath, injector ); - } - - // logger.debug( "Checking hasSeen for graphPath: {} with pathInfo: {} (actual path: {})", graphPath, pathInfo, path ); - // if ( visitor.hasSeen( graphPath, pathInfo ) ) - // { - // logger.debug( "Already seen: {} (path: {})", graphPath, path ); - // return Collections.emptySet(); - // } - // split this so we register both the seen and the cycle. - /*else*/if ( cyclePath != null ) - { - return Collections.emptySet(); - } - - if ( returnChildren( path, graphPath, pathInfo ) ) - { - - // final ProjectRelationshipFilter nextFilter = pathInfo.getFilter(); - // log( "Implementation says return the children of: {}\n lastRel={}\n nextFilter={}\n\n", - // path.endNode() - // .hasProperty( GAV ) ? path.endNode() - // .getProperty( GAV ) : "Unknown", path.lastRelationship(), nextFilter ); - - final Set nextRelationships = new TreeSet( new AtlasRelIndexComparator() ); - - GraphRelType[] childTypes = types; - final ProjectRelationshipFilter filter = pathInfo.getFilter(); - if ( filter != null ) - { - childTypes = TraversalUtils.getGraphRelTypes( filter ); - } - - logger.debug( "Getting relationships from node: {} with type in [{}] and direction: {} (path: {})", - path.endNode(), new JoinString( ", ", childTypes ), direction, path ); - - final Iterable relationships = path.endNode() - .getRelationships( direction, childTypes ); - - // logger.info( "{} Determining which of {} child relationships to expand traversal into for: {}\n{}", getClass().getName(), path.length(), - // path.endNode() - // .hasProperty( GAV ) ? path.endNode() - // .getProperty( GAV ) : "Unknown", new JoinString( "\n ", Thread.currentThread() - // .getStackTrace() ) ); - - for ( Relationship r : relationships ) - { - logger.debug( "Analyzing child relationship for traversal potential: {}", r ); - - if ( useSelections ) - { - final Relationship selected = admin.select( r, view, viewNode, pathInfo, graphPath ); - if ( selected == null ) - { - logger.debug( "selection failed for: {} at {}. Likely, this is filter rejection from: {}", r, - graphPath, pathInfo ); - continue; - } - - // if no selection happened and r is a selection-only relationship, skip it. - if ( selected == r && admin.isSelection( r, viewNode ) ) - { - logger.debug( "{} is NOT the result of selection, yet it is marked as a selection relationship. Path: {}", - r, path ); - continue; - } - - if ( !accepted( selected, view ) ) - { - logger.debug( "{} NOT accepted, likely due to incompatible POM location or source URI. Path: {}", - r, path ); - continue; - } - - if ( selected != null ) - { - r = selected; - } - - logger.debug( "After selection, using child relationship: {}", r ); - } - - final ProjectRelationship rel = toProjectRelationship( r ); - - final Neo4jGraphPath nextPath = new Neo4jGraphPath( graphPath, r ); - final GraphPathInfo nextPathInfo = pathInfo.getChildPathInfo( rel ); - - logger.debug( "Including child: {} with next-path: {} and childPathInfo: {} from parent path: {}", r, - nextPath, nextPathInfo, path ); - visitor.includingChild( r, nextPath, nextPathInfo, path ); - - logger.debug( "+= {}", wrap( r ) ); - nextRelationships.add( r ); - } - - return nextRelationships; - } - - logger.debug( "children not being returned for: {}", path ); - return Collections.emptySet(); - } - - public boolean returnChildren( final Path path, final Neo4jGraphPath graphPath, final GraphPathInfo pathInfo ) - { - // if there's a GraphPathInfo mapped for this path, then it was accepted during expansion. - return visitor.includeChildren( path, graphPath, pathInfo ); - } - - private Object wrap( final Relationship r ) - { - return new Object() - { - @Override - public String toString() - { - return r + " " + String.valueOf( toProjectRelationship( r ) ); - } - }; - } - - @Override - public final Evaluation evaluate( final Path path ) - { - return Evaluation.INCLUDE_AND_CONTINUE; - } - - @Override - public PathExpander reverse() - { - final AtlasCollector collector = - new AtlasCollector( visitor, startNodes, connection, view, viewNode, admin, types, - direction.reverse() ); - collector.setUseSelections( useSelections ); - - return collector; - } -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasRelIndexComparator.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasRelIndexComparator.java deleted file mode 100644 index 1b30be7c..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/AtlasRelIndexComparator.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; - -import java.util.Comparator; - -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; -import org.neo4j.graphdb.Relationship; - -public class AtlasRelIndexComparator - implements Comparator -{ - - @Override - public int compare( final Relationship f, final Relationship s ) - { - final int fidx = Conversions.getIntegerProperty( Conversions.ATLAS_RELATIONSHIP_INDEX, f, 0 ); - final int sidx = Conversions.getIntegerProperty( Conversions.ATLAS_RELATIONSHIP_INDEX, s, 0 ); - - final int comp = fidx - sidx; - if ( comp < 0 ) - { - return -1; - } - else if ( comp > 0 ) - { - return 1; - } - - return comp; - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java deleted file mode 100644 index a498bd88..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/MembershipWrappedTraversalEvaluator.java +++ /dev/null @@ -1,250 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; - -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.toProjectRelationship; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; -import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; -import org.commonjava.maven.atlas.graph.spi.neo4j.GraphAdmin; -import org.commonjava.maven.atlas.graph.spi.neo4j.GraphRelType; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; -import org.commonjava.maven.atlas.graph.traverse.RelationshipGraphTraversal; -import org.neo4j.graphdb.Direction; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Path; -import org.neo4j.graphdb.PathExpander; -import org.neo4j.graphdb.Relationship; -import org.neo4j.graphdb.traversal.BranchState; -import org.neo4j.graphdb.traversal.Evaluation; -import org.neo4j.graphdb.traversal.Evaluator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class MembershipWrappedTraversalEvaluator - implements Evaluator, PathExpander -{ - - private final Logger logger = LoggerFactory.getLogger( getClass() ); - - private final Set rootIds; - - private final RelationshipGraphTraversal traversal; - - private boolean reversedExpander; - - private final ViewParams view; - - private final GraphAdmin admin; - - private final Node viewNode; - - private final GraphRelType[] types; - - private final RelationshipGraphConnection connection; - - public MembershipWrappedTraversalEvaluator( final Set rootIds, final RelationshipGraphTraversal traversal, - final RelationshipGraphConnection connection, final ViewParams view, - final Node viewNode, final GraphAdmin admin, - final GraphRelType... types ) - { - this.rootIds = rootIds; - this.traversal = traversal; - this.connection = connection; - this.view = view; - this.viewNode = viewNode; - this.admin = admin; - this.types = types; - } - - private MembershipWrappedTraversalEvaluator( final MembershipWrappedTraversalEvaluator ev, final boolean reversedExpander ) - { - this.rootIds = ev.rootIds; - this.traversal = ev.traversal; - this.connection = ev.connection; - this.view = ev.view; - this.admin = ev.admin; - this.viewNode = ev.viewNode; - this.types = ev.types; - this.reversedExpander = reversedExpander; - } - - @Override - public Evaluation evaluate( final Path path ) - { - final Relationship rel = path.lastRelationship(); - if ( rel == null ) - { - // logger.info( "MISSING last-relationship: {}. exclude and continue", rel ); - return Evaluation.EXCLUDE_AND_CONTINUE; - } - - final Set roots = rootIds; - if ( roots == null || roots.isEmpty() || roots.contains( path.startNode() - .getId() ) ) - { - final ProjectRelationship lastRel = Conversions.toProjectRelationship( rel ); - - final List> relPath = new ArrayList>(path.length()); - relPath.addAll( Conversions.convertToRelationships( path.relationships() ) ); - - if ( relPath.indexOf( lastRel ) == relPath.size() - 1 ) - { - // logger.warn( "\n\n\n\n\nREMOVING last-relationship: {} from path!\n\n\n\n\n" ); - relPath.remove( relPath.size() - 1 ); - } - - if ( traversal.preCheck( lastRel, relPath ) ) - { - logger.debug( "Include-and-continue: {}, {}", relPath, lastRel ); - return Evaluation.INCLUDE_AND_CONTINUE; - } - else - { - logger.debug( "exclude-and-prune: {}, {}", relPath, lastRel ); - } - } - - // logger.info( "exclude and prune" ); - return Evaluation.EXCLUDE_AND_PRUNE; - } - - @Override - public Iterable expand( final Path path, final BranchState state ) - { - final Node node = path.endNode(); - // logger.info( "START expansion for: {}", path ); - - // TODO: Is node(0) appropriate to see?? - final Set roots = rootIds; - if ( node.getId() != 0 && roots != null && roots.isEmpty() && !roots.contains( path.startNode() - .getId() ) ) - { - // logger.info( "{} not in membership. Skipping expansion.", node ); - return Collections.emptySet(); - } - - final Neo4jGraphPath graphPath = new Neo4jGraphPath( path ); - GraphPathInfo pathInfo = new GraphPathInfo( connection, view ); - for ( final Long rid : graphPath ) - { - final Relationship r = admin.getRelationship( rid ); - pathInfo = pathInfo.getChildPathInfo( toProjectRelationship( r ) ); - } - - GraphRelType[] childTypes = types; - final ProjectRelationshipFilter filter = pathInfo.getFilter(); - if ( filter != null ) - { - childTypes = TraversalUtils.getGraphRelTypes( filter ); - } - - final Iterable rs = - node.getRelationships( reversedExpander ? Direction.INCOMING : Direction.OUTGOING, childTypes ); - - if ( rs == null ) - { - // logger.info( "No relationships from end-node: {}", node ); - return Collections.emptySet(); - } - - // sort the child relationships to make the traversal deterministic - final Set result = new TreeSet( new AtlasRelIndexComparator() ); - - final List> rels = getPathRelationships( path ); - - // logger.info( "For: {} Determining which of {} child relationships to expand traversal into for: {}\n{}", traversal.getClass() - // .getName(), path.length(), - // path.endNode() - // .hasProperty( GAV ) ? path.endNode() - // .getProperty( GAV ) : "Unknown", new JoinString( "\n ", Thread.currentThread() - // .getStackTrace() ) ); - - for ( Relationship r : rs ) - { - if ( Conversions.getBooleanProperty( Conversions.CYCLES_INJECTED, r, false ) ) - { - continue; - } - - final Relationship selected = admin.select( r, view, viewNode, pathInfo, graphPath ); - - // if no selection happened and r is a selection-only relationship, skip it. - if ( ( selected == null || selected == r ) && admin.isSelection( r, viewNode ) ) - { - continue; - } - - if ( selected != null ) - { - r = selected; - } - // logger.info( "Attempting to expand: {}", r ); - - final ProjectRelationship projectRel = Conversions.toProjectRelationship( r ); - - logger.debug( "Pre-checking relationship {} for expansion using filter: {}", projectRel, traversal ); - if ( traversal.preCheck( projectRel, rels ) ) - { - logger.debug( "Adding for expansion: {}", projectRel ); - result.add( r ); - } - else - { - logger.debug( "Skipping for expansion: {}", projectRel ); - } - } - - logger.debug( "Expanding for {} relationships.", result.size() ); - return result; - } - - private List> getPathRelationships( final Path path ) - { - List> rels = new ArrayList>(path.length()); - final Iterable rs = path.relationships(); - if ( rs != null ) - { - rels.addAll( Conversions.convertToRelationships( rs ) ); - // logger.info( "Got relationship list {} entries long for filter", rels.size() ); - } - - if ( reversedExpander ) - { - // logger.info( "Reversing relationship list for filter." ); - Collections.reverse( rels ); - } - - return rels; - } - - @Override - public PathExpander reverse() - { - return new MembershipWrappedTraversalEvaluator( this, true ); - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/NodePair.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/NodePair.java deleted file mode 100644 index 7c4dfd65..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/NodePair.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; - -import org.neo4j.graphdb.Node; - -public final class NodePair -{ - private final long from; - - private final long to; - - public NodePair( final Node from, final Node to ) - { - this.from = from.getId(); - this.to = to.getId(); - } - - public long getFrom() - { - return from; - } - - public long getTo() - { - return to; - } - - @Override - public boolean equals( final Object other ) - { - if ( other == this ) - { - return true; - } - if ( !( other instanceof NodePair ) ) - { - return false; - } - final NodePair o = (NodePair) other; - - return o.from == from && o.to == to; - } - - @Override - public int hashCode() - { - final int result = (int) ( 1337133713 * from / to ); - - return result; - } - - @Override - public String toString() - { - return String.format( "NodePair %d -> %d (%d)", from, to, hashCode() ); - } -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathCollectingVisitor.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathCollectingVisitor.java deleted file mode 100644 index 3166a1ba..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathCollectingVisitor.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Path; - -public class PathCollectingVisitor - extends AbstractTraverseVisitor - implements Iterable -{ - - private final Set ends; - - private final Set paths = new HashSet(); - - public PathCollectingVisitor( final Set ends ) - { - this.ends = ends; - } - - public Set getPaths() - { - return paths; - } - - @Override - public boolean includeChildren( final Path path, final Neo4jGraphPath graphPath, final GraphPathInfo pathInfo ) - { - if ( ends.contains( path.endNode() ) ) - { - paths.add( graphPath ); - return false; - } - - return true; - } - - @Override - public Iterator iterator() - { - return paths.iterator(); - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathExistenceVisitor.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathExistenceVisitor.java deleted file mode 100644 index 66896f98..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/PathExistenceVisitor.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; - -import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Path; -import org.neo4j.graphdb.Relationship; - -public class PathExistenceVisitor - extends AbstractTraverseVisitor -{ - - private final Node end; - - private boolean found = false; - - public PathExistenceVisitor( final Node end ) - { - this.end = end; - } - - public boolean isFound() - { - return found; - } - - @Override - public boolean isEnabledFor( final Path path ) - { - return !found; - } - - @Override - public void includingChild( final Relationship child, final Neo4jGraphPath childPath, - final GraphPathInfo childPathInfo, final Path parentPath ) - { - final Node end = child.getEndNode(); - if ( this.end.getId() == end.getId() ) - { - found = true; - } - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/RootedRelationshipsVisitor.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/RootedRelationshipsVisitor.java deleted file mode 100644 index 55c6d182..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/RootedRelationshipsVisitor.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.GraphRelType; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; -import org.neo4j.graphdb.Path; -import org.neo4j.graphdb.Relationship; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RootedRelationshipsVisitor - extends AbstractTraverseVisitor - implements Iterable> -{ - - private final Logger logger = LoggerFactory.getLogger( getClass() ); - - private final Set> found = new HashSet>(); - - public Set> getRelationships() - { - return found; - } - - @Override - public Iterator> iterator() - { - return found.iterator(); - } - - @Override - public boolean includeChildren( final Path path, final Neo4jGraphPath graphPath, final GraphPathInfo pathInfo ) - { - for ( final Relationship r : path.relationships() ) - { - if ( r.getType() == GraphRelType.PARENT && r.getStartNode() - .getId() == r.getEndNode() - .getId() ) - { - logger.debug( "Skipping self-referential parent relationship to: {}", r.getStartNode() - .getProperty( Conversions.GAV ) ); - } - else - { - found.add( Conversions.toProjectRelationship( r ) ); - } - } - - return true; - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/SubPathsCollectingVisitor.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/SubPathsCollectingVisitor.java deleted file mode 100644 index ae380146..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/SubPathsCollectingVisitor.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.spi.neo4j.GraphAdmin; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; -import org.neo4j.graphdb.Path; -import org.neo4j.graphdb.Relationship; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SubPathsCollectingVisitor - extends AbstractTraverseVisitor - implements Iterable -{ - - private final Logger logger = LoggerFactory.getLogger( getClass() ); - - private final Set viaNodes; - - private final Set paths = new HashSet(); - - private final GraphAdmin admin; - - public SubPathsCollectingVisitor( final Set viaNodes, final GraphAdmin admin ) - { - this.viaNodes = viaNodes; - this.admin = admin; - } - - @Override - public Iterator iterator() - { - return paths.iterator(); - } - - public Set getSubPaths() - { - return paths; - } - - @Override - public boolean includeChildren( final Path path, final Neo4jGraphPath graphPath, final GraphPathInfo pathInfo ) - { - if ( path.length() > 1 ) - { - final Neo4jGraphPath gp = new Neo4jGraphPath( path ); - final long[] allRids = gp.getRelationshipIds(); - int i = 0; - Relationship start = null; - for ( ; i < allRids.length; i++ ) - { - start = admin.getRelationship( allRids[i] ); - if ( viaNodes.contains( start.getEndNode() - .getId() ) ) - { - logger.debug( "found via-node ending: {}", start ); - break; - } - } - - if ( start != null && i < allRids.length - 1 ) - { - final long[] rids = new long[allRids.length - i]; - System.arraycopy( allRids, i, rids, 0, rids.length ); - - final Relationship last = admin.getRelationship( allRids[allRids.length - 1] ); - paths.add( new Neo4jGraphPath( start.getStartNode(), last.getEndNode(), rids ) ); - } - } - - return true; - } - - @Override - public void configure( final AtlasCollector collector ) - { - collector.setUseSelections( false ); - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java deleted file mode 100644 index cf619c52..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraversalUtils.java +++ /dev/null @@ -1,173 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; - -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.POM_LOCATION_URI; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.SOURCE_URI; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.getURIProperty; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.getURISetProperty; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.toProjectRelationship; -import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.POM_ROOT_URI; -import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.UNKNOWN_SOURCE_URI; - -import java.net.URI; -import java.util.HashSet; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.graph.spi.neo4j.GraphRelType; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; -import org.neo4j.graphdb.Relationship; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public final class TraversalUtils -{ - - private static final Logger logger = LoggerFactory.getLogger( TraversalUtils.class ); - - private TraversalUtils() - { - } - - // public static boolean acceptedInView( final Path path, final GraphView view, final ConversionCache cache ) - // { - // ProjectRelationshipFilter f = view.getFilter(); - // final GraphWorkspace ws = view.getWorkspace(); - // - // for ( final Relationship r : path.relationships() ) - // { - // if ( !accepted( r, f, ws, cache ) ) - // { - // return false; - // } - // - // if ( f != null ) - // { - // final ProjectRelationship rel = toProjectRelationship( r, cache ); - // f = f.getChildFilter( rel ); - // } - // } - // - // debug( "ACCEPT: Path: {}", path ); - // return true; - // } - - public static boolean acceptedInView( final Relationship r, final ViewParams view ) - { - return accepted( r, view ); - } - - public static boolean accepted( final Relationship r, final ViewParams view ) - { - final ProjectRelationship rel = toProjectRelationship( r ); - - debug( "Checking relationship for acceptance: {} ({})", r, rel ); - - final Set sources = view.getActiveSources(); - if ( sources != null && !sources.isEmpty() ) - { - if ( !sources.contains( RelationshipUtils.ANY_SOURCE_URI ) ) - { - final Set s = getURISetProperty( SOURCE_URI, r, UNKNOWN_SOURCE_URI ); - boolean found = false; - for ( final URI uri : s ) - { - // TODO: What are the default sources anyway?? any:any?? - if ( /*sources == GraphWorkspace.DEFAULT_SOURCES ||*/sources.contains( uri ) ) - { - found = true; - break; - } - } - - if ( !found ) - { - debug( "REJECTED: Found relationship in path with de-selected source-repository URI: {} (r={}, permissable sources: {})", - s, r, sources ); - return false; - } - } - } - - final Set pomLocations = view.getActivePomLocations(); - if ( pomLocations != null && !pomLocations.isEmpty() ) - { - final URI pomLocation = getURIProperty( POM_LOCATION_URI, r, POM_ROOT_URI ); - if ( !pomLocations.contains( pomLocation ) ) - { - debug( "REJECTED: Found relationship in path with de-selected pom-location URI: {}", r ); - return false; - } - } - - final ProjectRelationshipFilter filter = view.getFilter(); - if ( filter != null ) - { - if ( !filter.accept( rel ) ) - { - debug( "Filter: {} REJECTED relationship: {} ({})", filter, r, rel ); - return false; - } - } - - debug( "ACCEPT: {} ({})", r, rel ); - return true; - } - - private static void debug( final String message, final Object... params ) - { - logger.debug( message, params ); - } - - public static GraphRelType[] getGraphRelTypes( final ProjectRelationshipFilter filter ) - { - if ( filter == null ) - { - return GraphRelType.atlasRelationshipTypes(); - } - - final Set result = new HashSet(); - - final Set types = filter.getAllowedTypes(); - for ( final RelationshipType rt : types ) - { - if ( filter.includeManagedRelationships() ) - { - final GraphRelType grt = GraphRelType.map( rt, true ); - if ( grt != null ) - { - result.add( grt ); - } - } - - if ( filter.includeConcreteRelationships() ) - { - final GraphRelType grt = GraphRelType.map( rt, false ); - if ( grt != null ) - { - result.add( grt ); - } - } - } - - return result.toArray( new GraphRelType[result.size()] ); - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraverseVisitor.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraverseVisitor.java deleted file mode 100644 index ba241e12..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/TraverseVisitor.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.traverse; - -import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; -import org.neo4j.graphdb.Path; -import org.neo4j.graphdb.Relationship; - -public interface TraverseVisitor -{ - - /** - * Allow configuration of extra options for this collector as it initializes - * with this visitor. - */ - void configure( AtlasCollector collector ); - - /** - * MUST call this after traverse completes, to allow resource reclamation. - */ - void traverseComplete( AtlasCollector collector ); - - /** - * Allow visitor to turn itself off and skip further traversal of a path. - */ - boolean isEnabledFor( Path path ); - - /** - * Handle detected cycle (which was traversed TO, but not THROUGH). - */ - void cycleDetected( CyclePath cp, Relationship injector ); - - /** - * Whether child edges of the given path should be visited. - */ - boolean includeChildren( Path path, Neo4jGraphPath graphPath, GraphPathInfo pathInfo ); - - /** - * Notice that a child relationship has been included. - * - * @param child The relationship that WILL BE traversed - * @param childPath The {@link Neo4jGraphPath} that will be associated with traversing this child - * @param childPathInfo {@link GraphPathInfo} that will be associated with traversing this child - * @param parentPath parent {@link Path} which will be extended by this child - */ - void includingChild( Relationship child, Neo4jGraphPath childPath, GraphPathInfo childPathInfo, Path parentPath ); - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/LuceneSeenTracker.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/LuceneSeenTracker.java deleted file mode 100644 index dac04a1f..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/LuceneSeenTracker.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.traverse.track; - -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.spi.neo4j.GraphAdmin; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; -import org.commonjava.maven.atlas.graph.spi.neo4j.update.CycleCacheUpdater; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Transaction; -import org.neo4j.graphdb.index.Index; -import org.neo4j.graphdb.index.IndexHits; - -public class LuceneSeenTracker - implements TraverseSeenTracker -{ - - private static final String SEEN_RELS_PREFIX = "_seen_rels_"; - - private static final String KEY = "seen_key"; - - private final GraphAdmin admin; - - private final Index seen; - - private final Node viewNode; - - public LuceneSeenTracker( final ViewParams view, final Node viewNode, final GraphAdmin admin ) - { - this.viewNode = viewNode; - this.seen = admin.getNodeIndex( view.getShortId() + SEEN_RELS_PREFIX + System.currentTimeMillis() ); - this.admin = admin; - } - - @Override - public boolean hasSeen( final Neo4jGraphPath graphPath, final GraphPathInfo pathInfo ) - { - // TODO: This trims the path leading up to the cycle...is that alright?? - - String key; - final CyclePath cyclePath = CycleCacheUpdater.getTerminatingCycle( graphPath, admin ); - if ( cyclePath != null ) - { - key = cyclePath.getKey(); - } - else - { - key = graphPath.getKey(); - } - - key += "#" + pathInfo.getKey(); - final IndexHits hits = seen.get( KEY, key ); - if ( hits.hasNext() ) - { - return true; - } - - final Transaction tx = admin.beginTransaction(); - try - { - seen.add( viewNode, KEY, key ); - tx.success(); - } - finally - { - tx.finish(); - } - - return false; - } - - @Override - public void traverseComplete() - { - final Transaction tx = admin.beginTransaction(); - try - { - seen.delete(); - tx.success(); - } - finally - { - tx.finish(); - } - - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/MemorySeenTracker.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/MemorySeenTracker.java deleted file mode 100644 index 8bad8fcc..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/MemorySeenTracker.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.traverse.track; - -import java.util.HashSet; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.spi.neo4j.GraphAdmin; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; -import org.commonjava.maven.atlas.graph.spi.neo4j.update.CycleCacheUpdater; - -public class MemorySeenTracker - implements TraverseSeenTracker -{ - - private final Set seenKeys = new HashSet(); - - private final GraphAdmin admin; - - public MemorySeenTracker( final GraphAdmin admin ) - { - this.admin = admin; - } - - @Override - public boolean hasSeen( final Neo4jGraphPath graphPath, final GraphPathInfo pathInfo ) - { - // TODO: This trims the path leading up to the cycle...is that alright?? - - String key; - final CyclePath cyclePath = CycleCacheUpdater.getTerminatingCycle( graphPath, admin ); - if ( cyclePath != null ) - { - key = cyclePath.getKey(); - } - else - { - key = graphPath.getKey(); - } - - key += "#" + pathInfo.getKey(); - return !seenKeys.add( key ); - } - - @Override - public void traverseComplete() - { - seenKeys.clear(); - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/TraverseSeenTracker.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/TraverseSeenTracker.java deleted file mode 100644 index 17efe342..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/traverse/track/TraverseSeenTracker.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.traverse.track; - -import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; - -public interface TraverseSeenTracker -{ - - boolean hasSeen( Neo4jGraphPath graphPath, GraphPathInfo pathInfo ); - - void traverseComplete(); - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java deleted file mode 100644 index ad08c938..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/CycleCacheUpdater.java +++ /dev/null @@ -1,216 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.update; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.model.EProjectCycle; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.GraphAdmin; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; -import org.commonjava.maven.atlas.graph.spi.neo4j.traverse.AbstractTraverseVisitor; -import org.commonjava.maven.atlas.graph.spi.neo4j.traverse.AtlasCollector; -import org.commonjava.maven.atlas.ident.util.JoinString; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Path; -import org.neo4j.graphdb.Relationship; -import org.neo4j.graphdb.Transaction; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class CycleCacheUpdater - extends AbstractTraverseVisitor -{ - - private final Logger logger = LoggerFactory.getLogger( getClass() ); - - private final Node viewNode; - - final Set cycles = new HashSet(); - - private final ViewParams view; - - private final GraphAdmin admin; - - public CycleCacheUpdater( final ViewParams view, final Node viewNode, final GraphAdmin admin ) - { - this.view = view; - this.viewNode = viewNode; - this.admin = admin; - } - - @Override - public void cycleDetected( final CyclePath cyclicPath, final Relationship injector ) - { - if ( cyclicPath.length() < 1 ) - { - logger.debug( "No paths in cycle!" ); - return; - } - - addCycleInternal( cyclicPath, injector ); - } - - public void addCycle( final CyclePath cyclicPath, final Relationship injector ) - { - if ( cyclicPath.length() < 1 ) - { - logger.debug( "No paths in cycle!" ); - return; - } - - addCycleInternal( cyclicPath, injector ); - } - - private void addCycleInternal( final CyclePath cyclicPath, final Relationship injector ) - { - final Transaction tx = admin.beginTransaction(); - try - { - logger.debug( "Adding cycle: {} (via: {})", cyclicPath, injector ); - Conversions.storeCachedCyclePath( cyclicPath, viewNode ); - - final List> cycle = new ArrayList>(cyclicPath.length()); - cycle.addAll( Conversions.convertToRelationships( cyclicPath, admin ) ); - logger.info( "CYCLES += {\n {}\n}", new JoinString( "\n ", cycle ) ); - cycles.add( new EProjectCycle( cycle ) ); - - tx.success(); - } - finally - { - tx.finish(); - } - } - - public static CyclePath getTerminatingCycle( final Path path ) - { - final Logger logger = LoggerFactory.getLogger( CycleCacheUpdater.class ); - logger.debug( "Looking for terminating cycle in: {}", path ); - - final List rids = new ArrayList(); - final List starts = new ArrayList(); - for ( final Relationship pathR : path.relationships() ) - { - rids.add( pathR.getId() ); - - final long sid = pathR.getStartNode() - .getId(); - - final long eid = pathR.getEndNode() - .getId(); - - final int idx = starts.indexOf( eid ); - if ( idx > -1 ) - { - final CyclePath cp = new CyclePath( rids.subList( idx, rids.size() ) ); - logger.debug( "Detected cycle: {}", cp ); - - return cp; - } - - starts.add( sid ); - } - - logger.debug( "No cycle detected" ); - - return null; - } - - public static CyclePath getTerminatingCycle( final Neo4jGraphPath graphPath, final GraphAdmin admin ) - { - final Logger logger = LoggerFactory.getLogger( CycleCacheUpdater.class ); - logger.debug( "Looking for terminating cycle in: {}", graphPath ); - - final Map startNodesToRids = new HashMap(); - final long[] rids = graphPath.getRelationshipIds(); - Long startRid = null; - for ( final long rid : rids ) - { - final Relationship r = admin.getRelationship( rid ); - - final long eid = r.getEndNode() - .getId(); - - startRid = startNodesToRids.get( eid ); - if ( startRid != null ) - { - break; - } - - startNodesToRids.put( r.getStartNode() - .getId(), r.getId() ); - } - - if ( startRid != null ) - { - int i = 0; - for ( ; i < rids.length; i++ ) - { - if ( rids[i] == startRid ) - { - break; - } - } - - final long[] cycle = new long[rids.length - i]; - System.arraycopy( rids, i, cycle, 0, cycle.length ); - - final CyclePath cp = new CyclePath( cycle ); - logger.debug( "Detected cycle: {}", cp ); - return cp; - } - - logger.debug( "No cycle detected" ); - - return null; - } - - public int getCycleCount() - { - return cycles.size(); - } - - public Set getCycles() - { - return cycles; - } - - @Override - public void traverseComplete( final AtlasCollector collector ) - { - final Transaction tx = admin.beginTransaction(); - try - { - logger.info( "Clearing PENDING cycle-detection for: {} of view: {}", viewNode, view.getShortId() ); - Conversions.setCycleDetectionPending( viewNode, false ); - tx.success(); - } - finally - { - tx.finish(); - } - } - -} diff --git a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java b/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java deleted file mode 100644 index 46b245d4..00000000 --- a/drivers/neo4j-embedded/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/update/ViewUpdater.java +++ /dev/null @@ -1,235 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.update; - -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.NID; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.RID; - -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.GraphAdmin; -import org.commonjava.maven.atlas.graph.spi.neo4j.ViewIndexes; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.CyclePath; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.Neo4jGraphPath; -import org.commonjava.maven.atlas.graph.spi.neo4j.traverse.AbstractTraverseVisitor; -import org.commonjava.maven.atlas.graph.spi.neo4j.traverse.AtlasCollector; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Path; -import org.neo4j.graphdb.Relationship; -import org.neo4j.graphdb.Transaction; -import org.neo4j.graphdb.index.Index; -import org.neo4j.graphdb.index.IndexHits; -import org.neo4j.graphdb.index.RelationshipIndex; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ViewUpdater - extends AbstractTraverseVisitor -{ - - private final Logger logger = LoggerFactory.getLogger( getClass() ); - - private final Node viewNode; - - private final GraphAdmin admin; - - private final CycleCacheUpdater cycleUpdater; - - private final ViewIndexes indexes; - - private Node stopNode; - - public ViewUpdater( final ViewParams view, final Node viewNode, final ViewIndexes indexes, - final GraphAdmin admin ) - { - this.viewNode = viewNode; - this.indexes = indexes; - this.admin = admin; - this.cycleUpdater = new CycleCacheUpdater( view, viewNode, admin ); - } - - public ViewUpdater( final Node stopNode, final ViewParams view, final Node viewNode, final ViewIndexes indexes, - final GraphAdmin admin ) - { - this.stopNode = stopNode; - this.viewNode = viewNode; - this.indexes = indexes; - this.admin = admin; - this.cycleUpdater = new CycleCacheUpdater( view, viewNode, admin ); - } - - public void cacheRoots( final Set roots ) - { - final Transaction tx = admin.beginTransaction(); - try - { - final Index cachedNodes = indexes.getCachedNodes(); - for ( final Node node : roots ) - { - cachedNodes.add( node, NID, node.getId() ); - } - tx.success(); - } - finally - { - tx.finish(); - } - } - - public boolean processAddedRelationships( final Map> createdRelationshipsMap ) - { - for ( final Entry> entry : createdRelationshipsMap.entrySet() ) - { - final Long rid = entry.getKey(); - final Relationship add = admin.getRelationship( rid ); - - // TODO: WTF is the point of this?? - // indexes.getSelections() - // .remove( add ); - // - - final Transaction tx = admin.beginTransaction(); - try - { - logger.debug( "Checking node cache for: {}", add.getStartNode() ); - final IndexHits hits = indexes.getCachedNodes() - .get( NID, add.getStartNode() - .getId() ); - if ( hits.hasNext() ) - { - Conversions.setMembershipDetectionPending( viewNode, true ); - Conversions.setCycleDetectionPending( viewNode, true ); - - tx.success(); - return true; - } - } - finally - { - tx.finish(); - } - } - - return false; - } - - @Override - public void includingChild( final Relationship child, final Neo4jGraphPath childPath, final GraphPathInfo childPathInfo, final Path parentPath ) - { - cachePath( childPath, childPathInfo ); - } - - @Override - public void configure( final AtlasCollector collector ) - { - cycleUpdater.configure( collector ); - } - - private void cachePath( final Neo4jGraphPath path, final GraphPathInfo pathInfo ) - { - final CyclePath cyclePath = CycleCacheUpdater.getTerminatingCycle( path, admin ); - if ( cyclePath != null ) - { - // logger.info( "CYCLE: {}", cyclePath ); - - final Relationship injector = admin.getRelationship( path.getLastRelationshipId() ); - cycleUpdater.addCycle( cyclePath, injector ); - - return; - } - - final Transaction tx = admin.beginTransaction(); - try - { - logger.debug( "Caching path: {}", path ); - - final RelationshipIndex cachedRels = indexes.getCachedRelationships(); - final Index cachedNodes = indexes.getCachedNodes(); - - final Set nodes = new HashSet(); - for ( final Long relId : path ) - { - final Relationship r = admin.getRelationship( relId ); - - logger.debug( "rel-membership += " + relId ); - cachedRels.add( r, RID, relId ); - - final long startId = r.getStartNode() - .getId(); - if ( nodes.add( startId ) ) - { - logger.debug( "node-membership += " + startId ); - cachedNodes.add( r.getStartNode(), NID, startId ); - } - - final long endId = r.getEndNode() - .getId(); - if ( nodes.add( endId ) ) - { - logger.debug( "node-membership += " + endId ); - cachedNodes.add( r.getEndNode(), NID, endId ); - } - } - tx.success(); - } - finally - { - tx.finish(); - } - } - - @Override - public void cycleDetected( final CyclePath path, final Relationship injector ) - { - cycleUpdater.cycleDetected( path, injector ); - } - - @Override - public boolean includeChildren( final Path path, final Neo4jGraphPath graphPath, final GraphPathInfo pathInfo ) - { - return !( stopNode != null && path.endNode().getId() == stopNode.getId() ); - - } - - @Override - public void traverseComplete( final AtlasCollector collector ) - { - if ( stopNode == null ) - { - final Transaction tx = admin.beginTransaction(); - try - { - // we did a complete traversal. - Conversions.setMembershipDetectionPending( viewNode, false ); - tx.success(); - } - finally - { - tx.finish(); - } - - cycleUpdater.traverseComplete( collector ); - } - } - -} diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectRelationshipSerializerModuleTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectRelationshipSerializerModuleTest.java deleted file mode 100644 index 6c9fb8e8..00000000 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectRelationshipSerializerModuleTest.java +++ /dev/null @@ -1,359 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.io; - -import static org.junit.Assert.*; -import static org.hamcrest.CoreMatchers.*; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import org.commonjava.maven.atlas.graph.jackson.ProjectRelationshipSerializerModule; -import org.commonjava.maven.atlas.graph.rel.BomRelationship; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleBomRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleExtensionRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.rel.SimplePluginDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.GraphRelType; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoBomRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoDependencyRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoExtensionRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoParentRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoPluginDependencyRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoPluginRelationship; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.jackson.ProjectVersionRefSerializerModule; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Relationship; -import org.neo4j.graphdb.Transaction; -import org.neo4j.graphdb.factory.GraphDatabaseFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * Created by jdcasey on 8/26/15. - */ -public class NeoProjectRelationshipSerializerModuleTest -{ - private static final String WORKSPACE = "workspace"; - - private static final URI TEST_URI; - - static - { - URI u; - try - { - u = new URI( "test:location" ); - } - catch ( URISyntaxException e ) - { - Logger logger = LoggerFactory.getLogger( NeoProjectRelationshipSerializerModuleTest.class ); - logger.error( "Failed to construct test URI", e ); - u = null; - } - - TEST_URI = u; - } - - @Rule - public TemporaryFolder temp = new TemporaryFolder(); - - private ObjectMapper mapper; - - private GraphDatabaseService graph; - - @Before - public void before() - throws Exception - { - mapper = new ObjectMapper(); - mapper.registerModules( ProjectVersionRefSerializerModule.INSTANCE, - NeoSpecificProjectVersionRefSerializerModule.INSTANCE, - ProjectRelationshipSerializerModule.INSTANCE, - NeoSpecificProjectRelationshipSerializerModule.INSTANCE ); - - mapper.setSerializationInclusion( JsonInclude.Include.NON_EMPTY ); - mapper.configure( JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT, true ); - - mapper.enable( SerializationFeature.INDENT_OUTPUT, SerializationFeature.USE_EQUALITY_FOR_OBJECT_ID ); - - mapper.enable( MapperFeature.AUTO_DETECT_FIELDS ); - // disable( MapperFeature.AUTO_DETECT_GETTERS ); - - mapper.disable( SerializationFeature.WRITE_NULL_MAP_VALUES, SerializationFeature.WRITE_EMPTY_JSON_ARRAYS ); - - mapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES ); - - graph = new GraphDatabaseFactory().newEmbeddedDatabase( temp.newFolder( "db" ).getAbsolutePath() ); - } - - @After - public void after() - { - if ( graph != null ) - { - graph.shutdown(); - } - } - - @Test - public void roundTripParentRelationship() - throws Exception - { - ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); - - ParentRelationship rel = - new SimpleParentRelationship( pvr ); - - String json = mapper.writeValueAsString( rel ); - - Relationship r = store( rel ); - - NeoParentRelationship result = new NeoParentRelationship( r ); - - String njson = mapper.writeValueAsString( result ); - - assertThat( njson, equalTo( json ) ); - - ParentRelationship deser = mapper.readValue( njson, ParentRelationship.class ); - assertThat( deser, equalTo( rel ) ); - } - - @Test - public void roundTripDependencyRelationship() - throws Exception - { - ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); - ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); - - DependencyRelationship rel = new SimpleDependencyRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2.asJarArtifact(), - DependencyScope.compile, 0, false, false, false ); - - String json = mapper.writeValueAsString( rel ); - - Relationship r = store( rel ); - - NeoDependencyRelationship result = new NeoDependencyRelationship( r ); - - String njson = mapper.writeValueAsString( result ); - - assertThat( njson, equalTo( json ) ); - - DependencyRelationship deser = mapper.readValue( njson, DependencyRelationship.class ); - assertThat( deser, equalTo( rel ) ); - } - - private Relationship store( final ProjectRelationship rel ) - { - Relationship r; - Transaction tx = graph.beginTx(); - try - { - Node start = graph.createNode(); - Conversions.toNodeProperties( rel.getDeclaring(), start, true ); - Node end = graph.createNode(); - Conversions.toNodeProperties( rel.getTarget(), end, false ); - - r = start.createRelationshipTo( end, GraphRelType.map( rel.getType(), rel.isManaged() ) ); - Conversions.toRelationshipProperties( rel, r ); - - tx.success(); - } - finally - { - tx.finish(); - } - - return r; - } - - @Test - public void roundTripExtensionRelationship() - throws Exception - { - ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); - ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); - - ExtensionRelationship rel = new SimpleExtensionRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0, false ); - - String json = mapper.writeValueAsString( rel ); - - Relationship r = store( rel ); - - NeoExtensionRelationship result = new NeoExtensionRelationship( r ); - - String njson = mapper.writeValueAsString( result ); - - assertThat( njson, equalTo( json ) ); - - ExtensionRelationship deser = mapper.readValue( njson, ExtensionRelationship.class ); - assertThat( deser, equalTo( rel ) ); - } - - @Test - public void roundTripBomRelationship() - throws Exception - { - ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); - ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); - - BomRelationship rel = new SimpleBomRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0, false, false ); - - String json = mapper.writeValueAsString( rel ); - - Relationship r = store( rel ); - - NeoBomRelationship result = new NeoBomRelationship( r ); - - String njson = mapper.writeValueAsString( result ); - - assertThat( njson, equalTo( json ) ); - - BomRelationship deser = mapper.readValue( njson, BomRelationship.class ); - assertThat( deser, equalTo( rel ) ); - } - - @Test - public void roundTripPluginRelationship() - throws Exception - { - ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); - ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); - - PluginRelationship rel = new SimplePluginRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0, false, false ); - - String json = mapper.writeValueAsString( rel ); - - Relationship r = store( rel ); - - NeoPluginRelationship result = new NeoPluginRelationship( r ); - - String njson = mapper.writeValueAsString( result ); - - assertThat( njson, equalTo( json ) ); - - PluginRelationship deser = mapper.readValue( njson, PluginRelationship.class ); - assertThat( deser, equalTo( rel ) ); - } - - @Test - public void roundTripPluginDependencyRelationship() - throws Exception - { - ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); - ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); - ProjectRef pr = new SimpleProjectRef( "org.foo", "plugin" ); - - PluginDependencyRelationship rel = new SimplePluginDependencyRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pr, pvr2.asJarArtifact(), 0, false, false ); - - String json = mapper.writeValueAsString( rel ); - - Relationship r = store( rel ); - - NeoPluginDependencyRelationship result = new NeoPluginDependencyRelationship( r ); - - String njson = mapper.writeValueAsString( result ); - - assertThat( njson, equalTo( json ) ); - - PluginDependencyRelationship deser = mapper.readValue( njson, PluginDependencyRelationship.class ); - assertThat( deser, equalTo( rel ) ); - } - - @Test - public void roundTripMixedList() - throws Exception - { - ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); - ProjectVersionRef dep = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); - ProjectVersionRef bom = new SimpleProjectVersionRef( "org.foo", "bom", "1.0" ); - ProjectVersionRef ext = new SimpleProjectVersionRef( "org.foo", "ext", "1.0" ); - ProjectVersionRef plug = new SimpleProjectVersionRef( "org.foo", "plug", "1.0" ); - ProjectVersionRef pdep = new SimpleProjectVersionRef( "org.foo", "pdep", "1.0" ); - ProjectVersionRef parent = new SimpleProjectVersionRef( "org.foo", "parent", "1.0" ); - ProjectRef pr = new SimpleProjectRef( "org.foo", "plugin" ); - - List> rels = Arrays.> asList( - new SimpleParentRelationship( TEST_URI, pvr, parent ), - new SimpleDependencyRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, dep.asJarArtifact(), - DependencyScope.compile, 0, false, false, false ), - new SimpleBomRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, ext, 0, false, false ), - new SimpleExtensionRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, ext, 0, false ), - new SimplePluginRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, plug, 0, false, false ), - new SimplePluginDependencyRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pr, - pdep.asJarArtifact(), 0, false, false ) ); - - String json = mapper.writeValueAsString( rels ); - - List rs = new ArrayList(); - for ( ProjectRelationship rel : rels ) - { - rs.add( store( rel ) ); - } - - int i=0; - List> nrels = Arrays.>asList( - new NeoParentRelationship( rs.get( i++ ) ), - new NeoDependencyRelationship( rs.get(i++) ), - new NeoBomRelationship( rs.get(i++) ), - new NeoExtensionRelationship( rs.get(i++) ), - new NeoPluginRelationship( rs.get(i++) ), - new NeoPluginDependencyRelationship( rs.get(i++) ) - ); - - String njson = mapper.writeValueAsString( nrels ); - - assertThat( njson, equalTo( json ) ); - - List> deser = mapper.readValue( njson, - new TypeReference>>() - { - } ); - assertThat( deser, equalTo( rels ) ); - } - -} diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectVersionRefSerializerModuleTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectVersionRefSerializerModuleTest.java deleted file mode 100644 index 71385a37..00000000 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/io/NeoProjectVersionRefSerializerModuleTest.java +++ /dev/null @@ -1,202 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.io; - -import static org.junit.Assert.*; -import static org.hamcrest.CoreMatchers.*; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import org.apache.commons.io.IOUtils; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.graph.spi.neo4j.FileNeo4JGraphConnection; -import org.commonjava.maven.atlas.graph.spi.neo4j.FileNeo4jConnectionFactory; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoArtifactRef; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoProjectRef; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoProjectVersionRef; -import org.commonjava.maven.atlas.graph.spi.neo4j.model.NeoTypeAndClassifier; -import org.commonjava.maven.atlas.ident.jackson.ProjectVersionRefSerializerModule; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleTypeAndClassifier; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Transaction; -import org.neo4j.graphdb.factory.GraphDatabaseFactory; - -import java.io.File; -import java.io.IOException; - -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.GA; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.GAV; -import static org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions.toNodeProperties; - -/** - * Created by jdcasey on 8/26/15. - */ -public class NeoProjectVersionRefSerializerModuleTest -{ - private static final String WORKSPACE = "workspace"; - - @Rule - public TemporaryFolder temp = new TemporaryFolder(); - - private ObjectMapper mapper; - - private GraphDatabaseService graph; - - @Before - public void before() - throws Exception - { - mapper = new ObjectMapper(); - mapper.registerModules( ProjectVersionRefSerializerModule.INSTANCE, - NeoSpecificProjectVersionRefSerializerModule.INSTANCE ); - - mapper.setSerializationInclusion( JsonInclude.Include.NON_EMPTY ); - mapper.configure( JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT, true ); - - mapper.enable( SerializationFeature.INDENT_OUTPUT, SerializationFeature.USE_EQUALITY_FOR_OBJECT_ID ); - - mapper.enable( MapperFeature.AUTO_DETECT_FIELDS ); - // disable( MapperFeature.AUTO_DETECT_GETTERS ); - - mapper.disable( SerializationFeature.WRITE_NULL_MAP_VALUES, SerializationFeature.WRITE_EMPTY_JSON_ARRAYS ); - - mapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES ); - - graph = new GraphDatabaseFactory().newEmbeddedDatabase( temp.newFolder( "db" ).getAbsolutePath() ); - } - - @After - public void after() - { - if ( graph != null ) - { - graph.shutdown(); - } - } - - @Test - public void roundTripArtifactRef() - throws IOException - { - ArtifactRef aref = new SimpleArtifactRef( new SimpleProjectVersionRef( "org.foo", "bar", "1" ), - new SimpleTypeAndClassifier( "jar", null ) ); - - String json = mapper.writeValueAsString( aref ); - - Transaction tx = graph.beginTx(); - Node node; - try - { - node = graph.createNode(); - Conversions.toNodeProperties( aref, node, true ); - tx.success(); - } - finally - { - tx.finish(); - } - - NeoArtifactRef naref = new NeoArtifactRef( node, new NeoTypeAndClassifier( "jar" ) ); - String njson = mapper.writeValueAsString( naref ); - - assertThat( njson, equalTo( json ) ); - - ArtifactRef deser = mapper.readValue( njson, ArtifactRef.class ); - assertThat( deser, equalTo( aref ) ); - } - - @Test - public void roundTripProjectVersionRef() - throws IOException - { - ProjectVersionRef ref = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); - - String json = mapper.writeValueAsString( ref ); - - Transaction tx = graph.beginTx(); - Node node; - try - { - node = graph.createNode(); - Conversions.toNodeProperties( ref, node, true ); - tx.success(); - } - finally - { - tx.finish(); - } - - NeoProjectVersionRef naref = new NeoProjectVersionRef( node ); - String njson = mapper.writeValueAsString( naref ); - - assertThat( njson, equalTo( json ) ); - - ProjectVersionRef deser = mapper.readValue( njson, ProjectVersionRef.class ); - assertThat( deser, equalTo( ref ) ); - } - - @Test - public void roundTripProjectRef() - throws IOException - { - ProjectRef aref = new SimpleProjectRef( "org.foo", "bar" ); - ProjectVersionRef pvr = new SimpleProjectVersionRef( aref.getGroupId(), aref.getArtifactId(), "1" ); - - String json = mapper.writeValueAsString( aref ); - - Transaction tx = graph.beginTx(); - Node node; - try - { - node = graph.createNode(); - Conversions.toNodeProperties( pvr, node, true ); - tx.success(); - } - finally - { - tx.finish(); - } - - NeoProjectRef naref = new NeoProjectRef( node ); - String njson = mapper.writeValueAsString( naref ); - - assertThat( njson, equalTo( json ) ); - - ProjectRef deser = mapper.readValue( njson, ProjectRef.class ); - assertThat( deser, equalTo( aref ) ); - } - -} diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java deleted file mode 100644 index 80e2917e..00000000 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoIdentitiesTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.model; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.NeoSpecificProjectVersionRefSerializerModule; -import org.commonjava.maven.atlas.ident.jackson.ProjectVersionRefSerializerModule; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Transaction; -import org.neo4j.graphdb.factory.GraphDatabaseFactory; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -/** - * Created by jdcasey on 8/28/15. - */ -public class NeoIdentitiesTest -{ - - private static final String WORKSPACE = "workspace"; - - @Rule - public TemporaryFolder temp = new TemporaryFolder(); - - private GraphDatabaseService graph; - - @Before - public void before() - throws Exception - { - graph = new GraphDatabaseFactory().newEmbeddedDatabase( temp.newFolder( "db" ).getAbsolutePath() ); - } - - @After - public void after() - { - if ( graph != null ) - { - graph.shutdown(); - } - } - - @Test - public void projectRefCrossImplEquality() - { - ProjectRef aref = new SimpleProjectRef( "org.foo", "bar" ); - Node node = toNode( new SimpleProjectVersionRef( aref.getGroupId(), aref.getArtifactId(), "1" ) ); - - NeoProjectRef naref = new NeoProjectRef( node ); - - assertThat( naref, equalTo( aref ) ); - } - - @Test - public void projectVersionRefCrossImplEquality() - { - ProjectVersionRef aref = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); - Node node = toNode( aref ); - - NeoProjectVersionRef naref = new NeoProjectVersionRef( node ); - - assertThat( naref, equalTo( aref ) ); - } - - @Test - public void artifactRefCrossImplEquality() - { - ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); - ArtifactRef aref = new SimpleArtifactRef( pvr, "jar", null ); - Node node = toNode( aref ); - - NeoArtifactRef naref = new NeoArtifactRef( node, new NeoTypeAndClassifier( "jar" ) ); - - assertThat( naref, equalTo( aref ) ); - } - - private Node toNode( final ProjectVersionRef pvr ) - { - Transaction tx = graph.beginTx(); - Node node; - try - { - node = graph.createNode(); - Conversions.toNodeProperties( pvr, node, true ); - tx.success(); - } - finally - { - tx.finish(); - } - - return node; - } -} diff --git a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRelationshipEqualitiesTest.java b/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRelationshipEqualitiesTest.java deleted file mode 100644 index 6904b5fa..00000000 --- a/drivers/neo4j-embedded/src/test/java/org/commonjava/maven/atlas/graph/spi/neo4j/model/NeoProjectRelationshipEqualitiesTest.java +++ /dev/null @@ -1,282 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.model; - -import org.commonjava.maven.atlas.graph.rel.BomRelationship; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleBomRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleExtensionRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.rel.SimplePluginDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; -import org.commonjava.maven.atlas.graph.spi.neo4j.GraphRelType; -import org.commonjava.maven.atlas.graph.spi.neo4j.io.Conversions; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Relationship; -import org.neo4j.graphdb.Transaction; -import org.neo4j.graphdb.factory.GraphDatabaseFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -/** - * Created by jdcasey on 8/26/15. - */ -public class NeoProjectRelationshipEqualitiesTest -{ - private static final URI TEST_URI; - - static - { - URI u; - try - { - u = new URI( "test:location" ); - } - catch ( URISyntaxException e ) - { - Logger logger = LoggerFactory.getLogger( NeoProjectRelationshipEqualitiesTest.class ); - logger.error( "Failed to construct test URI", e ); - u = null; - } - - TEST_URI = u; - } - - @Rule - public TemporaryFolder temp = new TemporaryFolder(); - - private GraphDatabaseService graph; - - @Before - public void before() - throws Exception - { - graph = new GraphDatabaseFactory().newEmbeddedDatabase( temp.newFolder( "db" ).getAbsolutePath() ); - } - - @After - public void after() - { - if ( graph != null ) - { - graph.shutdown(); - } - } - - @Test - public void parentRelationshipEq() - throws Exception - { - ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); - - ParentRelationship rel = - new SimpleParentRelationship( pvr ); - - Relationship r = store( rel ); - - NeoParentRelationship result = new NeoParentRelationship( r ); - assertThat( result, equalTo( rel ) ); - } - - @Test - public void dependencyRelationshipEq() - throws Exception - { - ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); - ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); - - DependencyRelationship rel = new SimpleDependencyRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2.asJarArtifact(), - DependencyScope.compile, 0, false, false, false ); - - Relationship r = store( rel ); - - NeoDependencyRelationship result = new NeoDependencyRelationship( r ); - assertThat( result, equalTo( rel ) ); - } - - private Relationship store( final ProjectRelationship rel ) - { - Relationship r; - Transaction tx = graph.beginTx(); - try - { - Node start = graph.createNode(); - Conversions.toNodeProperties( rel.getDeclaring(), start, true ); - Node end = graph.createNode(); - Conversions.toNodeProperties( rel.getTarget(), end, false ); - - r = start.createRelationshipTo( end, GraphRelType.map( rel.getType(), rel.isManaged() ) ); - Conversions.toRelationshipProperties( rel, r ); - - tx.success(); - } - finally - { - tx.finish(); - } - - return r; - } - - @Test - public void extensionRelationshipEq() - throws Exception - { - ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); - ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); - - ExtensionRelationship rel = new SimpleExtensionRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0, false ); - - Relationship r = store( rel ); - - NeoExtensionRelationship result = new NeoExtensionRelationship( r ); - assertThat( result, equalTo( rel ) ); - } - - @Test - public void bomRelationshipEq() - throws Exception - { - ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); - ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); - - BomRelationship rel = new SimpleBomRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0, false, false ); - - Relationship r = store( rel ); - - NeoBomRelationship result = new NeoBomRelationship( r ); - assertThat( result, equalTo( rel ) ); - } - - @Test - public void pluginRelationshipEq() - throws Exception - { - ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); - ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); - - PluginRelationship rel = new SimplePluginRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pvr2, 0, false, false ); - - Relationship r = store( rel ); - - NeoPluginRelationship result = new NeoPluginRelationship( r ); - assertThat( result, equalTo( rel ) ); - } - - @Test - public void pluginDependencyRelationshipEq() - throws Exception - { - ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); - ProjectVersionRef pvr2 = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); - ProjectRef pr = new SimpleProjectRef( "org.foo", "plugin" ); - - PluginDependencyRelationship rel = new SimplePluginDependencyRelationship(TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pr, pvr2.asJarArtifact(), 0, false, false ); - - Relationship r = store( rel ); - - NeoPluginDependencyRelationship result = new NeoPluginDependencyRelationship( r ); - assertThat( result, equalTo( rel ) ); - } - - @Test - public void mixedSetContains() - throws Exception - { - ProjectVersionRef pvr = new SimpleProjectVersionRef( "org.foo", "bar", "1" ); - ProjectVersionRef dep = new SimpleProjectVersionRef( "org.foo", "dep", "1.0" ); - ProjectVersionRef bom = new SimpleProjectVersionRef( "org.foo", "bom", "1.0" ); - ProjectVersionRef ext = new SimpleProjectVersionRef( "org.foo", "ext", "1.0" ); - ProjectVersionRef plug = new SimpleProjectVersionRef( "org.foo", "plug", "1.0" ); - ProjectVersionRef pdep = new SimpleProjectVersionRef( "org.foo", "pdep", "1.0" ); - ProjectVersionRef parent = new SimpleProjectVersionRef( "org.foo", "parent", "1.0" ); - ProjectRef pr = new SimpleProjectRef( "org.foo", "plugin" ); - - List> rels = Arrays.> asList( - new SimpleParentRelationship( TEST_URI, pvr, parent ), - new SimpleDependencyRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, dep.asJarArtifact(), - DependencyScope.compile, 0, false, false, false ), - new SimpleBomRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, bom, 0, false, false ), - new SimpleExtensionRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, ext, 0, false ), - new SimplePluginRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, plug, 0, false, false ), - new SimplePluginDependencyRelationship( TEST_URI, RelationshipUtils.POM_ROOT_URI, pvr, pr, - pdep.asJarArtifact(), 0, false, false ) ); - - List rs = new ArrayList(); - for ( ProjectRelationship rel : rels ) - { - rs.add( store( rel ) ); - } - - int i=0; - List> nrels = new ArrayList>(); - Logger logger = LoggerFactory.getLogger( getClass() ); - logger.info("Adding parent, i={}", i); - nrels.add( new NeoParentRelationship( rs.get( i++ ) ) ); - logger.info( "Adding dep, i={}", i ); - nrels.add( new NeoDependencyRelationship( rs.get( i++ ) ) ); - logger.info( "Adding bom, i={}", i ); - nrels.add( new NeoBomRelationship( rs.get( i++ ) ) ); - logger.info( "Adding ext, i={}", i ); - nrels.add( new NeoExtensionRelationship( rs.get( i++ ) ) ); - logger.info( "Adding plugin, i={}", i ); - nrels.add( new NeoPluginRelationship( rs.get( i++ ) ) ); - logger.info( "Adding plugin-dep, i={}", i ); - nrels.add( new NeoPluginDependencyRelationship( rs.get( i++ ) ) ); - logger.info( "Added all, i={}", i ); - - List> missing = new ArrayList>(); - for ( ProjectRelationship rel: nrels ) - { - if ( !rels.contains( rel ) ) - { - missing.add( rel ); - } - } - - assertThat( "Neo-specific relationships not found in original set: " + missing, missing.isEmpty(), - equalTo( true ) ); - - } - -} diff --git a/drivers/pom.xml b/drivers/pom.xml deleted file mode 100644 index 53ac1742..00000000 --- a/drivers/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - 4.0.0 - - - org.commonjava.maven.atlas - atlas-parent - 0.16.3-SNAPSHOT - - - atlas-drivers-parent - pom - - Atlas :: Maven Project-Graph :: Drivers Parent - - - - org.commonjava.maven.atlas - atlas-relationships-api - - - - - neo4j-embedded - jung - - diff --git a/ftests/jung/pom.xml b/ftests/jung/pom.xml deleted file mode 100644 index b5e50f5f..00000000 --- a/ftests/jung/pom.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - 4.0.0 - - - org.commonjava.maven.atlas - atlas-ftests-parent - 0.16.3-SNAPSHOT - - - atlas-ftests-jung - - Atlas :: Maven Project-Graph :: Jung Functional Tests - - - - org.commonjava.maven.atlas - atlas-driver-jung - - - net.sf.jung - jung-graph-impl - - - - diff --git a/ftests/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/fixture/JungTCKDriver.java b/ftests/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/fixture/JungTCKDriver.java deleted file mode 100644 index 24709477..00000000 --- a/ftests/jung/src/main/java/org/commonjava/maven/atlas/graph/spi/jung/fixture/JungTCKDriver.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.jung.fixture; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.graph.spi.jung.JungGraphConnectionFactory; -import org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver; -import org.junit.rules.TemporaryFolder; - -import java.io.IOException; - -/** - * Created by jdcasey on 8/24/15. - */ -public class JungTCKDriver - implements TCKDriver -{ - private TemporaryFolder temp; - - private JungGraphConnectionFactory factory; - - @Override - public void setup( TemporaryFolder temp ) - throws Exception - { - this.temp = temp; - } - - @Override - public RelationshipGraphConnectionFactory getConnectionFactory() - throws Exception - { - if ( factory == null ) - { - factory = new JungGraphConnectionFactory(); - } - - return factory; - } - - @Override - public void close() - throws IOException - { - if ( factory != null ) - { - factory.close(); - } - } -} diff --git a/ftests/jung/src/main/resources/META-INF/services/org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver b/ftests/jung/src/main/resources/META-INF/services/org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver deleted file mode 100644 index 309992dd..00000000 --- a/ftests/jung/src/main/resources/META-INF/services/org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver +++ /dev/null @@ -1 +0,0 @@ -org.commonjava.maven.atlas.graph.spi.jung.fixture.JungTCKDriver \ No newline at end of file diff --git a/ftests/jung/src/main/resources/logback-test.xml b/ftests/jung/src/main/resources/logback-test.xml deleted file mode 100644 index 37e09750..00000000 --- a/ftests/jung/src/main/resources/logback-test.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - - - diff --git a/ftests/neo4j/pom.xml b/ftests/neo4j/pom.xml deleted file mode 100644 index 3850e762..00000000 --- a/ftests/neo4j/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - 4.0.0 - - - org.commonjava.maven.atlas - atlas-ftests-parent - 0.16.3-SNAPSHOT - - - atlas-ftests-neo4j - - Atlas :: Maven Project-Graph :: Neo4J Functional Tests - - - 1C - true - - - - - org.commonjava.maven.atlas - atlas-driver-neo4j-embedded - - - org.neo4j - neo4j - - - commons-codec - commons-codec - - - org.slf4j - log4j-over-slf4j - - - commons-io - commons-io - - - - diff --git a/ftests/neo4j/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/NeoTCKDriver.java b/ftests/neo4j/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/NeoTCKDriver.java deleted file mode 100644 index 42503c25..00000000 --- a/ftests/neo4j/src/main/java/org/commonjava/maven/atlas/graph/spi/neo4j/fixture/NeoTCKDriver.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi.neo4j.fixture; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.graph.spi.neo4j.FileNeo4jConnectionFactory; -import org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver; -import org.junit.rules.TemporaryFolder; - -import java.io.IOException; - -/** - * Created by jdcasey on 8/24/15. - */ -public class NeoTCKDriver - implements TCKDriver -{ - private TemporaryFolder temp; - - private FileNeo4jConnectionFactory factory; - - @Override - public void setup( TemporaryFolder temp ) - throws Exception - { - this.temp = temp; - } - - @Override - public RelationshipGraphConnectionFactory getConnectionFactory() - throws Exception - { - if ( factory == null ) - { - factory = new FileNeo4jConnectionFactory( temp.newFolder( "db", ".dir" ), false ); - } - - return factory; - } - - @Override - public void close() - throws IOException - { - if ( factory != null ) - { - factory.close(); - } - } -} diff --git a/ftests/neo4j/src/main/resources/META-INF/services/org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver b/ftests/neo4j/src/main/resources/META-INF/services/org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver deleted file mode 100644 index 1d15b9b9..00000000 --- a/ftests/neo4j/src/main/resources/META-INF/services/org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver +++ /dev/null @@ -1 +0,0 @@ -org.commonjava.maven.atlas.graph.spi.neo4j.fixture.NeoTCKDriver \ No newline at end of file diff --git a/ftests/neo4j/src/main/resources/logback-test.xml b/ftests/neo4j/src/main/resources/logback-test.xml deleted file mode 100644 index 37e09750..00000000 --- a/ftests/neo4j/src/main/resources/logback-test.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - - - diff --git a/ftests/pom.xml b/ftests/pom.xml deleted file mode 100644 index 82470782..00000000 --- a/ftests/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - 4.0.0 - - - org.commonjava.maven.atlas - atlas-parent - 0.16.3-SNAPSHOT - - - atlas-ftests-parent - pom - - Atlas :: Maven Project-Graph :: Functional Test Parent - - - - org.commonjava.maven.atlas - atlas-relationships-api - - - org.commonjava.maven.atlas - atlas-drivers-tck - compile - - - junit - junit - compile - - - org.hamcrest - hamcrest-core - compile - - - - - neo4j - jung - - - - - - - maven-surefire-plugin - - ${test-forkCount} - false - ${test-redirectOutput} - - **/*TCK.java - - - org.commonjava.maven.atlas:atlas-drivers-tck - - - - - - - diff --git a/pom.xml b/pom.xml index 7956d077..ea568e64 100644 --- a/pom.xml +++ b/pom.xml @@ -65,23 +65,6 @@ atlas-bindings-jackson-relationships 0.16.3-SNAPSHOT - - org.commonjava.maven.atlas - atlas-driver-jung - 0.16.3-SNAPSHOT - - - org.commonjava.maven.atlas - atlas-driver-neo4j-embedded - 0.16.3-SNAPSHOT - - - org.commonjava.maven.atlas - atlas-drivers-tck - 0.16.3-SNAPSHOT - test - - org.commonjava.boms web-commons-bom @@ -89,17 +72,6 @@ import pom - - - org.neo4j - neo4j - 1.9.6 - - - net.sf.jung - jung-graph-impl - 2.0.1 - @@ -149,8 +121,5 @@ identities relationships-api bindings - tck - drivers - ftests diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/AbstractRelationshipGraphListener.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/AbstractRelationshipGraphListener.java deleted file mode 100644 index 53f7e7dd..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/AbstractRelationshipGraphListener.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph; - -import java.util.Collection; - -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; - -public abstract class AbstractRelationshipGraphListener - implements RelationshipGraphListener -{ - - protected AbstractRelationshipGraphListener() - { - } - - @Override - public abstract int hashCode(); - - @Override - public abstract boolean equals( Object other ); - - @Override - public void storing( final RelationshipGraph graph, final Collection> relationships ) - throws RelationshipGraphException - { - // NOP - } - - @Override - public void stored( final RelationshipGraph graph, - final Collection> relationships, - final Collection> rejected ) - throws RelationshipGraphException - { - // NOP - } - - @Override - public void projectError( final RelationshipGraph graph, final ProjectVersionRef ref, - final Throwable error ) - throws RelationshipGraphException - { - // NOP - } - - @Override - public void closing( final RelationshipGraph graph ) - throws RelationshipGraphException - { - // NOP - } - - @Override - public void closed( final RelationshipGraph graph ) - throws RelationshipGraphException - { - // NOP - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java deleted file mode 100644 index b192ed1d..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraph.java +++ /dev/null @@ -1,762 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph; - -import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; -import org.commonjava.maven.atlas.graph.model.EProjectCycle; -import org.commonjava.maven.atlas.graph.model.EProjectDirectRelationships; -import org.commonjava.maven.atlas.graph.model.GraphPath; -import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.mutate.GraphMutator; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; -import org.commonjava.maven.atlas.graph.traverse.RelationshipGraphTraversal; -import org.commonjava.maven.atlas.graph.traverse.TraversalType; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.Closeable; -import java.io.IOException; -import java.net.URI; -import java.util.*; - -import static org.apache.commons.lang.StringUtils.join; - -public final class RelationshipGraph - implements Closeable -{ - - private final Logger logger = LoggerFactory.getLogger( getClass() ); - - private static final String GROUP_ID = "groupId"; - - private static final String ARTIFACT_ID = "artifactId"; - - private static final String VERSION = "version"; - - private List listeners; - - private final ViewParams params; - - private RelationshipGraphConnection connection; - - // if we didn't have a user, we wouldn't have constructed this thing! - private int userCount = 1; - - RelationshipGraph( final ViewParams params, final RelationshipGraphConnection driver ) - { - this.params = params; - this.connection = driver; - - getConnectionInternal().registerView( params ); - } - - public ViewParams getParams() - { - return params; - } - - public void storeProjectError( final ProjectVersionRef ref, final Throwable error ) - throws RelationshipGraphException - { - getConnectionInternal().addProjectError( ref, String.format( "%s\n%s", error.getMessage(), - join( error.getStackTrace(), "\n " ) ) ); - - for ( final RelationshipGraphListener listener : listeners ) - { - listener.projectError( this, ref, error ); - } - } - - public String getProjectError( final ProjectVersionRef ref ) - { - return getConnectionInternal().getProjectError( ref ); - } - - public boolean hasProjectError( final ProjectVersionRef ref ) - { - return getConnectionInternal().hasProjectError( ref ); - } - - public void clearProjectError( final ProjectVersionRef ref ) - throws RelationshipGraphException - { - getConnectionInternal().clearProjectError( ref ); - } - - public Set> storeRelationships( final ProjectRelationship... relationships ) - throws RelationshipGraphException - { - final List> rels = Arrays.asList( relationships ); - - for ( final RelationshipGraphListener listener : listeners ) - { - listener.storing( this, rels ); - } - - final Set> rejected = getConnectionInternal().addRelationships( relationships ); - - for ( final RelationshipGraphListener listener : listeners ) - { - listener.stored( this, rels, rejected ); - } - - return rejected; - } - - public Set> storeRelationships( - final Collection> relationships ) - throws RelationshipGraphException - { - for ( final RelationshipGraphListener listener : listeners ) - { - listener.storing( this, relationships ); - } - - final Set> rejected = getConnectionInternal().addRelationships( - relationships.toArray( new ProjectRelationship[relationships.size()] ) ); - - for ( final RelationshipGraphListener listener : listeners ) - { - listener.stored( this, relationships, rejected ); - } - - return rejected; - } - - public void addListener( final RelationshipGraphListener listener ) - { - if ( listeners == null ) - { - listeners = new ArrayList(); - } - - listeners.add( listener ); - } - - public void removeListener( final RelationshipGraphListener listener ) - { - if ( listeners != null ) - { - listeners.remove( listener ); - } - } - - synchronized void incrementGraphOwnership() - { - userCount++; - logger.info( "User count incremented to: {} for: {}", userCount, params ); - } - - public synchronized void forceClose() - throws RelationshipGraphException - { - logger.info( "Closing: {}", params ); - - if ( listeners != null ) - { - for ( final RelationshipGraphListener listener : listeners ) - { - listener.closing( this ); - } - } - - connection = null; - - if ( listeners != null ) - { - for ( final RelationshipGraphListener listener : listeners ) - { - listener.closed( this ); - } - } - } - - @Override - public synchronized void close() - throws IOException - { - userCount--; - logger.info( "User count decremented to: {} for: {}", userCount, params ); - - if ( userCount < 1 ) - { - try - { - forceClose(); - } - catch ( final RelationshipGraphException e ) - { - throw new IOException( "Failed to close graph.", e ); - } - } - else - { - logger.info( "NOT closing; there are other users registered!" ); - } - } - - // +++ IMPORTED FROM EProjectWeb... - - public Set> getAllRelationships() - { - return new HashSet>( getConnectionInternal().getAllRelationships( params ) ); - } - - public boolean isComplete() - { - return !getConnectionInternal().hasMissingProjects( params ); - } - - public boolean isConcrete() - { - return !getConnectionInternal().hasVariableProjects( params ); - } - - public Set getIncompleteSubgraphs() - { - return Collections.unmodifiableSet( getConnectionInternal().getMissingProjects( params ) ); - } - - public Set getVariableSubgraphs() - { - return Collections.unmodifiableSet( getConnectionInternal().getVariableProjects( params ) ); - } - - public Set> add( final EProjectDirectRelationships rels ) - throws RelationshipGraphException - { - return addAll( rels.getAllRelationships() ); - } - - public boolean add( final ProjectRelationship rel ) - throws RelationshipGraphException - { - if ( rel == null ) - { - return false; - } - - return getConnectionInternal().addRelationships( rel ).isEmpty(); - } - - public > Set addAll( final Collection rels ) - throws RelationshipGraphException - { - if ( rels == null ) - { - return null; - } - - final Set result = new HashSet( rels ); - - final Set> rejected = - getConnectionInternal().addRelationships( rels.toArray( new ProjectRelationship[rels.size()] ) ); - result.removeAll( rejected ); - - if ( !result.isEmpty() ) - { - getConnectionInternal().recomputeIncompleteSubgraphs(); - } - - return result; - } - - public > Set addAll( final T... rels ) - throws RelationshipGraphException - { - if ( rels == null ) - { - return null; - } - - final Set result = new HashSet(); - for ( final T rel : rels ) - { - if ( add( rel ) ) - { - result.add( rel ); - } - } - - getConnectionInternal().recomputeIncompleteSubgraphs(); - - return result; - } - - public void traverse( final ProjectVersionRef start, final RelationshipGraphTraversal traversal, - final TraversalType type ) - throws RelationshipGraphException - { - getConnectionInternal().traverse( traversal, start, this, type ); - } - - public void traverse( final ProjectVersionRef start, final RelationshipGraphTraversal traversal ) - throws RelationshipGraphException - { - traverse( start, traversal, TraversalType.breadth_first ); - } - - public void traverse( final RelationshipGraphTraversal traversal, final TraversalType type ) - throws RelationshipGraphException - { - for ( final ProjectVersionRef root : params.getRoots() ) - { - getConnectionInternal().traverse( traversal, root, this, type ); - } - } - - public void traverse( final RelationshipGraphTraversal traversal ) - throws RelationshipGraphException - { - traverse( traversal, TraversalType.breadth_first ); - } - - public Set> getUserRelationships( final ProjectVersionRef ref ) - { - if ( !getConnectionInternal().containsProject( params, ref ) ) - { - return Collections.emptySet(); - } - - return new HashSet>( getConnectionInternal().getRelationshipsTargeting( params, ref ) ); - } - - public Set> getDirectRelationships( final ProjectVersionRef ref ) - { - if ( !getConnectionInternal().containsProject( params, ref ) ) - { - return Collections.emptySet(); - } - - return new HashSet>( getConnectionInternal().getRelationshipsDeclaredBy( params, ref ) ); - } - - public Set getRoots() - { - return params.getRoots(); - } - - public Set> getExactAllRelationships() - { - return getAllRelationships(); - } - - public boolean isCycleParticipant( final ProjectVersionRef ref ) - { - return getConnectionInternal().isCycleParticipant( params, ref ); - } - - public boolean isCycleParticipant( final ProjectRelationship rel ) - { - return getConnectionInternal().isCycleParticipant( params, rel ); - } - - public void addCycle( final EProjectCycle cycle ) - throws RelationshipGraphException - { - getConnectionInternal().addCycle( cycle ); - } - - public Set getCycles() - { - return getConnectionInternal().getCycles( params ); - } - - public Set> getRelationshipsTargeting( final ProjectVersionRef ref ) - { - final Collection> rels = - getConnectionInternal().getRelationshipsTargeting( params, ref.asProjectVersionRef() ); - if ( rels == null ) - { - return Collections.emptySet(); - } - - return new HashSet>( rels ); - } - - public RelationshipGraphConnection getDatabase() - { - return connection; - } - - public Set getAllProjects() - { - return getConnectionInternal().getAllProjects( params ); - } - - public void addMetadata( final ProjectVersionRef ref, final String name, final String value ) - throws RelationshipGraphException - { - getConnectionInternal().addMetadata( ref, name, value ); - } - - public void addMetadata( final ProjectVersionRef ref, final Map metadata ) - throws RelationshipGraphException - { - getConnectionInternal().setMetadata( ref, metadata ); - } - - public Set getProjectsWithMetadata( final String key ) - { - return getConnectionInternal().getProjectsWithMetadata( params, key ); - } - - public void reindex() - throws RelationshipGraphException - { - getConnectionInternal().reindex(); - } - - public void reindex( final ProjectVersionRef ref ) - throws RelationshipGraphConnectionException - { - getConnectionInternal().reindex( ref ); - } - - public Set>> getPathsTo( final ProjectVersionRef... projectVersionRefs ) - { - return getConnectionInternal().getAllPathsTo( params, projectVersionRefs ); - } - - public boolean introducesCycle( final ProjectRelationship rel ) - { - return getConnectionInternal().introducesCycle( params, rel ); - } - - public void addDisconnectedProject( final ProjectVersionRef ref ) - throws RelationshipGraphException - { - getConnectionInternal().addDisconnectedProject( ref ); - } - - public boolean isMissing( final ProjectVersionRef ref ) - { - return getConnectionInternal().isMissing( params, ref ); - } - - public Set getSources() - { - return params.getActiveSources(); - // final Set> rels = getAllRelationships(); - // final Set sources = new HashSet(); - // for ( final ProjectRelationship rel : rels ) - // { - // sources.addAll( rel.getSources() ); - // } - // - // return sources; - } - - public GraphMutator getMutator() - { - return params.getMutator(); - } - - public ProjectRelationshipFilter getFilter() - { - return params.getFilter(); - } - - public ViewParams addActivePomLocation( final URI location ) - { - return params.addActivePomLocation( location ); - } - - public ViewParams addActivePomLocations( final Collection locations ) - { - return params.addActivePomLocations( locations ); - } - - public ViewParams addActivePomLocations( final URI... locations ) - { - return params.addActivePomLocations( locations ); - } - - public ViewParams addActiveSources( final Collection sources ) - { - return params.addActiveSources( sources ); - } - - public ViewParams addActiveSources( final URI... sources ) - { - return params.addActiveSources( sources ); - } - - public ViewParams addActiveSource( final URI source ) - { - return params.addActiveSource( source ); - } - - public long getLastAccess() - { - return params.getLastAccess(); - } - - public String setProperty( final String key, final String value ) - { - return params.setProperty( key, value ); - } - - public String getProperty( final String key ) - { - return params.getProperty( key ); - } - - public String getProperty( final String key, final String def ) - { - return params.getProperty( key, def ); - } - - public final String getWorkspaceId() - { - return params.getWorkspaceId(); - } - - public final Set getActivePomLocations() - { - return params.getActivePomLocations(); - } - - public final Set getActiveSources() - { - return params.getActiveSources(); - } - - public final ProjectVersionRef getSelection( final ProjectRef ref ) - { - return params.getSelection( ref ); - } - - // --- IMPORTED FROM EProjectWeb - - // +++ IMPORTED FROM EGraphManager - public boolean containsGraph( final ProjectVersionRef ref ) - { - return getConnectionInternal().containsProject( params, ref ); - } - - public Set> findDirectRelationshipsTo( final ProjectVersionRef to, - final boolean includeManagedInfo, - final RelationshipType... types ) - { - return getConnectionInternal().getDirectRelationshipsTo( params, to, includeManagedInfo, true, types ); - } - - public Set> findDirectRelationshipsTo( final ProjectVersionRef to, - final boolean includeManagedInfo, - final boolean includeConcreteInfo, - final RelationshipType... types ) - { - return getConnectionInternal().getDirectRelationshipsTo( params, to, includeManagedInfo, includeConcreteInfo, - types ); - } - - public Set> findDirectRelationshipsFrom( final ProjectVersionRef source, - final boolean managed, - final RelationshipType... types ) - { - return getConnectionInternal().getDirectRelationshipsFrom( params, source, managed, true, types ); - } - - public Set> findDirectRelationshipsFrom( final ProjectVersionRef source, - final boolean managed, final boolean concrete, - final RelationshipType... types ) - { - return getConnectionInternal().getDirectRelationshipsFrom( params, source, managed, concrete, types ); - } - - public Set getAllIncompleteSubgraphs() - { - return getConnectionInternal().getMissingProjects( params ); - } - - public Set getAllVariableSubgraphs() - { - return getConnectionInternal().getVariableProjects( params ); - } - - public Map getMetadata( final ProjectVersionRef ref ) - { - final Map result = new HashMap(); - final Map metadata = getConnectionInternal().getMetadata( ref ); - if ( metadata != null ) - { - result.putAll( metadata ); - } - - result.put( GROUP_ID, ref.getGroupId() ); - result.put( ARTIFACT_ID, ref.getArtifactId() ); - result.put( VERSION, ref.getVersionString() ); - - return result; - } - - public Map getMetadata( final ProjectVersionRef ref, final Set keys ) - { - final Map result = new HashMap(); - final Map metadata = getConnectionInternal().getMetadata( ref, keys ); - if ( metadata != null ) - { - result.putAll( metadata ); - } - - if ( keys.contains( GROUP_ID ) ) - { - result.put( GROUP_ID, ref.getGroupId() ); - } - - if ( keys.contains( ARTIFACT_ID ) ) - { - result.put( ARTIFACT_ID, ref.getArtifactId() ); - } - - if ( keys.contains( VERSION ) ) - { - result.put( VERSION, ref.getVersionString() ); - } - - return result; - } - - public Map, Set> collateByMetadata( final Set refs, - final Set keys ) - { - final Map, Set> result = - new HashMap, Set>(); - for ( final ProjectVersionRef ref : refs ) - { - final Map metadata = getMetadata( ref, keys ); - Set collated = result.get( metadata ); - if ( collated == null ) - { - collated = new HashSet(); - result.put( metadata, collated ); - } - - collated.add( ref ); - } - - return result; - } - - public void setMetadata( final ProjectVersionRef project, final Map metadata ) - throws RelationshipGraphException - { - getConnectionInternal().setMetadata( project, metadata ); - } - - public void deleteRelationshipsDeclaredBy( final ProjectVersionRef ref ) - throws RelationshipGraphException - { - getConnectionInternal().deleteRelationshipsDeclaredBy( ref ); - } - - public Set getProjectsMatching( final ProjectRef projectRef ) - { - return getConnectionInternal().getProjectsMatching( params, projectRef ); - } - - public Map, GraphPathInfo> getPathMapTargeting( final Set refs ) - { - return getConnectionInternal().getPathMapTargeting( params, refs ); - } - - public ProjectVersionRef getPathTargetRef( final GraphPath path ) - { - return getConnectionInternal().getPathTargetRef( path ); - } - - public GraphPath createPath( final GraphPath parentPath, final ProjectRelationship relationship ) - { - return getConnectionInternal().createPath( parentPath, relationship ); - } - - public GraphPath createPath( final ProjectRelationship... relationships ) - { - return getConnectionInternal().createPath( relationships ); - } - - public List getPathRefs( final GraphPath path ) - { - return getConnectionInternal().getPathRefs( params, path ); - } - - public List> getRelationships( final GraphPath path ) - { - return getConnectionInternal().getRelationships( params, path ); - } - - RelationshipGraphConnection getConnection() - { - return connection; - } - - // --- IMPORTED FROM EGraphManager - - @Override - public String toString() - { - return "RelationshipGraph [params=" + params + "]"; - } - - public void printStats() - { - getConnectionInternal().printStats(); - } - - public Map getAllProjectErrors() - { - final Map errors = new HashMap(); - final Set projects = getConnectionInternal().getAllProjects( params ); - for ( final ProjectVersionRef ref : projects ) - { - final String error = getConnectionInternal().getProjectError( ref ); - if ( error != null ) - { - errors.put( ref, error ); - } - } - - return errors; - } - - public synchronized boolean isOpen() - { - return connection != null; - } - - private synchronized RelationshipGraphConnection getConnectionInternal() - { - if ( connection == null ) - { - throw new IllegalStateException( "Relationship graph has been closed!" ); - } - - return connection; - } - - public Collection> getRelationshipsDeclaring( final ProjectVersionRef root ) - { - return getConnectionInternal().getRelationshipsDeclaredBy( params, root ); - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphException.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphException.java deleted file mode 100644 index dce02a22..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphException.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph; - -import java.util.IllegalFormatException; - -public class RelationshipGraphException - extends Exception -{ - - private static final long serialVersionUID = 1L; - - private final Object[] params; - - public RelationshipGraphException( final String message, final Throwable error, final Object... params ) - { - super( message, error ); - this.params = params; - } - - public RelationshipGraphException( final String message, final Object... params ) - { - super( message ); - this.params = params; - } - - @Override - public String getLocalizedMessage() - { - return getMessage(); - } - - @Override - public String getMessage() - { - String message = super.getMessage(); - if ( params != null && params.length > 0 ) - { - try - { - final String formatted = String.format( message.replaceAll( "\\{\\}", "%s" ), params ); - message = formatted; - } - catch ( final IllegalFormatException e ) - { - } - } - - return message; - } -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java deleted file mode 100644 index 39bfad3d..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphFactory.java +++ /dev/null @@ -1,362 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph; - -import java.io.Closeable; -import java.io.IOException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.Timer; -import java.util.TimerTask; - -import org.apache.commons.lang.StringUtils; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public final class RelationshipGraphFactory - implements Closeable -{ - - private final Logger logger = LoggerFactory.getLogger( getClass() ); - - private final RelationshipGraphConnectionFactory connectionManager; - - private final Map connectionCaches = new HashMap(); - - private final Set listenerFactories = - new HashSet(); - - private boolean closed; - - private final Timer timer = new Timer( true ); - - public RelationshipGraphFactory( final RelationshipGraphConnectionFactory connectionFactory, - final RelationshipGraphListenerFactory... listenerFactories ) - { - this.connectionManager = connectionFactory; - if ( listenerFactories.length > 0 ) - { - this.listenerFactories.addAll( Arrays.asList( listenerFactories ) ); - } - } - - public synchronized RelationshipGraph open( final ViewParams params, final boolean create ) - throws RelationshipGraphException - { - checkClosed(); - - final String wsid = params.getWorkspaceId(); - ConnectionCache cache = connectionCaches.get( wsid ); - if ( cache == null || !cache.isOpen() ) - { - final RelationshipGraphConnection connection = - connectionManager.openConnection( params.getWorkspaceId(), create ); - - cache = new ConnectionCache( timer, connectionCaches, connection, wsid ); - connectionCaches.put( wsid, cache ); - - // logger.info( "Created new connection to graph db: {}\nVia:\n {}", params.getWorkspaceId(), - // join( Thread.currentThread() - // .getStackTrace(), "\n " ) ); - } - // else - // { - // logger.info( "Reusing connection to graph db: {}\nVia:\n {}", params.getWorkspaceId(), - // join( Thread.currentThread() - // .getStackTrace(), "\n " ) ); - // } - - RelationshipGraph graph = cache.getGraph( params ); - - if ( graph == null ) - { - graph = new RelationshipGraph( params, cache.getConnection() ); - graph.addListener( cache ); - cache.registerGraph( params, graph ); - } - else - { - graph.incrementGraphOwnership(); - } - - return graph; - } - - public Set listWorkspaces() - { - return connectionManager.listWorkspaces(); - } - - public void store( final RelationshipGraph graph ) - throws RelationshipGraphException - { - checkClosed(); - connectionManager.flush( graph.getConnection() ); - } - - public boolean deleteWorkspace( final String workspaceId ) - throws RelationshipGraphException - { - checkClosed(); - boolean result; - try - { - result = connectionManager.delete( workspaceId ); - } - finally - { - final ConnectionCache connectionCache = connectionCaches.get( workspaceId ); - if ( connectionCache != null ) - { - try - { - connectionCache.closeNow(); - } - catch ( final IOException ex ) - { - logger.error( "Error when trying to close connection cache: {}", ex ); - } - catch ( final RuntimeException ex ) - { - logger.error( "Unexpected error when trying to close connection cache: {}", ex ); - } - } - } - return result; - } - - private void checkClosed() - throws RelationshipGraphException - { - if ( closed ) - { - throw new RelationshipGraphException( "Graph factory is closed!" ); - } - } - - public synchronized void close() - throws IOException - { - closed = true; - timer.cancel(); - - for ( final ConnectionCache cache : connectionCaches.values() ) - { - cache.closeNow(); - } - - connectionCaches.clear(); - - connectionManager.close(); - } - - public boolean workspaceExists( final String workspaceId ) - { - return connectionManager.exists( workspaceId ); - } - - private static final class ConnectionCache - extends AbstractRelationshipGraphListener - implements Iterable - { - private static final long CLOSE_WAIT_TIMEOUT = 5000; - - private final Logger logger = LoggerFactory.getLogger( getClass() ); - - private RelationshipGraphConnection connection; - - private final String wsid; - - private final Map graphs = new HashMap(); - - private final Timer timer; - - private TimerTask closeTimer; - - private final Map mapOfCaches; - - ConnectionCache( final Timer timer, final Map mapOfCaches, - final RelationshipGraphConnection connection, final String wsid ) - { - this.timer = timer; - this.mapOfCaches = mapOfCaches; - this.connection = connection; - this.wsid = wsid; - } - - public synchronized void closeNow() - throws IOException - { - mapOfCaches.remove( wsid ); - - graphs.clear(); - - final RelationshipGraphConnection conn = connection; - connection = null; - - if ( conn != null && !conn.isClosed() ) - { - conn.close(); - } - } - - public synchronized void startCloseTimer() - { - closeTimer = new TimerTask() - { - @Override - public void run() - { - if ( isEmpty() ) - { - try - { - closeNow(); - } - catch ( final IOException e ) - { - logger.error( "Failed to close graph connection cache: " + connection, e ); - } - } - } - }; - - if ( connection == null ) - { - logger.warn( "Attempt to close an already closed ConnectionCache. Called from:\n {}", - StringUtils.join( (new Exception()).getStackTrace(), "\n " ) ); - } - else - { - logger.info( "Starting close-cache countdown for: {} ({}ms)", - connection.getWorkspaceId(), CLOSE_WAIT_TIMEOUT ); - } - - timer.schedule( closeTimer, CLOSE_WAIT_TIMEOUT ); - } - - public synchronized boolean isOpen() - { - return connection != null; - } - - RelationshipGraph getGraph( final ViewParams params ) - { - final RelationshipGraph graph = graphs.get( params ); - - logger.info( "Returning existing graph for: {}", params.getWorkspaceId() ); - - if ( graph != null ) - { - cancelCloseTimer(); - } - - return graph; - } - - private synchronized void cancelCloseTimer() - { - if ( closeTimer != null ) - { - logger.info( "Canceling close-cache countdown for: {} (was scheduled to run in: {}ms)", - connection.getWorkspaceId(), - ( closeTimer.scheduledExecutionTime() - System.currentTimeMillis() ) ); - - closeTimer.cancel(); - closeTimer = null; - } - } - - RelationshipGraphConnection getConnection() - { - return connection; - } - - synchronized void registerGraph( final ViewParams params, final RelationshipGraph graph ) - { - logger.info( "Registering new connection to: {}", params.getWorkspaceId() ); - graphs.put( params, graph ); - cancelCloseTimer(); - } - - synchronized void deregisterGraph( final ViewParams params ) - { - graphs.remove( params ); - if ( isEmpty() ) - { - startCloseTimer(); - } - } - - boolean isEmpty() - { - return graphs.isEmpty(); - } - - @Override - public synchronized Iterator iterator() - { - return new HashSet( graphs.values() ).iterator(); - } - - @Override - public void closed( final RelationshipGraph graph ) - throws RelationshipGraphException - { - // TODO: It'd be nice to be able to flush to disk without wrecking the connection for all other views on the - // same workspace... - - // factory.flush( cache.getConnection() ); - - deregisterGraph( graph.getParams() ); - } - - @Override - public int hashCode() - { - return connection.getWorkspaceId() - .hashCode() + 13; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( obj == null ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final ConnectionCache other = (ConnectionCache) obj; - return connection.getWorkspaceId() - .equals( other.connection.getWorkspaceId() ); - } - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListener.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListener.java deleted file mode 100644 index 42bfdd09..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListener.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph; - -import java.util.Collection; - -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; - -public interface RelationshipGraphListener -{ - - void projectError( RelationshipGraph graph, ProjectVersionRef ref, Throwable error ) - throws RelationshipGraphException; - - void storing( RelationshipGraph graph, Collection> relationships ) - throws RelationshipGraphException; - - void stored( RelationshipGraph graph, Collection> relationships, - Collection> rejected ) - throws RelationshipGraphException; - - void closing( RelationshipGraph graph ) - throws RelationshipGraphException; - - void closed( RelationshipGraph graph ) - throws RelationshipGraphException; - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListenerFactory.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListenerFactory.java deleted file mode 100644 index 6130be4e..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/RelationshipGraphListenerFactory.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph; - -public interface RelationshipGraphListenerFactory -{ - - void addListeners( RelationshipGraph graph ); - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java deleted file mode 100644 index cc72c2bd..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/ViewParams.java +++ /dev/null @@ -1,569 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph; - -import org.apache.commons.codec.digest.DigestUtils; -import org.commonjava.maven.atlas.graph.filter.AnyFilter; -import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; -import org.commonjava.maven.atlas.graph.mutate.GraphMutator; -import org.commonjava.maven.atlas.graph.mutate.ManagedDependencyMutator; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; - -import java.io.Serializable; -import java.net.URI; -import java.util.*; -import java.util.Map.Entry; - -import static org.apache.commons.lang.StringUtils.join; - -/** - *

- * View of a graph database that may include a set of traversal root-nodes, - * a {@link ProjectRelationshipFilter}, and a {@link GraphMutator}. This view - * also supports selection of a GAV to override either all references to a GA, or - * references to a specific GAV. - *

- * - *

- * NOTE(1): Selections currently cannot be overridden or - * cleared once set, and root GAVs cannot be overridden with a selection. - *

- * - *

- * NOTE(2): If root nodes are unspecified, then neither filter nor mutator can be used! - *

- * - * @author jdcasey - */ -public class ViewParams - implements Serializable -{ - - private static final long serialVersionUID = 1L; - - private static final Set DEFAULT_SOURCES = - Collections.unmodifiableSet( Collections.singleton( RelationshipUtils.UNKNOWN_SOURCE_URI ) ); - - private static final Set DEFAULT_POM_LOCATIONS = - Collections.unmodifiableSet( Collections.singleton( RelationshipUtils.POM_ROOT_URI ) ); - - private final Set roots = new HashSet(); - - private final ProjectRelationshipFilter filter; - - private final GraphMutator mutator; - - private Set activePomLocations; - - private Set activeSources; - - private long lastAccess = System.currentTimeMillis(); - - private Map properties; - - private final Map selections; - - private transient String longId; - - private transient String shortId; - - private final String workspaceId; - - public ViewParams( final String workspaceId, final ProjectRelationshipFilter filter, final GraphMutator mutator, - final Collection roots ) - { - this( workspaceId, filter, mutator, null, roots ); - } - - public ViewParams( final String workspaceId, final ProjectRelationshipFilter filter, final GraphMutator mutator, - final ProjectVersionRef... roots ) - { - this( workspaceId, filter, mutator, null, roots ); - } - - public ViewParams( final String workspaceId, final Collection roots ) - { - this( workspaceId, null, null, null, roots ); - } - - public ViewParams( final String workspaceId, final ProjectVersionRef... roots ) - { - this( workspaceId, null, null, null, roots ); - } - - public ViewParams( final String workspaceId, final ProjectRelationshipFilter filter, final GraphMutator mutator, - final Map selections, final Collection roots ) - { - this.workspaceId = workspaceId; - this.filter = filter; - this.selections = selections; - this.roots.addAll( roots ); - this.mutator = mutator; - } - - public ViewParams( final String workspaceId, final ProjectRelationshipFilter filter, final GraphMutator mutator, - final Map selections, final ProjectVersionRef... roots ) - { - this.workspaceId = workspaceId; - this.filter = filter; - this.selections = selections; - this.roots.addAll( Arrays.asList( roots ) ); - this.mutator = mutator; - } - - public ViewParams( final String workspaceId, final Map selections, - final Collection roots ) - { - this( workspaceId, null, null, selections, roots ); - } - - public ViewParams( final String workspaceId, final Map selections, - final ProjectVersionRef... roots ) - { - this( workspaceId, null, null, selections, roots ); - } - - public ViewParams( final String workspaceId, final ProjectRelationshipFilter filter, final GraphMutator mutator, - final Set activePomLocations, final Set activeSources, - final Map selections, final Map properties, - final Collection roots ) - { - this.workspaceId = workspaceId; - this.filter = filter; - this.mutator = mutator; - this.activePomLocations = activePomLocations; - this.activeSources = activeSources; - this.selections = selections; - this.properties = properties; - this.roots.addAll( roots ); - } - - public GraphMutator getMutator() - { - return mutator == null ? ManagedDependencyMutator.INSTANCE : mutator; - } - - public ProjectRelationshipFilter getFilter() - { - return filter == null ? AnyFilter.INSTANCE : filter; - } - - public Set getRoots() - { - return roots; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ( ( filter == null ) ? 0 : filter.hashCode() ); - result = prime * result + ( ( roots == null ) ? 0 : roots.hashCode() ); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( obj == null ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final ViewParams other = (ViewParams) obj; - return getShortId().equals( other.getShortId() ); - } - - @Override - public String toString() - { - return getLongId() + " (shortId: " + getShortId() + ")"; - } - - public String getLongId() - { - if ( longId == null ) - { - final StringBuilder sb = new StringBuilder(); - final String abbreviatedPackage = getClass().getPackage() - .getName() - .replaceAll( "([a-zA-Z])[a-zA-Z]+", "$1" ); - - sb.append( abbreviatedPackage ) - .append( '.' ) - .append( getClass().getSimpleName() ) - .append( "(roots:" ) - .append( join( roots, "," ) ) - .append( ",filter:" ) - .append( filter == null ? "none" : filter.getLongId() ) - .append( ",mutator:" ) - .append( mutator == null ? "none" : mutator.getLongId() ) - .append( ",selections:\n " ) - .append( renderSelections() ); - - sb.append( ")" ); - - longId = sb.toString(); - } - - return longId; - } - - public String getShortId() - { - if ( shortId == null ) - { - shortId = DigestUtils.shaHex( getLongId() ); - } - - return shortId; - } - - public void touch() - { - lastAccess = System.currentTimeMillis(); - } - - public ViewParams addActivePomLocation( final URI location ) - { - if ( activePomLocations == null ) - { - activePomLocations = new HashSet(); - } - - activePomLocations.add( location ); - return this; - } - - public ViewParams addActivePomLocations( final Collection locations ) - { - if ( activePomLocations == null ) - { - activePomLocations = new HashSet(); - } - - activePomLocations.addAll( locations ); - return this; - } - - public ViewParams addActivePomLocations( final URI... locations ) - { - if ( activePomLocations == null ) - { - activePomLocations = new HashSet(); - } - - activePomLocations.addAll( Arrays.asList( locations ) ); - return this; - } - - public ViewParams addActiveSources( final Collection sources ) - { - if ( activeSources == null ) - { - activeSources = new HashSet(); - } - - activeSources.addAll( sources ); - return this; - } - - public ViewParams addActiveSources( final URI... sources ) - { - if ( activeSources == null ) - { - activeSources = new HashSet(); - } - - activeSources.addAll( Arrays.asList( sources ) ); - return this; - } - - public ViewParams addActiveSource( final URI source ) - { - if ( activeSources == null ) - { - activeSources = new HashSet(); - } - - activeSources.add( source ); - return this; - } - - public long getLastAccess() - { - return lastAccess; - } - - public String setProperty( final String key, final String value ) - { - if ( properties == null ) - { - properties = new HashMap(); - } - - return properties.put( key, value ); - } - - public String removeProperty( final String key ) - { - return properties == null ? null : properties.remove( key ); - } - - public String getProperty( final String key ) - { - return properties == null ? null : properties.get( key ); - } - - public String getProperty( final String key, final String def ) - { - final String val = properties == null ? null : properties.get( key ); - return val == null ? def : val; - } - - public final String getWorkspaceId() - { - return workspaceId; - } - - public final Set getActivePomLocations() - { - return activePomLocations == null ? DEFAULT_POM_LOCATIONS : activePomLocations; - } - - public final Set getActiveSources() - { - return activeSources == null ? DEFAULT_SOURCES : activeSources; - } - - public final Iterable activePomLocations() - { - return activePomLocations; - } - - public final Iterable activeSources() - { - return activeSources; - } - - public final Map getSelections() - { - return selections == null ? Collections. emptyMap() : selections; - } - - public final ProjectVersionRef getSelection( final ProjectRef ref ) - { - if ( selections == null ) - { - return null; - } - - ProjectVersionRef selected = selections.get( ref ); - if ( selected == null ) - { - selected = selections.get( ref.asProjectRef() ); - } - - return selected; - } - - public boolean hasSelection( final ProjectVersionRef ref ) - { - return selections != null && ( selections.containsKey( ref ) || selections.containsKey( ref.asProjectRef() ) ); - } - - public String renderSelections() - { - if ( selections == null ) - { - return ""; - } - - final StringBuilder sb = new StringBuilder(); - for ( final Entry entry : selections.entrySet() ) - { - final ProjectRef key = entry.getKey(); - final ProjectVersionRef value = entry.getValue(); - - sb.append( "\n " ) - .append( key ) - .append( " => " ) - .append( value ); - } - - return sb.toString(); - } - - public boolean hasSelections() - { - return selections != null && !selections.isEmpty(); - } - - public static final class Builder - { - private final Set roots; - - private ProjectRelationshipFilter filter; - - private GraphMutator mutator; - - private final Set activePomLocations; - - private final Set activeSources; - - private final Map properties; - - private final Map selections; - - private final String workspaceId; - - public Builder( final String workspaceId, final ProjectVersionRef... roots ) - { - this.workspaceId = workspaceId; - this.roots = new HashSet( Arrays.asList( roots ) ); - this.activePomLocations = new HashSet(); - this.activeSources = new HashSet(); - this.properties = new HashMap(); - this.selections = new HashMap(); - this.filter = AnyFilter.INSTANCE; - this.mutator = ManagedDependencyMutator.INSTANCE; - } - - public Builder( final String workspaceId, final Collection roots ) - { - this.workspaceId = workspaceId; - this.roots = new HashSet( roots ); - this.activePomLocations = new HashSet(); - this.activeSources = new HashSet(); - this.properties = new HashMap(); - this.selections = new HashMap(); - this.filter = AnyFilter.INSTANCE; - this.mutator = ManagedDependencyMutator.INSTANCE; - } - - public Builder( final ViewParams params ) - { - this.workspaceId = params.getWorkspaceId(); - this.roots = - params.roots == null ? new HashSet() : new HashSet( params.roots ); - this.filter = params.filter; - this.mutator = params.mutator; - this.activePomLocations = - params.activePomLocations == null ? new HashSet() : new HashSet( params.activePomLocations ); - this.activeSources = - params.activeSources == null ? new HashSet() : new HashSet( params.activeSources ); - this.properties = - params.properties == null ? new HashMap() - : new HashMap( params.properties ); - this.selections = - params.selections == null ? new HashMap() - : new HashMap( params.selections ); - } - - public Builder withRoots( final ProjectVersionRef... roots ) - { - this.roots.clear(); - this.roots.addAll( Arrays.asList( roots ) ); - return this; - } - - public Builder withFilter( final ProjectRelationshipFilter filter ) - { - this.filter = filter; - return this; - } - - public Builder withMutator( final GraphMutator mutator ) - { - this.mutator = mutator; - return this; - } - - /** - * Adds selected versions into selections map. To work properly keys - * must be instances of {@link ProjectRef} or of the same class as the - * one used in {@link ViewParams#getSelection(ProjectRef)} and - * {@link ViewParams#hasSelection(ProjectVersionRef)}. - * - * @param selections - * map of {@link ProjectRef} to {@link ProjectVersionRef}, - * can be {@code null} indicating that no selections were - * done - * @return this instance for method chaining - */ - public Builder withSelections( final Map selections ) - { - this.selections.clear(); - if ( selections != null ) - { - this.selections.putAll( selections ); - } - return this; - } - - public Builder withProperties( final Map properties ) - { - this.properties.clear(); - this.properties.putAll( properties ); - return this; - } - - public Builder withActivePomLocations( final Set activePomLocations ) - { - this.activePomLocations.clear(); - this.activePomLocations.addAll( activePomLocations ); - return this; - } - - public Builder withActiveSources( final Set activeSources ) - { - this.activeSources.clear(); - this.activeSources.addAll( activeSources ); - return this; - } - - public ViewParams build() - { - return new ViewParams( workspaceId, filter, mutator, activePomLocations, activeSources, selections, - properties, roots ); - } - - public Builder withSelection( final ProjectRef target, final ProjectVersionRef selection ) - { - selections.put( target, selection ); - return this; - } - - public Builder withRoots( final Collection roots ) - { - this.roots.clear(); - this.roots.addAll( roots ); - return this; - } - - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java deleted file mode 100644 index 073b18e8..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractAggregatingFilter.java +++ /dev/null @@ -1,256 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import org.apache.commons.codec.digest.DigestUtils; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; - -public abstract class AbstractAggregatingFilter - implements ProjectRelationshipFilter, Iterable -{ - /** - * - */ - private static final long serialVersionUID = 1L; - - private final List filters; - - private transient String longId; - - private transient String shortId; - - protected AbstractAggregatingFilter( final Collection filters ) - { - this.filters = new ArrayList( filters ); - } - - protected AbstractAggregatingFilter( final ProjectRelationshipFilter... filters ) - { - this.filters = new ArrayList( Arrays.asList( filters ) ); - } - - public final List getFilters() - { - return filters; - } - - @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) - { - final Set childFilters = new LinkedHashSet(); - for ( final ProjectRelationshipFilter filter : getFilters() ) - { - // if ( filter.accept( parent ) ) - // { - childFilters.add( filter.getChildFilter( parent ) ); - // } - } - - if ( filtersEqual( childFilters ) ) - { - return this; - } - - // TODO: Optimize to ensure we're only creating a new instance when it's critical to... - return newChildFilter( childFilters ); - } - - protected abstract AbstractAggregatingFilter newChildFilter( Collection childFilters ); - - @Override - public Iterator iterator() - { - return new ArrayList( filters ).iterator(); - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ( ( filters == null ) ? 0 : filters.hashCode() ); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( obj == null ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final AbstractAggregatingFilter other = (AbstractAggregatingFilter) obj; - - return filtersEqual( other.filters ); - } - - protected final boolean filtersEqual( final Collection otherFilters ) - { - if ( filters == null ) - { - if ( otherFilters != null ) - { - return false; - } - } - else if ( otherFilters != null ) - { - // if ( orderMatters ) - // { - if ( otherFilters instanceof List ) - { - return filters.equals( otherFilters ); - } - else - { - List otherFiltersList = - new ArrayList( otherFilters ); - return filters.equals( otherFiltersList ); - } - // } - // else - // { - // for ( final ProjectRelationshipFilter filter : filters ) - // { - // if ( !otherFilters.contains( filter ) ) - // { - // return false; - // } - // } - // - // for ( final ProjectRelationshipFilter filter : otherFilters ) - // { - // if ( !filters.contains( filter ) ) - // { - // return false; - // } - // } - // } - } - - return true; - } - - @Override - public String getLongId() - { - if ( longId == null ) - { - final StringBuilder sb = new StringBuilder(); - final List filters = getFilters(); - final String abbreviatedPackage = getClass().getPackage() - .getName() - .replaceAll( "([a-zA-Z])[a-zA-Z]+", "$1" ); - - sb.append( abbreviatedPackage ) - .append( '.' ) - .append( getClass().getSimpleName() ) - .append( '(' ); - - boolean first = true; - for ( final ProjectRelationshipFilter filter : filters ) - { - if ( !first ) - { - sb.append( ',' ); - } - - first = false; - sb.append( filter.getLongId() ); - } - sb.append( ')' ); - - longId = sb.toString(); - } - - return longId; - } - - @Override - public String toString() - { - return getLongId(); - } - - @Override - public String getCondensedId() - { - if ( shortId == null ) - { - shortId = DigestUtils.shaHex( getLongId() ); - } - - return shortId; - } - - @Override - public boolean includeManagedRelationships() - { - for ( final ProjectRelationshipFilter filter : filters ) - { - if ( filter.includeManagedRelationships() ) - { - return true; - } - } - - return false; - } - - @Override - public boolean includeConcreteRelationships() - { - for ( final ProjectRelationshipFilter filter : filters ) - { - if ( filter.includeConcreteRelationships() ) - { - return true; - } - } - - return false; - } - - @Override - public Set getAllowedTypes() - { - final Set result = new HashSet(); - for ( final ProjectRelationshipFilter filter : filters ) - { - result.addAll( filter.getAllowedTypes() ); - } - - return result; - } -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java deleted file mode 100644 index b039205b..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AbstractTypedFilter.java +++ /dev/null @@ -1,327 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import static org.apache.commons.lang.StringUtils.join; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import org.apache.commons.codec.digest.DigestUtils; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; - -public abstract class AbstractTypedFilter - implements ProjectRelationshipFilter -{ - - // private final Logger logger = new Logger( getClass() ); - - /** - * - */ - private static final long serialVersionUID = 1L; - - private final Set types; - - private final Set descendantTypes; - - private final boolean includeManagedInfo; - - private final boolean includeConcreteInfo; - - private transient String longId; - - private transient String shortId; - - protected AbstractTypedFilter( final RelationshipType type, final RelationshipType descendantType, - final boolean includeManagedInfo, final boolean includeConcreteInfo ) - { - this.types = Collections.unmodifiableSet( Collections.singleton( type ) ); - this.descendantTypes = Collections.unmodifiableSet( Collections.singleton( descendantType ) ); - this.includeManagedInfo = includeManagedInfo; - this.includeConcreteInfo = includeConcreteInfo; - } - - protected AbstractTypedFilter( final RelationshipType type, final Collection descendantTypes, - final boolean includeManagedInfo, final boolean includeConcreteInfo ) - { - if ( type == null ) - { - this.types = - Collections.unmodifiableSet( new HashSet( Arrays.asList( RelationshipType.values() ) ) ); - } - else - { - this.types = Collections.unmodifiableSet( Collections.singleton( type ) ); - } - - if ( descendantTypes == null || descendantTypes.isEmpty() ) - { - this.descendantTypes = - Collections.unmodifiableSet( new HashSet( Arrays.asList( RelationshipType.values() ) ) ); - } - else - { - this.descendantTypes = Collections.unmodifiableSet( new HashSet( descendantTypes ) ); - } - - this.includeManagedInfo = includeManagedInfo; - this.includeConcreteInfo = includeConcreteInfo; - } - - protected AbstractTypedFilter( final Collection types, - final Collection descendantTypes, - final boolean includeManagedInfo, final boolean includeConcreteInfo ) - { - if ( types == null || types.isEmpty() ) - { - this.types = - Collections.unmodifiableSet( new HashSet( Arrays.asList( RelationshipType.values() ) ) ); - } - else - { - this.types = Collections.unmodifiableSet( new HashSet( types ) ); - } - - if ( descendantTypes == null || descendantTypes.isEmpty() ) - { - this.descendantTypes = - Collections.unmodifiableSet( new HashSet( Arrays.asList( RelationshipType.values() ) ) ); - } - else - { - this.descendantTypes = Collections.unmodifiableSet( new HashSet( descendantTypes ) ); - } - - this.includeManagedInfo = includeManagedInfo; - this.includeConcreteInfo = includeConcreteInfo; - } - - protected AbstractTypedFilter( final RelationshipType type, final boolean hasDescendants, - final boolean includeManagedInfo, final boolean includeConcreteInfo ) - { - if ( type == null ) - { - this.types = - Collections.unmodifiableSet( new HashSet( Arrays.asList( RelationshipType.values() ) ) ); - } - else - { - this.types = Collections.unmodifiableSet( Collections.singleton( type ) ); - } - - if ( hasDescendants ) - { - this.descendantTypes = types; - } - else - { - this.descendantTypes = Collections.unmodifiableSet( Collections. emptySet() ); - } - - this.includeManagedInfo = includeManagedInfo; - this.includeConcreteInfo = includeConcreteInfo; - } - - @Override - public final boolean accept( final ProjectRelationship rel ) - { - if ( types.contains( rel.getType() ) ) - { - final boolean accepted = doAccept( rel ); - if ( accepted ) - { - // logger.info( "ACCEPT relationship: %s. Type is in: %s, and was accepted in second-level analysis", rel, - // types ); - } - else - { - // logger.info( "REJECT relationship: %s. Type is in: %s but was rejected by second-level analysis.", rel, - // types ); - } - - return accepted; - } - // else - // { - // logger.info( "REJECT relationship: %s. Type is not in: %s", rel, types ); - // } - - return false; - } - - @Override - public Set getDepExcludes() - { - return null; - } - - public Set getRelationshipTypes() - { - return types; - } - - public Set getDescendantRelationshipTypes() - { - return descendantTypes; - } - - protected boolean doAccept( final ProjectRelationship rel ) - { - // base functionality is only to check that the type is appropriate. - return true; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ( ( descendantTypes == null ) ? 0 : descendantTypes.hashCode() ); - result = prime * result + ( includeConcreteInfo ? 1231 : 1237 ); - result = prime * result + ( includeManagedInfo ? 1231 : 1237 ); - result = prime * result + ( ( types == null ) ? 0 : types.hashCode() ); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( obj == null ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final AbstractTypedFilter other = (AbstractTypedFilter) obj; - if ( descendantTypes == null ) - { - if ( other.descendantTypes != null ) - { - return false; - } - } - else if ( !descendantTypes.equals( other.descendantTypes ) ) - { - return false; - } - if ( includeConcreteInfo != other.includeConcreteInfo ) - { - return false; - } - if ( includeManagedInfo != other.includeManagedInfo ) - { - return false; - } - if ( types == null ) - { - if ( other.types != null ) - { - return false; - } - } - else if ( !types.equals( other.types ) ) - { - return false; - } - return true; - } - - @Override - public String getLongId() - { - if ( longId == null ) - { - final StringBuilder sb = new StringBuilder(); - final String abbreviatedPackage = getClass().getPackage() - .getName() - .replaceAll( "([a-zA-Z])[a-zA-Z]+", "$1" ); - - sb.append( abbreviatedPackage ) - .append( '.' ) - .append( getClass().getSimpleName() ) - .append( "[types:{" ) - .append( join( types, "," ) ) - .append( "}, next-types:{" ) - .append( join( descendantTypes, "," ) ) - .append( "}, concrete:" ) - .append( includeConcreteInfo ) - .append( ", managed:" ) - .append( includeManagedInfo ); - - renderIdAttributes( sb ); - sb.append( ']' ); - - longId = sb.toString(); - } - - return longId; - } - - protected void renderIdAttributes( final StringBuilder sb ) - { - } - - @Override - public String toString() - { - return getLongId(); - } - - @Override - public String getCondensedId() - { - if ( shortId == null ) - { - shortId = DigestUtils.shaHex( getLongId() ); - } - - return shortId; - } - - @Override - public boolean includeManagedRelationships() - { - return includeManagedInfo; - } - - @Override - public boolean includeConcreteRelationships() - { - return includeConcreteInfo; - } - - @Override - public Set getAllowedTypes() - { - final Set result = new HashSet(); - result.addAll( types ); - result.addAll( descendantTypes ); - - return result; - } -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java deleted file mode 100644 index e47c7c84..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AndFilter.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; - -public class AndFilter - extends AbstractAggregatingFilter -{ - - /** - * - */ - private static final long serialVersionUID = 1L; - - public AndFilter( final Collection filters ) - { - super( filters ); - } - - public AndFilter( final T... filters ) - { - super( filters ); - } - - @Override - public boolean accept( final ProjectRelationship rel ) - { - boolean accepted = true; - for ( final ProjectRelationshipFilter filter : getFilters() ) - { - accepted = accepted && filter.accept( rel ); - if ( !accepted ) - { - break; - } - } - - return accepted; - } - - @Override - public Set getDepExcludes() - { - Set excludes = null; - for (ProjectRelationshipFilter filter : getFilters()) - { - Set filterExcludes = filter.getDepExcludes(); - if (filterExcludes == null || filterExcludes.isEmpty()) - { - excludes = null; - break; - } - - if (excludes == null) - { - excludes = new HashSet(filterExcludes); - } - else - { - excludes.retainAll( filterExcludes ); - } - } - return excludes; - } - - @Override - protected AbstractAggregatingFilter newChildFilter( final Collection childFilters ) - { - if ( !filtersEqual( childFilters ) ) - { - return new AndFilter( childFilters ); - } - - return this; - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AnyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AnyFilter.java deleted file mode 100644 index 3261d9d9..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/AnyFilter.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; - -public class AnyFilter - implements ProjectRelationshipFilter -{ - - /** - * - */ - private static final long serialVersionUID = 1L; - - public static final AnyFilter INSTANCE = new AnyFilter(); - - private AnyFilter() - { - } - - @Override - public boolean accept( final ProjectRelationship rel ) - { - return true; - } - - @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) - { - return this; - } - - @Override - public String getLongId() - { - return "ANY"; - } - - @Override - public String toString() - { - return getLongId(); - } - - @Override - public boolean equals( final Object obj ) - { - return obj instanceof AnyFilter; - } - - @Override - public int hashCode() - { - return AnyFilter.class.hashCode() + 1; - } - - @Override - public String getCondensedId() - { - return getLongId(); - } - - @Override - public boolean includeManagedRelationships() - { - return true; - } - - @Override - public boolean includeConcreteRelationships() - { - return true; - } - - @Override - public Set getAllowedTypes() - { - return new HashSet( Arrays.asList( RelationshipType.values() ) ); - } - - @Override - public Set getDepExcludes() - { - return null; - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/BomFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/BomFilter.java deleted file mode 100644 index 67d1de68..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/BomFilter.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; - -public class BomFilter - extends AbstractTypedFilter -{ - - private static final long serialVersionUID = 1L; - - public static final BomFilter INSTANCE = new BomFilter(); - - private BomFilter() - { - // BOMs are actually marked as concrete...somewhat counter-intuitive, - // but they're structural, so managed isn't quite correct (despite - // Maven's unfortunate choice for location). - super( RelationshipType.BOM, true, false, true ); - } - - @Override - public boolean doAccept( final ProjectRelationship rel ) - { - return true; - } - - @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) - { - return this; - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java deleted file mode 100644 index 9f5cb466..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyFilter.java +++ /dev/null @@ -1,244 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import java.util.HashSet; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ScopeTransitivity; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DependencyFilter - extends AbstractTypedFilter -{ - - /** - * - */ - private static final long serialVersionUID = 1L; - - private final DependencyScope scope; - - private final ScopeTransitivity scopeTransitivity; - - private final Set excludes = new HashSet(); - - private final boolean useImpliedScopes; - - public DependencyFilter() - { - this( DependencyScope.test, ScopeTransitivity.maven, false, true, true, null ); - } - - public DependencyFilter( final DependencyScope scope ) - { - this( scope, ScopeTransitivity.maven, false, true, true, null ); - } - - public DependencyFilter( final DependencyScope scope, final ScopeTransitivity scopeTransitivity, - final boolean includeManaged, final boolean includeConcrete, final Set excludes ) - { - this( scope, scopeTransitivity, includeManaged, includeConcrete, true, excludes ); - } - - public DependencyFilter( final DependencyScope scope, final ScopeTransitivity scopeTransitivity, - final boolean includeManaged, final boolean includeConcrete, - final boolean useImpliedScopes, final Set excludes ) - { - super( RelationshipType.DEPENDENCY, true, includeManaged, includeConcrete ); - this.useImpliedScopes = useImpliedScopes; - this.scope = scope == null ? DependencyScope.test : scope; - this.scopeTransitivity = scopeTransitivity; - if ( excludes != null ) - { - for ( final ProjectRef pr : excludes ) - { - this.excludes.add( pr.asProjectRef() ); - } - } - } - - @Override - public boolean doAccept( final ProjectRelationship rel ) - { -// Logger logger = LoggerFactory.getLogger( getClass() ); -// logger.debug( "CHECK accept: {}", rel); - final DependencyRelationship dr = (DependencyRelationship) rel; - if ( RelationshipUtils.isExcluded( dr.getTarget(), excludes ) ) - { -// logger.debug( "NO (excluded)" ); - return false; - } - - if ( scope != null ) - { - if ( useImpliedScopes && !scope.implies( dr.getScope() ) ) - { -// logger.debug( "NO (wrong implied scope)" ); - return false; - } - else if ( !useImpliedScopes && scope != dr.getScope() ) - { -// logger.debug( "NO (wrong direct scope)" ); - return false; - } - } - - if ( !includeManagedRelationships() && dr.isManaged() ) - { -// logger.debug( "NO (excluding managed)" ); - return false; - } - else if ( !includeConcreteRelationships() && !dr.isManaged() ) - { -// logger.debug( "NO (excluding concrete)" ); - return false; - } - -// logger.debug( "YES" ); - return true; - } - - @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) - { - DependencyRelationship dr = null; - if ( ( parent instanceof DependencyRelationship ) ) - { - dr = (DependencyRelationship) parent; - } - - final DependencyScope nextScope = scopeTransitivity.getChildFor( scope ); - Set newExcludes = dr == null ? null : dr.getExcludes(); - if ( nextScope != scope || ( newExcludes != null && !newExcludes.isEmpty() ) ) - { - if ( excludes != null ) - { - final Set ex = new HashSet( excludes ); - - if ( newExcludes != null && !newExcludes.isEmpty() ) - { - ex.addAll( newExcludes ); - } - - newExcludes = ex; - } - - return new DependencyFilter( nextScope, scopeTransitivity, includeManagedRelationships(), - includeConcreteRelationships(), useImpliedScopes, newExcludes ); - } - - return this; - } - - public Set getDepExcludes() - { - return excludes; - } - - public boolean isUseImpliedScopes() - { - return useImpliedScopes; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ( ( excludes == null ) ? 0 : excludes.hashCode() ); - result = prime * result + ( ( scope == null ) ? 0 : scope.hashCode() ); - result = prime * result + ( ( scopeTransitivity == null ) ? 0 : scopeTransitivity.hashCode() ); - result = prime * result + ( useImpliedScopes ? 1231 : 1237 ); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( !super.equals( obj ) ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final DependencyFilter other = (DependencyFilter) obj; - if ( excludes == null ) - { - if ( other.excludes != null ) - { - return false; - } - } - else if ( !excludes.equals( other.excludes ) ) - { - return false; - } - if ( scope != other.scope ) - { - return false; - } - if ( scopeTransitivity != other.scopeTransitivity ) - { - return false; - } - return useImpliedScopes == other.useImpliedScopes; - } - - @Override - protected void renderIdAttributes( final StringBuilder sb ) - { - sb.append( ", scope:" ); - sb.append( scope.realName() ); - sb.append( ", transitivity:" ) - .append( scopeTransitivity.name() ); - sb.append( ", implied-scopes:" ) - .append( isUseImpliedScopes() ); - - if ( excludes != null && !excludes.isEmpty() ) - { - sb.append( ", excludes:{" ); - boolean first = true; - for ( final ProjectRef exclude : excludes ) - { - if ( !first ) - { - sb.append( ',' ); - } - - first = false; - sb.append( exclude ); - } - - sb.append( "}" ); - } - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java deleted file mode 100644 index f35f63dd..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/DependencyOnlyFilter.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import static org.apache.commons.lang.StringUtils.join; - -import java.util.Arrays; - -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.ident.DependencyScope; - -public class DependencyOnlyFilter - extends AbstractTypedFilter -{ - - /** - * - */ - private static final long serialVersionUID = 1L; - - // if unspecified, include all dependencies. - private final DependencyScope[] scopes; - - private final boolean useImpliedScope; - - public DependencyOnlyFilter() - { - this( false, true, true, DependencyScope.test ); - } - - public DependencyOnlyFilter( final DependencyScope... scopes ) - { - this( false, true, true, scopes ); - } - - public DependencyOnlyFilter( final boolean includeManaged, final boolean includeConcrete, - final boolean useImpliedScope, final DependencyScope... scopes ) - { - super( RelationshipType.DEPENDENCY, false, includeManaged, includeConcrete ); - - this.scopes = scopes; - this.useImpliedScope = useImpliedScope; - } - - @Override - public boolean doAccept( final ProjectRelationship rel ) - { - if ( this.scopes == null || this.scopes.length < 1 ) - { - return true; - } - - final DependencyRelationship dr = (DependencyRelationship) rel; - final DependencyScope scope = dr.getScope(); - for ( final DependencyScope s : this.scopes ) - { - if ( scope == s || ( useImpliedScope && s.implies( scope ) ) ) - { - if ( ( dr.isManaged() && includeManagedRelationships() ) - || ( !dr.isManaged() && includeConcreteRelationships() ) ) - { - return true; - } - } - } - - return false; - } - - @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) - { - return NoneFilter.INSTANCE; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + Arrays.hashCode( scopes ); - result = prime * result + ( useImpliedScope ? 1231 : 1237 ); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( !super.equals( obj ) ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final DependencyOnlyFilter other = (DependencyOnlyFilter) obj; - if ( !Arrays.equals( scopes, other.scopes ) ) - { - return false; - } - return useImpliedScope == other.useImpliedScope; - } - - @Override - protected void renderIdAttributes( final StringBuilder sb ) - { - sb.append( ",scopes:{" ) - .append( join( scopes, "," ) ) - .append( ",implied-scopes: " ) - .append( useImpliedScope ); - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java deleted file mode 100644 index 0261301f..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExcludingFilter.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import static org.apache.commons.lang.StringUtils.join; - -import java.util.List; -import java.util.Set; - -import org.apache.commons.codec.digest.DigestUtils; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; - -public class ExcludingFilter - implements ProjectRelationshipFilter -{ - - private static final long serialVersionUID = 1L; - - private final List excludedSubgraphs; - - private final ProjectRelationshipFilter filter; - - private transient String longId; - - private transient String shortId; - - public ExcludingFilter( final List excludedSubgraphs, final ProjectRelationshipFilter filter ) - { - this.excludedSubgraphs = excludedSubgraphs; - this.filter = filter; - } - - @Override - public boolean accept( final ProjectRelationship rel ) - { - final ProjectVersionRef target = rel.getTarget() - .asProjectVersionRef(); - return !excludedSubgraphs.contains( target ) && filter.accept( rel ); - } - - @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) - { - ProjectRelationshipFilter childfilter = filter.getChildFilter( parent ); - if ( childfilter == filter ) - { - return this; - } - else - { - return new ExcludingFilter( excludedSubgraphs, childfilter ); - } - } - - @Override - public Set getDepExcludes() - { - return filter.getDepExcludes(); - } - - @Override - public String getLongId() - { - if ( longId == null ) - { - longId = - "Excluded-Subgraphs [" + join( excludedSubgraphs, "\n" ) + "], delegating to: " + filter.getLongId(); - } - return longId; - } - - @Override - public String getCondensedId() - { - if ( shortId == null ) - { - shortId = DigestUtils.shaHex( getLongId() ); - } - - return shortId; - } - - @Override - public boolean includeManagedRelationships() - { - return filter.includeManagedRelationships(); - } - - @Override - public boolean includeConcreteRelationships() - { - return filter.includeConcreteRelationships(); - } - - @Override - public Set getAllowedTypes() - { - return filter.getAllowedTypes(); - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionFilter.java deleted file mode 100644 index 120037a1..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionFilter.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.graph.rel.SimpleExtensionRelationship; -import org.commonjava.maven.atlas.ident.DependencyScope; - -// TODO: Do we need to consider excludes in the extensions? -public class ExtensionFilter - extends AbstractTypedFilter -{ - - /** - * - */ - private static final long serialVersionUID = 1L; - - public ExtensionFilter() - { - super( RelationshipType.EXTENSION, RelationshipType.DEPENDENCY, false, true ); - } - - @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) - { - if ( parent instanceof SimpleExtensionRelationship ) - { - return new OrFilter( new DependencyFilter( DependencyScope.runtime ), ParentFilter.EXCLUDE_TERMINAL_PARENTS ); - } - else - { - return NoneFilter.INSTANCE; - } - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionOnlyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionOnlyFilter.java deleted file mode 100644 index fb71aa05..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ExtensionOnlyFilter.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; - -public class ExtensionOnlyFilter - extends AbstractTypedFilter -{ - - /** - * - */ - private static final long serialVersionUID = 1L; - - public ExtensionOnlyFilter() - { - super( RelationshipType.EXTENSION, false, false, true ); - } - - @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) - { - return NoneFilter.INSTANCE; - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/NoneFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/NoneFilter.java deleted file mode 100644 index 8af48e06..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/NoneFilter.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import java.util.Collections; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; - -public class NoneFilter - implements ProjectRelationshipFilter -{ - - /** - * - */ - private static final long serialVersionUID = 1L; - - public static final NoneFilter INSTANCE = new NoneFilter(); - - private NoneFilter() - { - } - - @Override - public boolean accept( final ProjectRelationship rel ) - { - return false; - } - - @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) - { - return this; - } - - @Override - public String getLongId() - { - return "NONE"; - } - - @Override - public String toString() - { - return getLongId(); - } - - @Override - public boolean equals( final Object obj ) - { - return obj instanceof NoneFilter; - } - - @Override - public int hashCode() - { - return NoneFilter.class.hashCode() + 1; - } - - @Override - public String getCondensedId() - { - return getLongId(); - } - - @Override - public boolean includeManagedRelationships() - { - return false; - } - - @Override - public boolean includeConcreteRelationships() - { - return false; - } - - @Override - public Set getAllowedTypes() - { - return Collections.emptySet(); - } - - @Override - public Set getDepExcludes() - { - return null; - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java deleted file mode 100644 index 8cedbe7e..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/OrFilter.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; - -public class OrFilter - extends AbstractAggregatingFilter -{ - - // private final Logger logger = new Logger( getClass() ); - - /** - * - */ - private static final long serialVersionUID = 1L; - - public OrFilter( final Collection filters ) - { - super( filters ); - } - - public OrFilter( final T... filters ) - { - super( filters ); - } - - @Override - public boolean accept( final ProjectRelationship rel ) - { - boolean accepted = false; - for ( final ProjectRelationshipFilter filter : getFilters() ) - { - accepted = accepted || filter.accept( rel ); - if ( accepted ) - { - // logger.info( "ACCEPTed: %s, by sub-filter: %s", rel, filter ); - break; - } - } - - return accepted; - } - - @Override - public Set getDepExcludes() - { - Set excludes = new HashSet(); - for (ProjectRelationshipFilter filter : getFilters()) - { - Set filterExcludes = filter.getDepExcludes(); - if (filterExcludes == null) - { - continue; - } - - excludes.addAll( filterExcludes ); - } - return excludes; - } - - @Override - protected AbstractAggregatingFilter newChildFilter( final Collection childFilters ) - { - if ( !filtersEqual( childFilters ) ) - { - return new OrFilter( childFilters ); - } - - return this; - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ParentFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ParentFilter.java deleted file mode 100644 index d5f3ed55..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ParentFilter.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; - -public class ParentFilter - extends AbstractTypedFilter -{ - - /** - * - */ - private static final long serialVersionUID = 1L; - - public static final ParentFilter EXCLUDE_TERMINAL_PARENTS = new ParentFilter( false ); - - public static final ParentFilter INCLUDE_TERMINAL_PARENTS = new ParentFilter( true ); - - private final boolean allowTerminalParent; - - private ParentFilter( final boolean allowTerminalParent ) - { - super( RelationshipType.PARENT, true, false, true ); - this.allowTerminalParent = allowTerminalParent; - } - - @Override - public boolean doAccept( final ProjectRelationship rel ) - { - return allowTerminalParent || !( (ParentRelationship) rel ).isTerminus(); - - } - - @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) - { - return this; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ( allowTerminalParent ? 1231 : 1237 ); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( !super.equals( obj ) ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final ParentFilter other = (ParentFilter) obj; - return allowTerminalParent == other.allowTerminalParent; - } - - @Override - protected void renderIdAttributes( final StringBuilder sb ) - { - sb.append( ",terminalParent:" ) - .append( allowTerminalParent ); - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyFilter.java deleted file mode 100644 index 3803f584..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyFilter.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; - -// TODO: Do we need to consider excludes in the direct plugin-level dependency? -public class PluginDependencyFilter - extends AbstractTypedFilter -{ - - /** - * - */ - private static final long serialVersionUID = 1L; - - private final ProjectRef plugin; - - public PluginDependencyFilter( final PluginRelationship plugin ) - { - this( plugin, false, true ); - } - - public PluginDependencyFilter( final PluginRelationship plugin, final boolean includeManaged, - final boolean includeConcrete ) - { - super( RelationshipType.PLUGIN_DEP, RelationshipType.DEPENDENCY, includeManaged, includeConcrete ); - - this.plugin = plugin == null ? null : plugin.getTarget() - .asProjectRef(); - } - - public PluginDependencyFilter() - { - this( null, false, true ); - } - - public PluginDependencyFilter( final boolean includeManaged, final boolean includeConcrete ) - { - this( null, includeManaged, includeConcrete ); - } - - @Override - public boolean doAccept( final ProjectRelationship rel ) - { - final PluginDependencyRelationship pdr = (PluginDependencyRelationship) rel; - if ( plugin == null || plugin.equals( pdr.getPlugin() ) ) - { - if ( includeManagedRelationships() && pdr.isManaged() ) - { - return true; - } - else if ( includeConcreteRelationships() && !pdr.isManaged() ) - { - return true; - } - } - - return false; - } - - @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) - { - return new DependencyFilter( DependencyScope.runtime ); - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ( ( plugin == null ) ? 0 : plugin.hashCode() ); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( !super.equals( obj ) ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final PluginDependencyFilter other = (PluginDependencyFilter) obj; - if ( plugin == null ) - { - if ( other.plugin != null ) - { - return false; - } - } - else if ( !plugin.equals( other.plugin ) ) - { - return false; - } - return true; - } - - @Override - protected void renderIdAttributes( final StringBuilder sb ) - { - sb.append( ",plugin:" ) - .append( plugin ); - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyOnlyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyOnlyFilter.java deleted file mode 100644 index 227d1203..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginDependencyOnlyFilter.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; - -public class PluginDependencyOnlyFilter - extends AbstractTypedFilter -{ - - /** - * - */ - private static final long serialVersionUID = 1L; - - private final ProjectRef plugin; - - public PluginDependencyOnlyFilter( final PluginRelationship plugin ) - { - this( plugin, false, true ); - } - - public PluginDependencyOnlyFilter( final PluginRelationship plugin, final boolean includeManaged, - final boolean includeConcrete ) - { - super( RelationshipType.PLUGIN_DEP, false, includeManaged, includeConcrete ); - - this.plugin = plugin.getTarget() - .asProjectRef(); - } - - @Override - public boolean doAccept( final ProjectRelationship rel ) - { - final PluginDependencyRelationship pdr = (PluginDependencyRelationship) rel; - if ( plugin.equals( pdr.getPlugin() ) ) - { - if ( includeManagedRelationships() && pdr.isManaged() ) - { - return true; - } - else if ( includeConcreteRelationships() && !pdr.isManaged() ) - { - return true; - } - } - - return false; - } - - @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) - { - return NoneFilter.INSTANCE; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ( ( plugin == null ) ? 0 : plugin.hashCode() ); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( !super.equals( obj ) ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final PluginDependencyOnlyFilter other = (PluginDependencyOnlyFilter) obj; - if ( plugin == null ) - { - if ( other.plugin != null ) - { - return false; - } - } - else if ( !plugin.equals( other.plugin ) ) - { - return false; - } - return true; - } - - @Override - protected void renderIdAttributes( final StringBuilder sb ) - { - sb.append( ",plugin:" ) - .append( plugin ); - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginOnlyFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginOnlyFilter.java deleted file mode 100644 index 06dcbf8a..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginOnlyFilter.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; - -public class PluginOnlyFilter - extends AbstractTypedFilter -{ - - /** - * - */ - private static final long serialVersionUID = 1L; - - public PluginOnlyFilter() - { - this( false, true ); - } - - public PluginOnlyFilter( final boolean includeManaged, final boolean includeConcrete ) - { - super( RelationshipType.PLUGIN, false, includeManaged, includeConcrete ); - } - - @Override - public boolean doAccept( final ProjectRelationship rel ) - { - final PluginRelationship pr = (PluginRelationship) rel; - if ( includeManagedRelationships() && pr.isManaged() ) - { - return true; - } - else if ( includeConcreteRelationships() && !pr.isManaged() ) - { - return true; - } - - return false; - } - - @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) - { - return NoneFilter.INSTANCE; - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java deleted file mode 100644 index d57b54a1..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/PluginRuntimeFilter.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import java.util.HashSet; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; - -public class PluginRuntimeFilter - implements ProjectRelationshipFilter -{ - - /** - * - */ - private static final long serialVersionUID = 1L; - - public PluginRuntimeFilter() - { - } - - @Override - public boolean accept( final ProjectRelationship rel ) - { - return ( rel instanceof SimplePluginRelationship ) && !( (PluginRelationship) rel ).isManaged(); - } - - // TODO: Optimize to minimize new instance creation... - @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) - { - ProjectRelationshipFilter child; - if ( parent instanceof SimplePluginRelationship ) - { - final PluginRelationship plugin = (PluginRelationship) parent; - - child = - new OrFilter( new DependencyFilter( DependencyScope.runtime ), - new PluginDependencyFilter( plugin, true, true ), ParentFilter.EXCLUDE_TERMINAL_PARENTS ); - } - else - { - child = NoneFilter.INSTANCE; - } - - return child; - } - - @Override - public Set getDepExcludes() - { - return null; - } - - @Override - public String getLongId() - { - return "PLUGIN-RUNTIME"; - } - - @Override - public String toString() - { - return getLongId(); - } - - @Override - public String getCondensedId() - { - return getLongId(); - } - - @Override - public boolean includeManagedRelationships() - { - return false; - } - - @Override - public boolean includeConcreteRelationships() - { - return true; - } - - @Override - public Set getAllowedTypes() - { - final Set result = new HashSet(); - result.add( RelationshipType.PLUGIN ); - - // for descendants - result.add( RelationshipType.PARENT ); - result.add( RelationshipType.DEPENDENCY ); - result.add( RelationshipType.PLUGIN_DEP ); - - return result; - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ProjectRelationshipFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ProjectRelationshipFilter.java deleted file mode 100644 index 4443829b..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/ProjectRelationshipFilter.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import java.io.Serializable; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; - -/** - * Filter used to determine which paths in a dependency graph to traverse (or discover). - * The full dependency graph (relation dependency, not just maven-style dependency) - * will be QUITE extensive, so a filter should be used in NEARLY ALL cases. - * - * @author jdcasey - */ -public interface ProjectRelationshipFilter - extends Serializable -{ - - /** - * Determine whether the given relationship should be traversed. - * - * @param rel The relationship in question - * @return true to allow traversal, false otherwise. - */ - boolean accept( ProjectRelationship rel ); - - /** - * Return the filter used to handle the next wave of relationships after the - * given one is traversed. - * - * @param parent The parent relationship for the set of relationships to which - * the return filter from this method will be applied - * - * @return This instance WHENEVER POSSIBLE, but possibly a different filter - * if the relationship demands a shift in logic. - */ - ProjectRelationshipFilter getChildFilter( ProjectRelationship parent ); - - /** - * Provides set of dependency exclusions applied by this filter. It means only exclusions - * applied on dependency relationships, not subgraph exclusions, i.e. a changing set of with - * traversing the dependency graph, not the constant part which is provided as part of the - * request. - * - * @return the set of dependency exclusions, might be {@code null} - */ - Set getDepExcludes(); - - /** - * Retrieve a human-readable string that uniquely identifies the logic in this filter, - * along with any state stored in this instance. - */ - String getLongId(); - - /** - * Retrieve a condensed version of the human-readable identity given in {@link #getLongId()}. - * If the human-readable identity is sufficiently short (eg. "ANY"), then no - * hashing is required. - */ - String getCondensedId(); - - boolean includeManagedRelationships(); - - boolean includeConcreteRelationships(); - - Set getAllowedTypes(); - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/RelationshipTypeFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/RelationshipTypeFilter.java deleted file mode 100644 index 7270fe58..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/RelationshipTypeFilter.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import java.util.Collection; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; - -public class RelationshipTypeFilter - extends AbstractTypedFilter -{ - - private static final long serialVersionUID = 1L; - - public RelationshipTypeFilter( final Collection types, final boolean includeManagedInfo, - final boolean includeConcreteInfo ) - { - super( types, types, includeManagedInfo, includeManagedInfo ); - } - - public RelationshipTypeFilter( final Collection types, - final Collection descendantTypes, - final boolean includeManagedInfo, final boolean includeConcreteInfo ) - { - super( types, descendantTypes, includeManagedInfo, includeConcreteInfo ); - } - - public RelationshipTypeFilter( final RelationshipType type, final boolean hasDescendants, - final boolean includeManagedInfo, final boolean includeConcreteInfo ) - { - super( type, hasDescendants, includeManagedInfo, includeConcreteInfo ); - } - - public RelationshipTypeFilter( final RelationshipType type, final Collection descendantTypes, - final boolean includeManagedInfo, final boolean includeConcreteInfo ) - { - super( type, descendantTypes, includeManagedInfo, includeConcreteInfo ); - } - - public RelationshipTypeFilter( final RelationshipType type, final RelationshipType descendantType, - final boolean includeManagedInfo, final boolean includeConcreteInfo ) - { - super( type, descendantType, includeManagedInfo, includeConcreteInfo ); - } - - @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) - { - final Set descendantTypes = getDescendantRelationshipTypes(); - final Set allowedTypes = getAllowedTypes(); - if ( !allowedTypes.equals( descendantTypes ) ) - { - return new RelationshipTypeFilter( descendantTypes, includeManagedRelationships(), - includeConcreteRelationships() ); - } - - return this; - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/StructuralRelationshipsFilter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/StructuralRelationshipsFilter.java deleted file mode 100644 index 59e80b30..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/filter/StructuralRelationshipsFilter.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import static org.commonjava.maven.atlas.graph.rel.RelationshipType.BOM; -import static org.commonjava.maven.atlas.graph.rel.RelationshipType.PARENT; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; - -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; - -public final class StructuralRelationshipsFilter - extends AbstractTypedFilter -{ - - private static final Collection TYPES = - Collections.unmodifiableCollection( Arrays.asList( PARENT, BOM ) ); - - private static final long serialVersionUID = 1L; - - public static final StructuralRelationshipsFilter INSTANCE = new StructuralRelationshipsFilter(); - - private StructuralRelationshipsFilter() - { - super( TYPES, TYPES, false, true ); - } - - @Override - public ProjectRelationshipFilter getChildFilter( final ProjectRelationship parent ) - { - return this; - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java index 923511bf..5c2bc5a7 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java @@ -16,7 +16,6 @@ package org.commonjava.maven.atlas.graph.model; import static org.apache.commons.lang.StringUtils.join; -import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.filterTerminalParents; import java.util.ArrayList; import java.util.Arrays; @@ -29,6 +28,7 @@ import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; import org.commonjava.maven.atlas.graph.rel.RelationshipComparator; +import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; public class EProjectCycle @@ -172,7 +172,7 @@ public int indexOf( final ProjectVersionRef ref ) public Collection> getAllRelationships() { final Collection> rels = getExactAllRelationships(); - filterTerminalParents( rels ); + RelationshipUtils.filterTerminalParents( rels ); return rels; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java index b2ccb424..51be378c 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java @@ -15,6 +15,7 @@ */ package org.commonjava.maven.atlas.graph.model; +import static org.commonjava.maven.atlas.graph.rel.RelationshipConstants.POM_ROOT_URI; import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.filterTerminalParents; import java.io.Serializable; @@ -30,7 +31,6 @@ import java.util.Set; import org.commonjava.maven.atlas.graph.rel.*; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.DependencyScope; import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectRef; @@ -484,7 +484,7 @@ public Builder withPlugin( final ProjectVersionRef ref, final boolean managed, f public Builder withExtension( final ProjectVersionRef ref, final boolean inherited ) { - withExtensions( new SimpleExtensionRelationship( source, RelationshipUtils.POM_ROOT_URI, ref, ref, + withExtensions( new SimpleExtensionRelationship( source, POM_ROOT_URI, ref, ref, getNextExtensionIndex(), inherited ) ); return this; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPath.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPath.java deleted file mode 100644 index 50cf7f62..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPath.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.model; - -public interface GraphPath - extends Iterable -{ - String getKey(); -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPathInfo.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPathInfo.java deleted file mode 100644 index 9f745340..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/GraphPathInfo.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.model; - -import java.io.Serializable; - -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; -import org.commonjava.maven.atlas.graph.mutate.GraphMutator; -import org.commonjava.maven.atlas.graph.mutate.VersionManagerMutator; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; - -public final class GraphPathInfo - implements Serializable -{ - - private static final long serialVersionUID = 1L; - - private final ProjectRelationshipFilter filter; - - private final GraphMutator mutator; - - private transient RelationshipGraphConnection connection; - - private transient ViewParams params; - - public GraphPathInfo( final RelationshipGraphConnection connection, final ViewParams params ) - { - this.connection = connection; - this.params = params; - filter = params.getFilter(); - mutator = params.getMutator() == null ? new VersionManagerMutator() : params.getMutator(); - } - - public GraphPathInfo( final ProjectRelationshipFilter filter, final GraphMutator mutator, - final RelationshipGraphConnection connection, final ViewParams params ) - { - this.connection = connection; - this.params = params; - this.filter = filter; - this.mutator = mutator; - } - - public ProjectRelationshipFilter getFilter() - { - return filter; - } - - public GraphMutator getMutator() - { - return mutator; - } - - public ProjectRelationship selectRelationship( ProjectRelationship next, final GraphPath path ) - { - if ( filter != null && !filter.accept( next ) ) - { - return null; - } - - if ( mutator != null ) - { - next = mutator.selectFor( next, path, connection, params ); - } - - return next; - } - - public GraphPathInfo getChildPathInfo( final ProjectRelationship rel ) - { - final ProjectRelationshipFilter nextFilter = filter == null ? null : filter.getChildFilter( rel ); - final GraphMutator nextMutator = mutator == null ? null : mutator.getMutatorFor( rel, connection, params ); - if ( nextFilter == filter && nextMutator == mutator ) - { - return this; - } - - return new GraphPathInfo( nextFilter, nextMutator, connection, params ); - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ( ( filter == null ) ? 0 : filter.hashCode() ); - result = prime * result + ( ( mutator == null ) ? 0 : mutator.hashCode() ); - return result; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( obj == null ) - { - return false; - } - if ( getClass() != obj.getClass() ) - { - return false; - } - final GraphPathInfo other = (GraphPathInfo) obj; - if ( filter == null ) - { - if ( other.filter != null ) - { - return false; - } - } - else if ( !filter.equals( other.filter ) ) - { - return false; - } - if ( mutator == null ) - { - if ( other.mutator != null ) - { - return false; - } - } - else if ( !mutator.equals( other.mutator ) ) - { - return false; - } - return true; - } - - public String getKey() - { - return ( filter == null ? "none" : filter.getCondensedId() ) + "/" - + ( mutator == null ? "none" : mutator.getCondensedId() ); - } - - public void reattach( final RelationshipGraphConnection connection, final ViewParams params ) - { - this.connection = connection; - this.params = params; - } - - @Override - public String toString() - { - return String.format( "GraphPathInfo [filter=%s, mutator=%s, view=%s]", filter, mutator, params.getShortId() ); - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/GraphMutator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/GraphMutator.java deleted file mode 100644 index f9ffa3ab..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/GraphMutator.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.mutate; - -import java.io.Serializable; - -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; -import org.commonjava.maven.atlas.graph.model.GraphPath; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; - -/** - * Mechanism for selecting alternative relationships (especially by changing the - * target artifact/project), usually making use of version-management information - * injected by the user or accumulated during graph traversal. - * - * Child instances allow for shifts in mutator logic according to encounters with - * different types of relationships. They also allow incorporation of new - * version-management information by embedding new instances of - * {@link VersionManager}. - * - * @author jdcasey - */ -public interface GraphMutator - extends Serializable -{ - - /** - * Alter the relationship to be traversed next, using whatever mutation logic - * this class incorporates. For example, managed versions (a la <dependencyManagement/>) - * - * @param rel The relationship to process. - * @param path The path leading to this selection, which may contain management information, etc. - * @param connection The db connection for this graph - * @param params The parameters for the context "view" of this operation - * @return The alternative relationship, or the given one if no mutation - * takes place. - */ - ProjectRelationship selectFor( ProjectRelationship rel, GraphPath path, - RelationshipGraphConnection connection, ViewParams params ); - - /** - * If necessary, create a new mutator instance to handle the next wave of - * relationships resulting from traversal of the given relationship. - * - * @param rel The relationship that will be traversed next, for which mutator logic is needed. - * @param connection The db connection for this graph - * @param params The parameters for the context "view" of this operation - * - * @return This instance WHEREVER POSSIBLE, or a new mutator instance to - * encapsulate changing logic or metadata. NEVER Null. Decisions about - * whether to proceed should be handled via {@link ProjectRelationshipFilter}, - * not here. - */ - GraphMutator getMutatorFor( ProjectRelationship rel, RelationshipGraphConnection connection, ViewParams params ); - - /** - * Retrieve a human-readable string that uniquely identifies the logic in this mutator, - * along with any state stored in this instance. - */ - String getLongId(); - - /** - * Retrieve a condensed version of the human-readable identity given in {@link #getLongId()}. - * If the human-readable identity is sufficiently short (eg. "ANY"), then no - * hashing is required. - */ - String getCondensedId(); - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java deleted file mode 100644 index 445b3ab1..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/ManagedDependencyMutator.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.mutate; - -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.model.GraphPath; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; - -public class ManagedDependencyMutator - extends VersionManagerMutator - implements GraphMutator -{ - - public static final ManagedDependencyMutator INSTANCE = new ManagedDependencyMutator(); - - private static final long serialVersionUID = 1L; - - /** - * Hidden constructor. - */ - private ManagedDependencyMutator() - { - } - - @Override - public ProjectRelationship selectFor( final ProjectRelationship rel, final GraphPath path, - final RelationshipGraphConnection connection, final ViewParams params ) - { - if ( rel.getType() != RelationshipType.DEPENDENCY ) // TODO: BOM types?? - { - // logger.debug( "No selections for relationships of type: {}", rel.getType() ); - return rel; - } - - ProjectRelationship mutated = super.selectFor( rel, path, connection, params ); - if ( mutated == null || mutated == rel ) - { - final ProjectVersionRef managed = - connection.getManagedTargetFor( rel.getTarget(), path, RelationshipType.DEPENDENCY ); - if ( managed != null ) - { - mutated = rel.selectTarget( managed ); - } - } - - return mutated == null ? rel : mutated; - } -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java deleted file mode 100644 index 1b4b05d4..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/NoOpGraphMutator.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.mutate; - -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.model.GraphPath; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; - -public class NoOpGraphMutator - implements GraphMutator -{ - - private static final long serialVersionUID = 1L; - - public static final NoOpGraphMutator INSTANCE = new NoOpGraphMutator(); - - private NoOpGraphMutator() - { - } - - @Override - public ProjectRelationship selectFor( final ProjectRelationship rel, final GraphPath path, - final RelationshipGraphConnection connection, final ViewParams params ) - { - return rel; - } - - @Override - public GraphMutator getMutatorFor( final ProjectRelationship rel, final RelationshipGraphConnection connection, - final ViewParams params ) - { - return this; - } - - @Override - public String getLongId() - { - return "NOP"; - } - - @Override - public String getCondensedId() - { - return getLongId(); - } - - @Override - public String toString() - { - return getLongId(); - } - - @Override - public int hashCode() - { - return NoOpGraphMutator.class.hashCode() + 1; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( obj == null ) - { - return false; - } - return getClass() == obj.getClass(); - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java deleted file mode 100644 index 783859be..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/mutate/VersionManagerMutator.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.mutate; - -import org.apache.commons.codec.digest.DigestUtils; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.model.GraphPath; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; - -public class VersionManagerMutator - implements GraphMutator -{ - - private static final long serialVersionUID = 1L; - - private transient String longId; - - private transient String shortId; - - @Override - public ProjectRelationship selectFor( final ProjectRelationship rel, final GraphPath path, - final RelationshipGraphConnection connection, final ViewParams params ) - { - final ProjectRef target = rel.getTarget() - .asProjectRef(); - - if ( params != null ) - { - final ProjectVersionRef ref = params.getSelection( target ); - if ( ref != null ) - { - return rel.selectTarget( ref ); - } - } - - return rel; - } - - @Override - public GraphMutator getMutatorFor( final ProjectRelationship rel, final RelationshipGraphConnection connection, - final ViewParams params ) - { - return this; - } - - @Override - public int hashCode() - { - return getClass().hashCode() + 1; - } - - @Override - public boolean equals( final Object obj ) - { - if ( this == obj ) - { - return true; - } - if ( obj == null ) - { - return false; - } - return getClass() == obj.getClass(); - } - - @Override - public String getLongId() - { - if ( longId == null ) - { - final StringBuilder sb = new StringBuilder(); - final String abbreviatedPackage = getClass().getPackage() - .getName() - .replaceAll( "([a-zA-Z])[a-zA-Z]+", "$1" ); - - sb.append( abbreviatedPackage ) - .append( '.' ) - .append( getClass().getSimpleName() ); - - longId = sb.toString(); - } - - return longId; - } - - @Override - public String getCondensedId() - { - if ( shortId == null ) - { - shortId = DigestUtils.shaHex( getLongId() ); - } - - return shortId; - } - - @Override - public String toString() - { - return getLongId(); - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java index 5b2fbbe2..145619d5 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java @@ -24,7 +24,7 @@ import java.net.URI; import java.util.*; -import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.POM_ROOT_URI; +import static org.commonjava.maven.atlas.graph.rel.RelationshipConstants.POM_ROOT_URI; public abstract class AbstractSimpleProjectRelationship, T extends ProjectVersionRef> implements ProjectRelationship, Serializable diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparator.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparator.java index c3658d8b..2c90c4ea 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparator.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparator.java @@ -15,7 +15,7 @@ */ package org.commonjava.maven.atlas.graph.rel; -import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.POM_ROOT_URI; +import static org.commonjava.maven.atlas.graph.rel.RelationshipConstants.POM_ROOT_URI; import java.util.Comparator; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipConstants.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipConstants.java new file mode 100644 index 00000000..a295b0ec --- /dev/null +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipConstants.java @@ -0,0 +1,59 @@ +package org.commonjava.maven.atlas.graph.rel; + +import java.net.URI; +import java.net.URISyntaxException; + +/** + * Created by ruhan on 12/6/16. + */ +public class RelationshipConstants { + + public static final URI UNKNOWN_SOURCE_URI; + + public static final URI POM_ROOT_URI; + + public static final URI ANY_SOURCE_URI; + + public static final URI TERMINAL_PARENT_SOURCE_URI; + + static + { + final String uri = "atlas:terminal-parent"; + try + { + TERMINAL_PARENT_SOURCE_URI = new URI( uri ); + } + catch ( final URISyntaxException e ) + { + throw new IllegalStateException( "Terminal-parent source URI constant is invalid: " + uri, e ); + } + + try + { + ANY_SOURCE_URI = new URI( "any:any" ); + } + catch ( final URISyntaxException e ) + { + throw new IllegalStateException( "Cannot construct any-source URI: 'any:any'" ); + } + + try + { + UNKNOWN_SOURCE_URI = new URI( "unknown:unknown" ); + } + catch ( final URISyntaxException e ) + { + throw new IllegalStateException( "Cannot construct unknown-source URI: 'unknown:unknown'" ); + } + + try + { + POM_ROOT_URI = new URI( "pom:root" ); + } + catch ( final URISyntaxException e ) + { + throw new IllegalStateException( "Cannot construct pom-root URI: 'pom:root'" ); + } + } + +} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java index fb2837fb..1ccc864a 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java @@ -15,7 +15,6 @@ */ package org.commonjava.maven.atlas.graph.rel; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; @@ -50,14 +49,14 @@ public SimpleExtensionRelationship( final URI source, final ProjectVersionRef de final ProjectVersionRef target, final int index, final boolean inherited ) { - super( source, RelationshipUtils.POM_ROOT_URI, RelationshipType.EXTENSION, declaring, target, index, inherited, false ); + super( source, RelationshipConstants.POM_ROOT_URI, RelationshipType.EXTENSION, declaring, target, index, inherited, false ); } public SimpleExtensionRelationship( final Collection sources, final ProjectVersionRef declaring, final ProjectVersionRef target, final int index, final boolean inherited ) { - super( sources, RelationshipUtils.POM_ROOT_URI, RelationshipType.EXTENSION, declaring, target, index, inherited, false ); + super( sources, RelationshipConstants.POM_ROOT_URI, RelationshipType.EXTENSION, declaring, target, index, inherited, false ); } public SimpleExtensionRelationship( final ExtensionRelationship relationship ) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java index 0b5ed5f6..773dea48 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java @@ -15,7 +15,6 @@ */ package org.commonjava.maven.atlas.graph.rel; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; import org.commonjava.maven.atlas.ident.ref.ArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; @@ -38,7 +37,7 @@ public final class SimpleParentRelationship */ public SimpleParentRelationship( final ProjectVersionRef declaring ) { - super( RelationshipUtils.TERMINAL_PARENT_SOURCE_URI, RelationshipType.PARENT, declaring, declaring, 0, false, false ); + super( RelationshipConstants.TERMINAL_PARENT_SOURCE_URI, RelationshipType.PARENT, declaring, declaring, 0, false, false ); } /** @@ -49,7 +48,7 @@ public SimpleParentRelationship( final ProjectVersionRef declaring ) @Deprecated public SimpleParentRelationship( final URI unused, final ProjectVersionRef declaring ) { - super( RelationshipUtils.TERMINAL_PARENT_SOURCE_URI, RelationshipType.PARENT, declaring, declaring, 0, false, false ); + super( RelationshipConstants.TERMINAL_PARENT_SOURCE_URI, RelationshipType.PARENT, declaring, declaring, 0, false, false ); } public SimpleParentRelationship( final URI source, final ProjectVersionRef declaring, diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java deleted file mode 100644 index 4483c151..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnection.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi; - -import java.io.Closeable; -import java.io.IOException; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.model.EProjectCycle; -import org.commonjava.maven.atlas.graph.model.GraphPath; -import org.commonjava.maven.atlas.graph.model.GraphPathInfo; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.graph.traverse.RelationshipGraphTraversal; -import org.commonjava.maven.atlas.graph.traverse.TraversalType; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; - -public interface RelationshipGraphConnection - extends Closeable -{ - - /* - * ######################### - * Mutations are viewless - * ######################### - */ - - boolean addCycle( EProjectCycle cycle ) - throws RelationshipGraphConnectionException; - - void addDisconnectedProject( ProjectVersionRef ref ) - throws RelationshipGraphConnectionException; - - void addMetadata( ProjectVersionRef ref, String key, String value ) - throws RelationshipGraphConnectionException; - - void setMetadata( ProjectVersionRef ref, Map metadata ) - throws RelationshipGraphConnectionException; - - void deleteRelationshipsDeclaredBy( ProjectVersionRef root ) - throws RelationshipGraphConnectionException; - - /** - * Add the given relationships. Skip/return those that introduce cycles. - * - * @return The set of relationships that were NOT added because they introduce cycles. NEVER null, but maybe empty. - */ - Set> addRelationships( ProjectRelationship... rel ) - throws RelationshipGraphConnectionException; - - void addProjectError( ProjectVersionRef ref, String error ) - throws RelationshipGraphConnectionException; - - void clearProjectError( ProjectVersionRef ref ) - throws RelationshipGraphConnectionException; - - void recomputeIncompleteSubgraphs() - throws RelationshipGraphConnectionException; - - void reindex() - throws RelationshipGraphConnectionException; - - void reindex( final ProjectVersionRef ref ) - throws RelationshipGraphConnectionException; - - /* - * ################################################ - * Queries require a view - * --- - * View param is first to support vararg methods - * ################################################ - */ - - String getProjectError( ProjectVersionRef ref ); - - Collection> getRelationshipsDeclaredBy( ViewParams params, ProjectVersionRef root ); - - Collection> getRelationshipsTargeting( ViewParams params, ProjectVersionRef root ); - - Collection> getAllRelationships( ViewParams params ); - - Set>> getAllPathsTo( ViewParams params, ProjectVersionRef... projectVersionRefs ); - - boolean introducesCycle( ViewParams params, ProjectRelationship rel ); - - Set getAllProjects( ViewParams params ); - - void traverse( RelationshipGraphTraversal traversal, ProjectVersionRef root, RelationshipGraph graph, - TraversalType type ) - throws RelationshipGraphConnectionException; - - boolean containsProject( ViewParams params, ProjectVersionRef ref ); - - boolean containsRelationship( ViewParams params, ProjectRelationship rel ); - - boolean isMissing( ViewParams params, ProjectVersionRef project ); - - boolean hasMissingProjects( ViewParams params ); - - boolean hasProjectError( ProjectVersionRef ref ); - - Set getMissingProjects( ViewParams params ); - - boolean hasVariableProjects( ViewParams params ); - - Set getVariableProjects( ViewParams params ); - - Set getCycles( ViewParams params ); - - boolean isCycleParticipant( ViewParams params, ProjectRelationship rel ); - - boolean isCycleParticipant( ViewParams params, ProjectVersionRef ref ); - - Map getMetadata( ProjectVersionRef ref ); - - Map getMetadata( ProjectVersionRef ref, Set keys ); - - Set getProjectsWithMetadata( ViewParams params, String key ); - - @Deprecated - Set> getDirectRelationshipsFrom( ViewParams params, ProjectVersionRef from, - boolean includeManagedInfo, RelationshipType... types ); - - @Deprecated - Set> getDirectRelationshipsTo( ViewParams params, ProjectVersionRef to, - boolean includeManagedInfo, RelationshipType... types ); - - Set> getDirectRelationshipsFrom( ViewParams params, ProjectVersionRef from, - boolean includeManagedInfo, boolean includeConcreteInfo, - RelationshipType... types ); - - Set> getDirectRelationshipsTo( ViewParams params, ProjectVersionRef to, - boolean includeManagedInfo, boolean includeConcreteInfo, - RelationshipType... types ); - - Set getProjectsMatching( ViewParams params, ProjectRef projectRef ); - - void printStats(); - - ProjectVersionRef getManagedTargetFor( ProjectVersionRef target, GraphPath path, RelationshipType type ); - - GraphPath createPath( ProjectRelationship... relationships ); - - GraphPath createPath( GraphPath parent, ProjectRelationship relationship ); - - boolean registerView( ViewParams params ); - - void registerViewSelection( ViewParams params, ProjectRef ref, ProjectVersionRef projectVersionRef ); - - Map, GraphPathInfo> getPathMapTargeting( ViewParams params, Set refs ); - - ProjectVersionRef getPathTargetRef( GraphPath path ); - - List getPathRefs( ViewParams params, GraphPath path ); - - List> getRelationships( ViewParams params, GraphPath path ); - - boolean isClosed(); - - String getWorkspaceId(); - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionException.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionException.java deleted file mode 100644 index 834f16e4..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionException.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi; - -import org.commonjava.maven.atlas.graph.RelationshipGraphException; - -public class RelationshipGraphConnectionException - extends RelationshipGraphException -{ - - private static final long serialVersionUID = 1L; - - public RelationshipGraphConnectionException( final String message, final Throwable error, final Object... params ) - { - super( message, error, params ); - } - - public RelationshipGraphConnectionException( final String message, final Object... params ) - { - super( message, params ); - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionFactory.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionFactory.java deleted file mode 100644 index a82c8dcd..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/spi/RelationshipGraphConnectionFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.spi; - -import java.io.Closeable; -import java.io.IOException; -import java.util.Set; - -public interface RelationshipGraphConnectionFactory - extends Closeable -{ - - RelationshipGraphConnection openConnection( String workspaceId, boolean create ) - throws RelationshipGraphConnectionException; - - Set listWorkspaces(); - - void flush( RelationshipGraphConnection connection ) - throws RelationshipGraphConnectionException; - - boolean delete( String workspaceId ) - throws RelationshipGraphConnectionException; - - void close() - throws IOException; - - boolean exists( String workspaceId ); - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractFilteringTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractFilteringTraversal.java deleted file mode 100644 index 034f66bc..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractFilteringTraversal.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.traverse; - -import java.util.List; - -import org.commonjava.maven.atlas.graph.filter.AnyFilter; -import org.commonjava.maven.atlas.graph.filter.NoneFilter; -import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public abstract class AbstractFilteringTraversal - extends AbstractTraversal -{ - - private final ProjectRelationshipFilter rootFilter; - - protected AbstractFilteringTraversal() - { - rootFilter = AnyFilter.INSTANCE; - } - - protected AbstractFilteringTraversal( final ProjectRelationshipFilter filter ) - { - rootFilter = filter; - } - - protected abstract boolean shouldTraverseEdge( ProjectRelationship relationship, - List> path ); - - protected void edgeTraversalFinished( final ProjectRelationship relationship, - final List> path ) - { - } - - public final ProjectRelationshipFilter getRootFilter() - { - return rootFilter; - } - - @Override - public final void edgeTraversed( final ProjectRelationship relationship, final List> path ) - { - edgeTraversalFinished( relationship, path ); - } - - @Override - public final boolean traverseEdge( final ProjectRelationship relationship, - final List> path ) - { - Logger logger = LoggerFactory.getLogger( getClass() ); - if ( !preCheck( relationship, path ) ) - { - logger.debug("DON'T traverse: {}", relationship ); - return false; - } - - // seen.add( relationship ); - - final boolean ok = shouldTraverseEdge( relationship, path ); - logger.debug( "Traverse: {}?\n{}", relationship, ok ); - - return ok; - } - - @Override - public boolean preCheck( final ProjectRelationship relationship, final List> path ) - { - boolean result = true; - - final ProjectRelationshipFilter filter = constructFilter( path ); - if ( result && filter != null && !filter.accept( relationship ) ) - { - result = false; - } - - return result; - } - - private ProjectRelationshipFilter constructFilter( final List> path ) - { - if ( rootFilter == null ) - { - return null; - } - - ProjectRelationshipFilter filter = rootFilter; - for ( final ProjectRelationship rel : path ) - { - if ( !filter.accept( rel ) ) - { - return NoneFilter.INSTANCE; - } - else - { - filter = filter.getChildFilter( rel ); - } - } - - return filter; - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractTraversal.java deleted file mode 100644 index 06bf2e0a..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AbstractTraversal.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.traverse; - -import java.util.List; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; - -public abstract class AbstractTraversal - implements RelationshipGraphTraversal -{ - - - @Override - public void startTraverse( final RelationshipGraph graph ) - throws RelationshipGraphConnectionException - { - } - - @Override - public void endTraverse( final RelationshipGraph graph ) - throws RelationshipGraphConnectionException - { - } - - @Override - public void edgeTraversed( final ProjectRelationship relationship, final List> path ) - { - } - - @Override - public boolean traverseEdge( final ProjectRelationship relationship, final List> path ) - { - return preCheck( relationship, path ); - } -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AncestryTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AncestryTraversal.java deleted file mode 100644 index 0b2bf3ea..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/AncestryTraversal.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.traverse; - -import java.util.List; - -import org.commonjava.maven.atlas.graph.filter.ParentFilter; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; - -public class AncestryTraversal - extends FilteringTraversal -{ - - public AncestryTraversal() - { - super( ParentFilter.EXCLUDE_TERMINAL_PARENTS, true ); - } - - public List getAncestry() - { - return getCapturedProjects( true ); - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java deleted file mode 100644 index 1277ad45..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/BuildOrderTraversal.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.traverse; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.filter.OrFilter; -import org.commonjava.maven.atlas.graph.filter.ParentFilter; -import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; -import org.commonjava.maven.atlas.graph.model.EProjectCycle; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; -import org.commonjava.maven.atlas.graph.traverse.model.BuildOrder; -import org.commonjava.maven.atlas.ident.ref.*; - -public class BuildOrderTraversal - extends AbstractFilteringTraversal -{ - - private final List order = new ArrayList(); - - private Set cycles; - - private Set allowedProjects; - - public BuildOrderTraversal() - { - } - - public BuildOrderTraversal( final ProjectRelationshipFilter filter ) - { - super( new OrFilter( filter, ParentFilter.EXCLUDE_TERMINAL_PARENTS ) ); - } - - public BuildOrderTraversal( final Set allowedProjects ) - { - this.allowedProjects = allowedProjects; - } - - public BuildOrder getBuildOrder() - { - return new BuildOrder( order, cycles ); - } - - @Override - protected boolean shouldTraverseEdge( final ProjectRelationship relationship, - final List> path ) - { - if ( !verifyProjectsAllowed( relationship, path ) ) - { - return false; - } - - final ProjectVersionRef decl = relationship.getDeclaring(); - - ProjectVersionRef target = relationship.getTarget(); - if ( target instanceof ArtifactRef ) - { - target = ( (ArtifactRef) target ).asProjectVersionRef(); - } - - final ProjectRef baseDecl = new SimpleProjectRef( decl.getGroupId(), decl.getArtifactId() ); - final ProjectRef baseTgt = new SimpleProjectRef( target.getGroupId(), target.getArtifactId() ); - - int declIdx = order.indexOf( baseDecl ); - final int tgtIdx = order.indexOf( baseTgt ); - if ( declIdx < 0 ) - { - declIdx = order.size(); - order.add( baseDecl ); - } - - if ( tgtIdx < 0 ) - { - order.add( declIdx, baseTgt ); - } - - return true; - } - - private boolean verifyProjectsAllowed( final ProjectRelationship relationship, - final List> path ) - { - if ( allowedProjects == null ) - { - return true; - } - else if ( allowedProjects.isEmpty() ) - { - return false; - } - - if ( !verifyRelationshipProjectsAllowed( relationship ) ) - { - return false; - } - - for ( final ProjectRelationship rel : path ) - { - if ( !verifyRelationshipProjectsAllowed( rel ) ) - { - return false; - } - } - - return true; - } - - private boolean verifyRelationshipProjectsAllowed( final ProjectRelationship relationship ) - { - return allowedProjects == null - || ( allowedProjects.contains( relationship.getDeclaring() ) && allowedProjects.contains( relationship.getTarget() ) ); - } - - @Override - public void endTraverse( final RelationshipGraph graph ) - throws RelationshipGraphConnectionException - { - super.endTraverse( graph ); - - Set cycles = graph.getCycles(); - if ( cycles != null ) - { - cycles = new HashSet( cycles ); - for ( final Iterator iterator = cycles.iterator(); iterator.hasNext(); ) - { - final EProjectCycle eProjectCycle = iterator.next(); - ProjectRelationshipFilter filter = getRootFilter(); - - boolean include = true; - for ( final ProjectRelationship rel : eProjectCycle ) - { - if ( !filter.accept( rel ) ) - { - include = false; - break; - } - - filter = filter.getChildFilter( rel ); - } - - if ( !include ) - { - iterator.remove(); - } - } - - } - - this.cycles = cycles; - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/FilteringTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/FilteringTraversal.java deleted file mode 100644 index c77ca52f..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/FilteringTraversal.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.traverse; - -import java.util.ArrayList; -import java.util.List; - -import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; - -public class FilteringTraversal - extends AbstractFilteringTraversal -{ - - private final List> captured = new ArrayList>(); - - private final boolean doCapture; - - public FilteringTraversal( final ProjectRelationshipFilter filter ) - { - this( filter, false ); - } - - public FilteringTraversal( final ProjectRelationshipFilter filter, final boolean doCapture ) - { - super( filter ); - this.doCapture = doCapture; - } - - public List> getCapturedRelationships() - { - return captured; - } - - public List getCapturedProjects( final boolean unique ) - { - final List refs = new ArrayList(); - for ( final ProjectRelationship rel : captured ) - { - final ProjectVersionRef d = rel.getDeclaring(); - final ProjectVersionRef t = rel.getTarget() - .asProjectVersionRef(); - - if ( !unique || !refs.contains( d ) ) - { - refs.add( d ); - } - - if ( !unique || !refs.contains( t ) ) - { - refs.add( t ); - } - } - - return refs; - } - - @Override - protected boolean shouldTraverseEdge( final ProjectRelationship relationship, - final List> path ) - { - if ( doCapture ) - { - captured.add( relationship ); - } - return true; - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/ImpactTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/ImpactTraversal.java deleted file mode 100644 index 278337b9..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/ImpactTraversal.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.traverse; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; - -public class ImpactTraversal - extends AbstractTraversal -{ - - private final Map>>> impactedPaths = - new HashMap>>>(); - - private final boolean includeManagedInfo; - - public ImpactTraversal( final ProjectVersionRef... targets ) - { - this( false, targets ); - } - - public ImpactTraversal( final boolean includeManagedInfo, final ProjectVersionRef... targets ) - { - this.includeManagedInfo = includeManagedInfo; - for ( final ProjectVersionRef target : targets ) - { - impactedPaths.put( target, new HashSet>>() ); - } - } - - public ImpactTraversal( final Set targets ) - { - this( false, targets ); - } - - public ImpactTraversal( final boolean includeManagedInfo, final Set targets ) - { - this.includeManagedInfo = includeManagedInfo; - for ( final ProjectVersionRef target : targets ) - { - impactedPaths.put( target, new HashSet>>() ); - } - } - - public Map>>> getImpactedPaths() - { - return impactedPaths; - } - - @Override - public boolean traverseEdge( final ProjectRelationship relationship, final List> path ) - { - if ( !preCheck( relationship, path ) ) - { - return false; - } - - final ProjectVersionRef target = relationship.getTarget() - .asProjectVersionRef(); - final Set>> paths = impactedPaths.get( target ); - final ArrayList> p = new ArrayList>( path ); - p.add( relationship ); - - paths.add( p ); - - // we may yet encounter the impact targets, so allow this traverse to proceed. - return true; - } - - @Override - public boolean preCheck( final ProjectRelationship relationship, final List> path ) - { - if ( !includeManagedInfo ) - { - if ( relationship instanceof DependencyRelationship - && ( (DependencyRelationship) relationship ).isManaged() ) - { - return false; - } - - if ( relationship instanceof PluginRelationship && ( (PluginRelationship) relationship ).isManaged() ) - { - return false; - } - } - - final Set>> paths = impactedPaths.get( relationship.getTarget() - .asProjectVersionRef() ); - return !( paths != null && paths.isEmpty() ); - - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java deleted file mode 100644 index c799fd81..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/PathsTraversal.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.traverse; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.filter.OrFilter; -import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; - -/** - * Dependency graph traversal ({@link ProjectNetTraversal}) implementation used - * to determine the paths between two GAVs or sets of GAVs in a graph. - * - * @author jdcasey - * @author pkocandr - */ -public class PathsTraversal -extends AbstractTraversal -{ - - private final ProjectRelationshipFilter rootFilter; - - private final Set to; - - private final Map cache = new HashMap(); - - private final Set>> paths = new HashSet>>(); - - public PathsTraversal( final ProjectRelationshipFilter filter, final Set toGas ) - { - this.rootFilter = filter; - this.to = toGas; - } - - @Override - public boolean preCheck( final ProjectRelationship relationship, final List> path ) - { - final ProjectVersionRef declaring = relationship.getDeclaring().asProjectVersionRef(); - if ( path.isEmpty() || path.get( path.size() - 1 ).getTarget().asProjectVersionRef().equals( declaring ) ) - { - final ProjectRef dRef = declaring.asProjectRef(); - - ProjectRelationshipFilter filter = cache.get( dRef ); - if ( filter == null ) - { - filter = rootFilter; - } - - if ( filter.accept( relationship ) ) - { - final ProjectRef tRef = relationship.getTarget() - .asProjectRef(); - - final ProjectRelationshipFilter child = filter.getChildFilter( relationship ); - final OrFilter f = cache.get( tRef ); - if ( f == null ) - { - if ( child instanceof OrFilter ) - { - cache.put( tRef, (OrFilter) child ); - } - else - { - cache.put( tRef, new OrFilter( child ) ); - } - } - else - { - final Set filters = - new HashSet( f.getFilters() ); - if ( child instanceof OrFilter ) - { - final List childFilters = - ( (OrFilter) child ).getFilters(); - if ( !filters.containsAll( childFilters ) ) - { - filters.addAll( childFilters ); - cache.put( tRef, new OrFilter( filters ) ); - } - } - else - { - if ( !filters.contains( child ) ) - { - filters.add( child ); - cache.put( tRef, new OrFilter( filters ) ); - } - } - } - - if ( to.contains( tRef ) ) - { - final List> realPath = new ArrayList>( path ); - realPath.add( relationship ); - paths.add( realPath ); - } - - return true; - } - } - - return false; - } - - public Set>> getDiscoveredPaths() - { - return paths; - } - -// @Override -// public boolean traverseEdge( final ProjectRelationship relationship, final List> path ) -// { -// return false; -// } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/RelationshipGraphTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/RelationshipGraphTraversal.java deleted file mode 100644 index 454dcc59..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/RelationshipGraphTraversal.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.traverse; - -import java.util.List; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; - -public interface RelationshipGraphTraversal -{ - - void startTraverse( RelationshipGraph graph ) - throws RelationshipGraphConnectionException; - - void endTraverse( RelationshipGraph graph ) - throws RelationshipGraphConnectionException; - - boolean traverseEdge( ProjectRelationship relationship, List> path ); - - void edgeTraversed( ProjectRelationship relationship, List> path ); - - boolean preCheck( ProjectRelationship relationship, List> path ); -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java deleted file mode 100644 index 6749eb71..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TransitiveDependencyTraversal.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.traverse; - -import org.commonjava.maven.atlas.graph.filter.DependencyFilter; -import org.commonjava.maven.atlas.graph.filter.OrFilter; -import org.commonjava.maven.atlas.graph.filter.ParentFilter; -import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; -import org.commonjava.maven.atlas.graph.rel.*; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleVersionlessArtifactRef; -import org.commonjava.maven.atlas.ident.ref.VersionlessArtifactRef; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; - -public class TransitiveDependencyTraversal - extends AbstractFilteringTraversal -{ - - private final Logger logger = LoggerFactory.getLogger( getClass() ); - - private final Map artifacts = new LinkedHashMap(); - - private final Map seenArtifacts = new HashMap(); - - public TransitiveDependencyTraversal() - { - this( DependencyScope.runtime ); - } - - public TransitiveDependencyTraversal( final ProjectRelationshipFilter filter ) - { - super( filter ); - } - - public TransitiveDependencyTraversal( final DependencyScope scope ) - { - super( new OrFilter( new DependencyFilter( scope ), ParentFilter.EXCLUDE_TERMINAL_PARENTS ) ); - } - - public List getArtifacts() - { - return Collections.unmodifiableList( new ArrayList( artifacts.values() ) ); - } - - @Override - public boolean shouldTraverseEdge( final ProjectRelationship relationship, - final List> path ) - { - boolean result = false; - if ( relationship instanceof DependencyRelationship ) - { - final ArtifactRef target = (ArtifactRef) relationship.getTarget(); - final VersionlessArtifactRef versionlessTarget = new SimpleVersionlessArtifactRef( target ); - - final Integer distance = seenArtifacts.get( versionlessTarget ); - logger.debug( "Checking for seen versionless GA[TC]: {}\nStored distance: {}\nPath distance: {}", versionlessTarget, distance, path.size() ); - if ( distance == null || distance > path.size() ) - { - logger.debug( "Adding: {} ({})", target, versionlessTarget ); - artifacts.put( versionlessTarget, target ); - seenArtifacts.put( versionlessTarget, path.size() ); - result = true; - } - } - else if ( relationship instanceof ParentRelationship ) - { - result = true; - } - - return result; - } -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TraversalType.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TraversalType.java deleted file mode 100644 index 559453d8..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/TraversalType.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.traverse; - -public enum TraversalType -{ - - depth_first, breadth_first - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/model/BuildOrder.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/model/BuildOrder.java deleted file mode 100644 index d749dbf3..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/model/BuildOrder.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.traverse.model; - -import java.util.Collections; -import java.util.List; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.model.EProjectCycle; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; - -public final class BuildOrder -{ - - private List order; - - private Set cycles; - - public BuildOrder(){} - - public BuildOrder( final List order, final Set cycles ) - { - this.order = Collections.unmodifiableList( order ); - this.cycles = cycles == null ? null : Collections.unmodifiableSet( cycles ); - } - - public List getOrder() - { - return order; - } - - public Set getCycles() - { - return cycles; - } - - public void setOrder( List order ) - { - this.order = order; - } - - public void setCycles( Set cycles ) - { - this.cycles = cycles; - } -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/DependencyTreeRelationshipPrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/DependencyTreeRelationshipPrinter.java deleted file mode 100644 index 2abd9548..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/DependencyTreeRelationshipPrinter.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.traverse.print; - -import java.io.PrintWriter; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipType; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; - -public class DependencyTreeRelationshipPrinter - implements StructureRelationshipPrinter -{ - - private final Set missing; - - public DependencyTreeRelationshipPrinter() - { - missing = null; - } - - public DependencyTreeRelationshipPrinter( final Set missing ) - { - this.missing = missing; - } - - @Override - public void print( final ProjectRelationship relationship, final ProjectVersionRef selectedTarget, - final PrintWriter writer, final Map> labels, final int depth, - final String indent ) - { - indent( writer, depth, indent ); - - final RelationshipType type = relationship.getType(); - - final ProjectVersionRef originalTarget = relationship.getTarget() - .asProjectVersionRef(); - - ProjectVersionRef target = null; - ArtifactRef targetArtifact = relationship.getTargetArtifact(); - - if ( selectedTarget == null ) - { - target = originalTarget; - } - else - { - target = selectedTarget; - targetArtifact = selectedTarget.asArtifactRef( targetArtifact.getTypeAndClassifier() ); - } - - final Set localLabels = new HashSet(); - - String suffix = null; - if ( type == RelationshipType.DEPENDENCY ) - { - final DependencyRelationship dr = (DependencyRelationship) relationship; - suffix = ":" + dr.getScope() - .name(); - - if ( dr.isOptional() ) - { - localLabels.add( "OPTIONAL" ); - } - - // writer.print( " [idx: " ) - // .append( relationship.getIndex() ) - // .append( ']' ); - } - else - { - localLabels.add( type.name() ); - } - - printProjectVersionRef( targetArtifact, writer, suffix, labels, localLabels ); - - if ( !target.equals( originalTarget ) ) - { - writer.print( " [was: " ); - writer.print( originalTarget ); - writer.print( "]" ); - } - - if ( missing != null && missing.contains( target ) ) - { - writer.print( '\n' ); - indent( writer, depth + 1, indent ); - writer.print( "???" ); - } - } - - @Override - public void printProjectVersionRef( final ProjectVersionRef targetArtifact, final PrintWriter writer, - final String targetSuffix, final Map> labels, - final Set localLabels ) - { - // the original could be an artifact ref! - final ProjectVersionRef target = targetArtifact.asProjectVersionRef(); - - writer.print( targetArtifact ); - if ( targetSuffix != null ) - { - writer.print( targetSuffix ); - } - - boolean hasLabel = false; - if ( localLabels != null && !localLabels.isEmpty() ) - { - hasLabel = true; - writer.print( " (" ); - - boolean first = true; - for ( final String label : localLabels ) - { - if ( first ) - { - first = false; - } - else - { - writer.print( ", " ); - } - - writer.print( label ); - } - } - - for ( final Entry> entry : labels.entrySet() ) - { - final String label = entry.getKey(); - final Set refs = entry.getValue(); - - if ( refs.contains( target ) ) - { - if ( !hasLabel ) - { - hasLabel = true; - writer.print( " (" ); - } - else - { - writer.print( ", " ); - } - - writer.print( label ); - } - - } - - if ( hasLabel ) - { - writer.print( ')' ); - } - } - - private void indent( final PrintWriter writer, final int depth, final String indent ) - { - for ( int i = 0; i < depth; i++ ) - { - writer.print( indent ); - } - } -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java deleted file mode 100644 index 04740189..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/ListPrinter.java +++ /dev/null @@ -1,167 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.traverse.print; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Stack; - -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; - -public class ListPrinter -{ - - // private final Logger logger = new Logger( getClass() ); - - private final StructureRelationshipPrinter relationshipPrinter; - - // private final Set seen = new HashSet(); - - public ListPrinter() - { - this.relationshipPrinter = new TargetRefPrinter(); - } - - public ListPrinter( final StructureRelationshipPrinter relationshipPrinter ) - { - this.relationshipPrinter = relationshipPrinter; - } - - public void printStructure( final ProjectVersionRef from, - final Map>> links, - final Map> labels, PrintWriter writer ) - { - printStructure( from, links, null, null, labels, writer ); - } - - public void printStructure( final ProjectVersionRef from, - final Map>> links, final String header, - final String footer, final Map> labels, - PrintWriter writer ) - { - if ( header != null ) - { - writer.print( header ); - } - - writer.print( " " ); - relationshipPrinter.printProjectVersionRef( from, writer, null, labels, null ); - // writer.print( from ); - - final Set lines = new LinkedHashSet(); - - printLinks( from, lines, links, labels, new HashSet(), new Stack() ); - - final List sorted = new ArrayList( lines ); - Collections.sort( sorted ); - - for ( final String line : sorted ) - { - writer.print( "\n " ); - writer.print( line ); - } - writer.print( "\n" ); - - if ( footer != null ) - { - writer.print( footer ); - } - } - - private void printLinks( final ProjectVersionRef from, final Set lines, - final Map>> links, - final Map> labels, final Set excluded, - final Stack inPath ) - { - inPath.push( from ); - - final List> outbound = links.get( from ); - if ( outbound != null ) - { - StringWriter sw; - for ( final ProjectRelationship out : outbound ) - { - sw = new StringWriter(); - - ProjectVersionRef outRef = out.getTarget() - .asProjectVersionRef(); - if ( inPath.contains( outRef ) ) - { - continue; - } - - if ( excluded.contains( outRef ) ) - { - continue; - } - // TODO: Reinstate transitive collapse IF we can find a way to make output consistent. - // else if ( !seen.add( out.getTarget() - // .asProjectRef() ) ) - // { - // return; - // } - - relationshipPrinter.print( out, null, new PrintWriter( sw ), labels, 0, "" ); - lines.add( sw.toString() ); - - if ( !from.equals( out.getTarget() - .asProjectRef() ) ) - { - Set newExcluded = null; - if ( out instanceof SimpleDependencyRelationship ) - { - final Set excludes = ( (DependencyRelationship) out ).getExcludes(); - if ( excludes != null && !excludes.isEmpty() ) - { - newExcluded = new HashSet(); - for ( final ProjectRef ref : excludes ) - { - if ( !RelationshipUtils.isExcluded( ref, excluded ) ) - { - newExcluded.add( ref ); - excluded.add( ref ); - } - } - } - } - - printLinks( out.getTarget() - .asProjectVersionRef(), lines, links, labels, excluded, inPath ); - - if ( newExcluded != null && !newExcluded.isEmpty() ) - { - excluded.removeAll( newExcluded ); - } - } - } - } - - inPath.pop(); - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructurePrintingTraversal.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructurePrintingTraversal.java deleted file mode 100644 index 4069347a..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructurePrintingTraversal.java +++ /dev/null @@ -1,226 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.traverse.print; - -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Stack; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; -import org.commonjava.maven.atlas.graph.traverse.RelationshipGraphTraversal; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; - -// TODO: Replace with getAllRelationships(), map to declaring GAV, and then printStructure based on that. -// Letting the filter in the graph view shape what's in getAllRelationships()... -public class StructurePrintingTraversal - implements RelationshipGraphTraversal -{ - - // private final Logger logger = new Logger( getClass() ); - - private final RelationshipGraphTraversal traversal; - - private final StructureRelationshipPrinter relationshipPrinter; - - private final Map>> outboundLinks = new HashMap>>(); - - public StructurePrintingTraversal() - { - this.traversal = null; - this.relationshipPrinter = new TargetRefPrinter(); - } - - public StructurePrintingTraversal( final RelationshipGraphTraversal traversal ) - { - this.traversal = traversal; - this.relationshipPrinter = new TargetRefPrinter(); - } - - public StructurePrintingTraversal( final StructureRelationshipPrinter relationshipPrinter ) - { - this.traversal = null; - this.relationshipPrinter = relationshipPrinter; - } - - public StructurePrintingTraversal( final RelationshipGraphTraversal traversal, final StructureRelationshipPrinter relationshipPrinter ) - { - this.traversal = traversal; - this.relationshipPrinter = relationshipPrinter; - } - - @Override - public boolean traverseEdge( final ProjectRelationship relationship, final List> path ) - { - if ( traversal == null || traversal.traverseEdge( relationship, path ) ) - { - List> outbound = outboundLinks.get( relationship.getDeclaring() ); - if ( outbound == null ) - { - outbound = new ArrayList>(); - outboundLinks.put( relationship.getDeclaring(), outbound ); - } - - if ( !outbound.contains( relationship ) ) - { - outbound.add( relationship ); - } - - return true; - } - - return false; - } - - public void printStructure( final ProjectVersionRef from, final Map> labels, - final PrintWriter writer ) - { - printStructure( from, null, null, " ", labels, writer ); - } - - public void printStructure( final ProjectVersionRef from, final String indent, - final Map> labels, final PrintWriter writer ) - { - printStructure( from, null, null, indent, labels, writer ); - } - - public void printStructure( final ProjectVersionRef from, final String header, final String footer, - final String indent, final Map> labels, - final PrintWriter writer ) - { - if ( header != null ) - { - writer.print( header ); - } - - writer.print( "\n" ); - writer.print( from ); - - printLinks( from, writer, indent, 1, labels, new HashSet(), new Stack() ); - writer.print( "\n" ); - - if ( footer != null ) - { - writer.print( footer ); - } - } - - private void printLinks( final ProjectVersionRef from, final PrintWriter writer, final String indent, - final int depth, final Map> labels, - final Set excluded, final Stack inPath ) - { - inPath.push( from ); - final List> outbound = outboundLinks.get( from ); - if ( outbound != null ) - { - for ( final ProjectRelationship out : outbound ) - { - final ProjectVersionRef outRef = out.getTarget() - .asProjectVersionRef(); - if ( inPath.contains( outRef ) ) - { - continue; - } - - if ( excluded.contains( outRef ) ) - { - continue; - } - - writer.append( "\n" ); - - relationshipPrinter.print( out, null, writer, labels, depth, indent ); - - if ( !from.equals( out.getTarget() - .asProjectVersionRef() ) ) - { - Set newExcluded = null; - if ( out instanceof SimpleDependencyRelationship ) - { - final Set excludes = ( (DependencyRelationship) out ).getExcludes(); - if ( excludes != null && !excludes.isEmpty() ) - { - newExcluded = new HashSet(); - for ( final ProjectRef ref : excludes ) - { - if ( !RelationshipUtils.isExcluded( ref, excluded ) ) - { - newExcluded.add( ref ); - excluded.add( ref ); - } - } - } - } - - printLinks( out.getTarget() - .asProjectVersionRef(), writer, indent, depth + 1, labels, excluded, inPath ); - - if ( newExcluded != null && !newExcluded.isEmpty() ) - { - excluded.removeAll( newExcluded ); - } - } - } - } - inPath.pop(); - } - - @Override - public boolean preCheck( final ProjectRelationship relationship, final List> path ) - { - return traversal == null || traversal.preCheck( relationship, path ); - } - - @Override - public void startTraverse( final RelationshipGraph graph ) - throws RelationshipGraphConnectionException - { - if ( traversal != null ) - { - traversal.startTraverse( graph ); - } - } - - @Override - public void endTraverse( final RelationshipGraph graph ) - throws RelationshipGraphConnectionException - { - if ( traversal != null ) - { - traversal.endTraverse( graph ); - } - } - - @Override - public void edgeTraversed( final ProjectRelationship relationship, final List> path ) - { - if ( traversal != null ) - { - traversal.edgeTraversed( relationship, path ); - } - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructureRelationshipPrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructureRelationshipPrinter.java deleted file mode 100644 index 0767d02d..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/StructureRelationshipPrinter.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.traverse.print; - -import java.io.PrintWriter; -import java.util.Map; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; - -public interface StructureRelationshipPrinter -{ - void print( ProjectRelationship relationship, ProjectVersionRef targetOverride, PrintWriter writer, - Map> labels, int depth, String indent ); - - void printProjectVersionRef( ProjectVersionRef targetArtifact, PrintWriter writer, String targetSuffix, - Map> labels, Set localLabels ); -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TargetRefPrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TargetRefPrinter.java deleted file mode 100644 index c4f890dc..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TargetRefPrinter.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.traverse.print; - -import java.io.PrintWriter; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; - -public final class TargetRefPrinter - implements StructureRelationshipPrinter -{ - - @Override - public void print( final ProjectRelationship relationship, final ProjectVersionRef selectedTarget, - final PrintWriter writer, final Map> labels, final int depth, - final String indent ) - { - for ( int i = 0; i < depth; i++ ) - { - writer.print( indent ); - } - - final ProjectVersionRef originalTarget = relationship.getTarget() - .asProjectVersionRef(); - final ProjectVersionRef target = selectedTarget == null ? originalTarget : selectedTarget; - - printProjectVersionRef( target, writer, null, labels, null ); - - if ( target != originalTarget ) - { - writer.print( " [was: " ); - writer.print( originalTarget ); - writer.print( "]" ); - } - } - - @Override - public void printProjectVersionRef( final ProjectVersionRef target, final PrintWriter writer, - final String targetSuffix, final Map> labels, - final Set localLabels ) - { - writer.print( target ); - if ( targetSuffix != null ) - { - writer.print( targetSuffix ); - } - - boolean hasLabel = false; - for ( final Entry> entry : labels.entrySet() ) - { - final String label = entry.getKey(); - final Set refs = entry.getValue(); - - if ( refs.contains( target ) ) - { - if ( !hasLabel ) - { - hasLabel = true; - writer.print( " (" ); - } - else - { - writer.print( ", " ); - } - - writer.print( label ); - } - - } - - if ( hasLabel ) - { - writer.print( ')' ); - } - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java deleted file mode 100644 index 585f92dd..00000000 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/traverse/print/TreePrinter.java +++ /dev/null @@ -1,185 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.traverse.print; - -import java.io.PrintWriter; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Stack; - -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; - -public class TreePrinter -{ - - // private final Logger logger = LoggerFactory.getLogger( getClass() ); - - private final StructureRelationshipPrinter relationshipPrinter; - - // private final boolean collapseTransitives; - - // private final Set seen = new HashSet(); - - private final Map selected = new HashMap(); - - public TreePrinter() - { - this.relationshipPrinter = new TargetRefPrinter(); - // this.collapseTransitives = true; - } - - public TreePrinter( final StructureRelationshipPrinter relationshipPrinter ) - { - this.relationshipPrinter = relationshipPrinter; - } - - // TODO: Reinstate transitive collapse IF we can find a way to make output consistent. - // public TreePrinter( final StructureRelationshipPrinter relationshipPrinter, final boolean collapseTransitives ) - // { - // this.relationshipPrinter = relationshipPrinter; - // this.collapseTransitives = collapseTransitives; - // } - - public void printStructure( final ProjectVersionRef from, - final Map>> links, - final Map> labels, final PrintWriter writer ) - { - printStructure( from, links, null, null, " ", labels, writer ); - } - - public void printStructure( final ProjectVersionRef from, - final Map>> links, - final String indent, - final Map> labels, final PrintWriter writer ) - { - printStructure( from, links, null, null, indent, labels, writer ); - } - - public void printStructure( final ProjectVersionRef from, - final Map>> links, - final String header, final String footer, final String indent, - final Map> labels, final PrintWriter writer ) - { - if ( header != null ) - { - writer.print( header ); - } - - writer.print( "\n" ); - relationshipPrinter.printProjectVersionRef( from, writer, null, labels, null ); - // writer.print( from ); - - printLinks( from, writer, indent, 1, links, labels, new HashSet(), new Stack() ); - writer.print( "\n" ); - - if ( footer != null ) - { - writer.print( footer ); - } - } - - private void printLinks( final ProjectVersionRef from, final PrintWriter writer, final String indent, - final int depth, final Map>> links, - final Map> labels, final Set excluded, - final Stack inPath ) - { - inPath.push( from ); - selected.put( from.asProjectRef(), from ); - - final List> outbound = links.get( from ); - if ( outbound != null ) - { - for ( final ProjectRelationship out : outbound ) - { - final ProjectVersionRef outRef = out.getTarget() - .asProjectVersionRef(); - if ( inPath.contains( outRef ) ) - { - continue; - } - - if ( excluded.contains( out.getTarget() - .asProjectVersionRef() ) ) - { - continue; - } - - // TODO: Reinstate transitive collapse IF we can find a way to make output consistent. - // else if ( collapseTransitives && !seen.add( out.getTarget() - // .asProjectRef() ) ) - // { - // return; - // } - - writer.append( "\n" ); - - final ProjectVersionRef selection = selected.get( out.getTarget() - .asProjectRef() ); - - if ( selection == null ) - { - selected.put( out.getTarget() - .asProjectRef(), selection ); - } - - relationshipPrinter.print( out, selection, writer, labels, depth, indent ); - - if ( ( selection == null || selection.equals( out.getTarget() - .asProjectVersionRef() ) ) - && !from.equals( out.getTarget() - .asProjectVersionRef() ) ) - { - Set newExcluded = null; - if ( out instanceof SimpleDependencyRelationship ) - { - final Set excludes = ( (DependencyRelationship) out ).getExcludes(); - if ( excludes != null && !excludes.isEmpty() ) - { - newExcluded = new HashSet(); - for ( final ProjectRef ref : excludes ) - { - if ( !RelationshipUtils.isExcluded( ref, excluded ) ) - { - newExcluded.add( ref ); - excluded.add( ref ); - } - } - } - } - - printLinks( out.getTarget() - .asProjectVersionRef(), writer, indent, depth + 1, links, labels, excluded, inPath ); - - if ( newExcluded != null && !newExcluded.isEmpty() ) - { - excluded.removeAll( newExcluded ); - } - } - } - } - - inPath.pop(); - } - -} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java index 39b7492c..10d0da82 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java @@ -16,403 +16,22 @@ package org.commonjava.maven.atlas.graph.util; import static org.commonjava.maven.atlas.ident.util.IdentityUtils.artifact; -import static org.commonjava.maven.atlas.ident.util.IdentityUtils.projectVersion; import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.commonjava.maven.atlas.graph.filter.AbstractAggregatingFilter; -import org.commonjava.maven.atlas.graph.filter.AbstractTypedFilter; -import org.commonjava.maven.atlas.graph.filter.AnyFilter; -import org.commonjava.maven.atlas.graph.filter.ProjectRelationshipFilter; import org.commonjava.maven.atlas.graph.rel.*; import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.util.JoinString; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public final class RelationshipUtils { - private RelationshipUtils() - { - } - - public static final URI UNKNOWN_SOURCE_URI; - - public static final URI POM_ROOT_URI; - - public static URI ANY_SOURCE_URI; - - public static URI TERMINAL_PARENT_SOURCE_URI; - - static - { - final String uri = "atlas:terminal-parent"; - try - { - TERMINAL_PARENT_SOURCE_URI = new URI( uri ); - } - catch ( final URISyntaxException e ) - { - throw new IllegalStateException( "Terminal-parent source URI constant is invalid: " + uri, e ); - } - - try - { - ANY_SOURCE_URI = new URI( "any:any" ); - } - catch ( final URISyntaxException e ) - { - throw new IllegalStateException( "Cannot construct any-source URI: 'any:any'" ); - } - - try - { - UNKNOWN_SOURCE_URI = new URI( "unknown:unknown" ); - } - catch ( final URISyntaxException e ) - { - throw new IllegalStateException( "Cannot construct unknown-source URI: 'unknown:unknown'" ); - } - - try - { - POM_ROOT_URI = new URI( "pom:root" ); - } - catch ( final URISyntaxException e ) - { - throw new IllegalStateException( "Cannot construct pom-root URI: 'pom:root'" ); - } - } - - public static boolean isExcluded( final ProjectRef ref, final Collection excludes ) - { - if ( excludes == null || excludes.isEmpty() ) - { - return false; - } - - for ( final ProjectRef ex : excludes ) - { - if ( ex == null ) - { - continue; - } - - if ( ex.matches( ref ) ) - { - return true; - } - } - - return false; - } - - public static Map>> mapByDeclaring( final Collection> relationships ) - { - final Logger logger = LoggerFactory.getLogger( RelationshipUtils.class ); - logger.debug( "Mapping {} relationships by declaring GAV:\n\n {}\n\n", relationships.size(), new JoinString( "\n ", relationships ) ); - final Map>> result = new HashMap>>(); - for ( final ProjectRelationship rel : relationships ) - { - final ProjectVersionRef declaring = rel.getDeclaring(); - List> outbound = result.get( declaring ); - if ( outbound == null ) - { - outbound = new ArrayList>(); - result.put( rel.getDeclaring(), outbound ); - } - - if ( !outbound.contains( rel ) ) - { - outbound.add( rel ); - } - } - - return result; - - } - - public static URI profileLocation( final String profile ) - { - if ( profile == null || profile.trim() - .length() < 1 ) - { - return POM_ROOT_URI; - } - - try - { - return new URI( "pom:profile:" + profile ); - } - catch ( final URISyntaxException e ) - { - throw new IllegalStateException( "Cannot construct pom-profile URI: 'pom:profile:" + profile + "'" ); - } - } - - public static void filterTerminalParents( final Collection> rels ) - { - for ( final Iterator> it = rels.iterator(); it.hasNext(); ) - { - final ProjectRelationship rel = it.next(); - if ( ( rel instanceof SimpleParentRelationship ) && ( (ParentRelationship) rel ).isTerminus() ) - { - it.remove(); - } - } - } - - public static void filter( final Set> rels, final RelationshipType... types ) - { - if ( rels == null || rels.isEmpty() ) - { - return; - } - - if ( types == null || types.length < 1 ) - { - return; - } - - Arrays.sort( types ); - for ( final Iterator> iterator = rels.iterator(); iterator.hasNext(); ) - { - final ProjectRelationship rel = iterator.next(); - if ( Arrays.binarySearch( types, rel.getType() ) < 0 ) - { - iterator.remove(); - } - } - } - - public static void filter( final Set> rels, final ProjectRelationshipFilter filter ) - { - if ( filter == null || filter instanceof AnyFilter ) - { - return; - } - - if ( rels == null || rels.isEmpty() ) - { - return; - } - - for ( final Iterator> iterator = rels.iterator(); iterator.hasNext(); ) - { - final ProjectRelationship rel = iterator.next(); - if ( !filter.accept( rel ) ) - { - iterator.remove(); - } - } - } - - public static Set declarers( final ProjectRelationship... relationships ) - { - return declarers( Arrays.asList( relationships ) ); - } - - public static Set declarers( final Collection> relationships ) - { - final Set results = new HashSet(); - for ( final ProjectRelationship rel : relationships ) - { - results.add( rel.getDeclaring() ); - } - - return results; - } - - public static Set targets( final ProjectRelationship... relationships ) - { - return targets( Arrays.asList( relationships ) ); - } - - public static Set targets( final Collection> relationships ) - { - if ( relationships == null ) - { - return null; - } - - final Set results = new HashSet(); - for ( final ProjectRelationship rel : relationships ) - { - results.add( rel.getTarget() ); - } - - return results; - } - - public static Set gavs( final ProjectRelationship... relationships ) - { - return gavs( Arrays.asList( relationships ) ); - } - - public static Set gavs( final Collection> relationships ) - { - final Set results = new HashSet(); - for ( final ProjectRelationship rel : relationships ) - { - results.add( rel.getDeclaring() - .asProjectVersionRef() ); - - results.add( rel.getTarget() - .asProjectVersionRef() ); - } - - return results; - } - - public static ExtensionRelationship extension( final URI source, final URI pomLocation, - final ProjectVersionRef owner, final String groupId, - final String artifactId, final String version, final int index, - final boolean inherited ) - throws InvalidVersionSpecificationException - { - return new SimpleExtensionRelationship( source, pomLocation, owner, projectVersion( groupId, artifactId, version ), - index, inherited ); - } - - public static PluginRelationship plugin( final URI source, final URI pomLocation, final ProjectVersionRef owner, - final String groupId, final String artifactId, final String version, - final int index, final boolean inherited ) - throws InvalidVersionSpecificationException - { - return plugin( source, pomLocation, owner, groupId, artifactId, version, index, false, inherited ); - } - - public static PluginRelationship plugin( final URI source, final URI pomLocation, final ProjectVersionRef owner, - final String groupId, final String artifactId, final String version, - final int index, final boolean managed, final boolean inherited ) - throws InvalidVersionSpecificationException - { - return new SimplePluginRelationship( source, pomLocation, owner, projectVersion( groupId, artifactId, version ), - index, managed, inherited ); - } - - public static PluginRelationship plugin( final URI source, final URI pomLocation, final ProjectVersionRef owner, - final ProjectVersionRef plugin, final int index, final boolean managed, - final boolean inherited ) - throws InvalidVersionSpecificationException - { - return new SimplePluginRelationship( source, pomLocation, owner, plugin, index, managed, inherited ); - } - - public static PluginRelationship plugin( final URI source, final ProjectVersionRef owner, final String groupId, - final String artifactId, final String version, final int index, - final boolean inherited ) - throws InvalidVersionSpecificationException - { - return plugin( source, owner, groupId, artifactId, version, index, false, inherited ); - } - - public static PluginRelationship plugin( final URI source, final ProjectVersionRef owner, final String groupId, - final String artifactId, final String version, final int index, - final boolean managed, final boolean inherited ) - throws InvalidVersionSpecificationException - { - return new SimplePluginRelationship( source, owner, projectVersion( groupId, artifactId, version ), index, - managed, inherited ); - } - - public static PluginRelationship plugin( final URI source, final ProjectVersionRef owner, - final ProjectVersionRef plugin, final int index, final boolean managed, - final boolean inherited ) - throws InvalidVersionSpecificationException - { - return new SimplePluginRelationship( source, owner, plugin, index, managed, inherited ); - } - - public static PluginDependencyRelationship pluginDependency( final URI source, final ProjectVersionRef owner, - final ProjectRef plugin, final String groupId, - final String artifactId, final String version, - final int index, final boolean inherited ) - throws InvalidVersionSpecificationException - { - return pluginDependency( source, owner, plugin, groupId, artifactId, version, null, null, index, false, inherited ); - } - - public static PluginDependencyRelationship pluginDependency( final URI source, final ProjectVersionRef owner, final ProjectRef plugin, - final String groupId, final String artifactId, final String version, - final int index, final boolean managed, final boolean inherited ) - throws InvalidVersionSpecificationException - { - return pluginDependency( source, owner, plugin, groupId, artifactId, version, null, null, index, managed, inherited ); - } - - public static PluginDependencyRelationship pluginDependency( final URI source, final ProjectVersionRef owner, final ProjectRef plugin, - final String groupId, final String artifactId, final String version, - final String type, final String classifier, final int index, final boolean managed, - final boolean inherited ) - throws InvalidVersionSpecificationException - { - return new SimplePluginDependencyRelationship( source, owner, plugin, artifact( groupId, artifactId, version, type, classifier ), index, - managed, inherited ); - } - - public static PluginDependencyRelationship pluginDependency( final URI source, final ProjectVersionRef owner, final ProjectRef plugin, - final ProjectVersionRef dep, final String type, final String classifier, - final int index, final boolean managed, final boolean inherited ) - throws InvalidVersionSpecificationException - { - return new SimplePluginDependencyRelationship( source, owner, plugin, artifact( dep, type, classifier ), index, managed, inherited ); - } - - public static PluginDependencyRelationship pluginDependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, - final ProjectRef plugin, final String groupId, final String artifactId, - final String version, final int index, final boolean inherited ) - throws InvalidVersionSpecificationException - { - return pluginDependency( source, pomLocation, owner, plugin, groupId, artifactId, version, null, null, index, false, inherited ); - } - - public static PluginDependencyRelationship pluginDependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, - final ProjectRef plugin, final String groupId, final String artifactId, - final String version, final int index, final boolean managed, - final boolean inherited ) - throws InvalidVersionSpecificationException - { - return pluginDependency( source, pomLocation, owner, plugin, groupId, artifactId, version, null, null, index, managed, inherited ); - } - - public static PluginDependencyRelationship pluginDependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, - final ProjectRef plugin, final String groupId, final String artifactId, - final String version, final String type, final String classifier, final int index, - final boolean managed, final boolean inherited ) - throws InvalidVersionSpecificationException - { - return new SimplePluginDependencyRelationship( source, pomLocation, owner, plugin, - artifact( groupId, artifactId, version, type, classifier ), index, managed, inherited ); - } - - public static PluginDependencyRelationship pluginDependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, - final ProjectRef plugin, final ProjectVersionRef dep, final String type, - final String classifier, final int index, final boolean managed, - final boolean inherited ) - throws InvalidVersionSpecificationException - { - return new SimplePluginDependencyRelationship( source, pomLocation, owner, plugin, artifact( dep, type, classifier ), index, managed, - inherited ); - } - public static DependencyRelationship dependency( final URI source, final ProjectVersionRef owner, final String groupId, final String artifactId, final String version, final int index, final boolean inherited, final boolean optional ) - throws InvalidVersionSpecificationException + throws InvalidVersionSpecificationException { return dependency( source, owner, groupId, artifactId, version, null, null, optional, null, index, false, inherited ); } @@ -420,7 +39,7 @@ public static DependencyRelationship dependency( final URI source, final Project public static DependencyRelationship dependency( final URI source, final ProjectVersionRef owner, final ProjectVersionRef dep, final int index, final boolean inherited, final boolean optional ) - throws InvalidVersionSpecificationException + throws InvalidVersionSpecificationException { return dependency( source, owner, dep, null, null, optional, null, index, false, inherited ); } @@ -428,7 +47,7 @@ public static DependencyRelationship dependency( final URI source, final Project public static DependencyRelationship dependency( final URI source, final ProjectVersionRef owner, final String groupId, final String artifactId, final String version, final DependencyScope scope, final int index, final boolean managed, final boolean inherited, final boolean optional ) - throws InvalidVersionSpecificationException + throws InvalidVersionSpecificationException { return dependency( source, owner, groupId, artifactId, version, null, null, optional, scope, index, managed, inherited ); } @@ -436,7 +55,7 @@ public static DependencyRelationship dependency( final URI source, final Project public static DependencyRelationship dependency( final URI source, final ProjectVersionRef owner, final ProjectVersionRef dep, final DependencyScope scope, final int index, final boolean managed, final boolean inherited, final boolean optional ) - throws InvalidVersionSpecificationException + throws InvalidVersionSpecificationException { return new SimpleDependencyRelationship( source, owner, artifact( dep, null, null ), scope, index, managed, inherited, optional ); } @@ -444,16 +63,16 @@ public static DependencyRelationship dependency( final URI source, final Project public static DependencyRelationship dependency( final URI source, final ProjectVersionRef owner, final String groupId, final String artifactId, final String version, final String type, final String classifier, final boolean optional, final DependencyScope scope, final int index, final boolean managed, final boolean inherited ) - throws InvalidVersionSpecificationException + throws InvalidVersionSpecificationException { return new SimpleDependencyRelationship( source, owner, artifact( groupId, artifactId, version, type, classifier ), scope, index, - managed, inherited, optional ); + managed, inherited, optional ); } public static DependencyRelationship dependency( final URI source, final ProjectVersionRef owner, final ProjectVersionRef dep, final String type, final String classifier, final boolean optional, final DependencyScope scope, final int index, final boolean managed, final boolean inherited ) - throws InvalidVersionSpecificationException + throws InvalidVersionSpecificationException { return new SimpleDependencyRelationship( source, owner, artifact( dep, type, classifier ), scope, index, managed, inherited, optional ); } @@ -461,7 +80,7 @@ public static DependencyRelationship dependency( final URI source, final Project public static DependencyRelationship dependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, final String groupId, final String artifactId, final String version, final int index, final boolean inherited, final boolean optional ) - throws InvalidVersionSpecificationException + throws InvalidVersionSpecificationException { return dependency( source, pomLocation, owner, groupId, artifactId, version, null, null, optional, null, index, false, inherited ); } @@ -469,7 +88,7 @@ public static DependencyRelationship dependency( final URI source, final URI pom public static DependencyRelationship dependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, final ProjectVersionRef dep, final int index, final boolean inherited, final boolean optional ) - throws InvalidVersionSpecificationException + throws InvalidVersionSpecificationException { return dependency( source, pomLocation, owner, dep, null, null, optional, null, index, false, inherited ); } @@ -477,7 +96,7 @@ public static DependencyRelationship dependency( final URI source, final URI pom public static DependencyRelationship dependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, final String groupId, final String artifactId, final String version, final DependencyScope scope, final int index, final boolean managed, final boolean inherited, final boolean optional ) - throws InvalidVersionSpecificationException + throws InvalidVersionSpecificationException { return dependency( source, pomLocation, owner, groupId, artifactId, version, null, null, optional, scope, index, managed, inherited ); } @@ -485,7 +104,7 @@ public static DependencyRelationship dependency( final URI source, final URI pom public static DependencyRelationship dependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, final ProjectVersionRef dep, final DependencyScope scope, final int index, final boolean managed, final boolean inherited, final boolean optional ) - throws InvalidVersionSpecificationException + throws InvalidVersionSpecificationException { return new SimpleDependencyRelationship( source, pomLocation, owner, artifact( dep, null, null ), scope, index, managed, inherited, optional ); } @@ -494,50 +113,30 @@ public static DependencyRelationship dependency( final URI source, final URI pom final String artifactId, final String version, final String type, final String classifier, final boolean optional, final DependencyScope scope, final int index, final boolean managed, final boolean inherited ) - throws InvalidVersionSpecificationException + throws InvalidVersionSpecificationException { return new SimpleDependencyRelationship( source, pomLocation, owner, artifact( groupId, artifactId, version, type, classifier ), scope, - index, managed, inherited, optional ); + index, managed, inherited, optional ); } public static DependencyRelationship dependency( final URI source, final URI pomLocation, final ProjectVersionRef owner, final ProjectVersionRef dep, final String type, final String classifier, final boolean optional, final DependencyScope scope, final int index, final boolean managed, final boolean inherited ) - throws InvalidVersionSpecificationException + throws InvalidVersionSpecificationException { return new SimpleDependencyRelationship( source, pomLocation, owner, artifact( dep, type, classifier ), scope, index, managed, inherited, optional ); } - public static Set getRelationshipTypes( final ProjectRelationshipFilter filter ) + public static void filterTerminalParents( final Collection> rels ) { - if ( filter == null ) + for (final Iterator> it = rels.iterator(); it.hasNext(); ) { - return new HashSet( Arrays.asList( RelationshipType.values() ) ); - } - - final Set result = new HashSet(); - - if ( filter instanceof AbstractTypedFilter ) - { - final AbstractTypedFilter typedFilter = (AbstractTypedFilter) filter; - result.addAll( typedFilter.getRelationshipTypes() ); - result.addAll( typedFilter.getDescendantRelationshipTypes() ); - } - else if ( filter instanceof AbstractAggregatingFilter ) - { - final List filters = ( (AbstractAggregatingFilter) filter ).getFilters(); - - for ( final ProjectRelationshipFilter f : filters ) + final ProjectRelationship rel = it.next(); + if ( ( rel instanceof SimpleParentRelationship) && ( (ParentRelationship) rel ).isTerminus() ) { - result.addAll( getRelationshipTypes( f ) ); + it.remove(); } } - else - { - result.addAll( Arrays.asList( RelationshipType.values() ) ); - } - - return result; } } diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java deleted file mode 100644 index 870e407c..00000000 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/EProjectRelationshipsTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.model.EProjectDirectRelationships; -import org.commonjava.maven.atlas.graph.rel.*; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; - -public class EProjectRelationshipsTest -{ - - @Rule - public TestName naming = new TestName(); - - private URI testURI() - throws URISyntaxException - { - return new URI( "test:repo:" + naming.getMethodName() ); - } - - @Test - public void builderWith2Dependencies2PluginsAParentAndAnExtension() - throws InvalidVersionSpecificationException, URISyntaxException - { - final ProjectVersionRef p = new SimpleProjectVersionRef( "org.apache.maven", "maven-core", "3.0.3" ); - final URI source = testURI(); - - final EProjectDirectRelationships.Builder prb = new EProjectDirectRelationships.Builder( source, p ); - - final ProjectVersionRef parent = new SimpleProjectVersionRef( "org.apache.maven", "maven", "3.0.3" ); - final ParentRelationship parentRel = new SimpleParentRelationship( source, p, parent ); - - int idx = 0; - int pidx = 0; - final DependencyRelationship papi = - new SimpleDependencyRelationship( source, p, new SimpleArtifactRef( "org.apache.maven", "maven-plugin-api", "3.0.3", - null, null ), DependencyScope.compile, - idx++, false, false, false ); - final DependencyRelationship art = - new SimpleDependencyRelationship( source, p, new SimpleArtifactRef( "org.apache.maven", "maven-artifact", "3.0.3", - null, null ), DependencyScope.compile, - idx++, false, false, false ); - final PluginRelationship jarp = - new SimplePluginRelationship( source, p, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-jar-plugin", - "2.2" ), pidx++, false, false ); - final PluginRelationship comp = - new SimplePluginRelationship( source, p, new SimpleProjectVersionRef( "org.apache.maven.plugins", - "maven-compiler-plugin", "2.3.2" ), pidx++, false, false ); - final ExtensionRelationship wag = - new SimpleExtensionRelationship( source, p, new SimpleProjectVersionRef( "org.apache.maven.wagon", - "wagon-provider-webdav", "1.0" ), 0, false ); - - prb.withParent( parentRel ); - prb.withDependencies( papi, art ); - prb.withPlugins( jarp, comp ); - prb.withExtensions( wag ); - - final EProjectDirectRelationships rels = prb.build(); - - final Set> all = rels.getAllRelationships(); - - assertThat( all.size(), equalTo( 6 ) ); - - assertThat( all.contains( parentRel ), equalTo( true ) ); - assertThat( all.contains( papi ), equalTo( true ) ); - assertThat( all.contains( art ), equalTo( true ) ); - assertThat( all.contains( jarp ), equalTo( true ) ); - assertThat( all.contains( comp ), equalTo( true ) ); - assertThat( all.contains( wag ), equalTo( true ) ); - } - -} diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java deleted file mode 100644 index 2fc10f79..00000000 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/filter/DependencyFilterTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.graph.filter; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -import java.net.URI; -import java.net.URISyntaxException; - -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; - -public class DependencyFilterTest -{ - - @Rule - public TestName naming = new TestName(); - - private URI testURI() - throws URISyntaxException - { - return new URI( "test:repo:" + naming.getMethodName() ); - } - - @Test - public void rejectTestScopeForRuntimeFilter() - throws Exception - { - final DependencyFilter filter = new DependencyFilter( DependencyScope.runtime ); - final DependencyRelationship rel = - new SimpleDependencyRelationship( testURI(), new SimpleProjectVersionRef( "g", "a", "1" ), - new SimpleArtifactRef( "g", "b", "2", "jar", null ), DependencyScope.test, 0, - false, false, false ); - - assertThat( filter.accept( rel ), equalTo( false ) ); - } - -} diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java index 39b003f4..ca38417c 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java @@ -15,7 +15,7 @@ */ package org.commonjava.maven.atlas.graph.rel; -import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.POM_ROOT_URI; +import static org.commonjava.maven.atlas.graph.rel.RelationshipConstants.POM_ROOT_URI; import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.dependency; import static org.commonjava.maven.atlas.ident.util.IdentityUtils.projectVersion; import static org.hamcrest.CoreMatchers.*; diff --git a/tck/pom.xml b/tck/pom.xml deleted file mode 100644 index 9b66691c..00000000 --- a/tck/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - 4.0.0 - - - org.commonjava.maven.atlas - atlas-parent - 0.16.3-SNAPSHOT - - - atlas-drivers-tck - - Atlas :: Maven Project-Graph :: TCK - - - - org.commonjava.maven.atlas - atlas-relationships-api - - - junit - junit - compile - - - org.hamcrest - hamcrest-core - compile - - - diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java deleted file mode 100644 index 25eb7977..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/AbstractSPI_TCK.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph; - -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Collections; -import java.util.Date; -import java.util.ServiceLoader; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.RelationshipGraphFactory; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.testutil.TCKDriver; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.rules.TemporaryFolder; -import org.junit.rules.TestName; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public abstract class AbstractSPI_TCK -{ - - @Rule - public TestName naming = new TestName(); - - @Rule - public TemporaryFolder temp = new TemporaryFolder(); - - private TCKDriver driver; - - @Before - public void before() - throws Exception - { - driver = ServiceLoader.load( TCKDriver.class ).iterator().next(); - driver.setup( temp ); - } - - @After - public void after() - throws IOException - { - if ( driver != null ) - { - driver.close(); - } - } - - protected URI sourceURI() - throws URISyntaxException - { - return new URI( "test:repo:" + naming.getMethodName() ); - } - - protected RelationshipGraph simpleGraph( final ProjectVersionRef... roots ) - throws Exception - { - final ViewParams params = new ViewParams( newWorkspaceId(), roots ); - params.addActiveSource( sourceURI() ); - - return graphFactory().open( params, true ); - } - - protected String newWorkspaceId() - { - return "Test-" + System.currentTimeMillis(); - } - - protected final Logger logger = LoggerFactory.getLogger( getClass() ); - - private RelationshipGraphFactory graphFactory; - - protected final RelationshipGraphConnectionFactory connectionFactory() - throws Exception - { - return driver.getConnectionFactory(); - } - - protected final RelationshipGraphFactory graphFactory() - throws Exception - { - if ( graphFactory == null ) - { - graphFactory = new RelationshipGraphFactory( driver.getConnectionFactory() ); - } - - return graphFactory; - } - - protected final RelationshipGraph openGraph( final ViewParams params, final boolean create ) - throws Exception - { - final RelationshipGraph graph = - graphFactory().open( new ViewParams.Builder( params ).withActiveSources( Collections.singleton( RelationshipUtils.ANY_SOURCE_URI ) ) - .build(), create ); - return graph; - } - - private long start; - - @Before - public void printStart() - { - start = System.currentTimeMillis(); - System.out.printf( "***START [%s#%s] (%s)\n\n", naming.getClass(), naming.getMethodName(), new Date().toString() ); - } - - @After - public void printEnd() - throws Exception - { - System.out.printf( "\n\n***END [%s#%s] - %sms (%s)\n", naming.getClass(), naming.getMethodName(), ( System.currentTimeMillis() - start ), - new Date().toString() ); - - if ( graphFactory != null ) - { - graphFactory.close(); - } - - connectionFactory().close(); - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java deleted file mode 100644 index 680f5dea..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/batch/LargeBatchInsertTCK.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.batch; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Test; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import java.util.Set; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -public class LargeBatchInsertTCK - extends AbstractSPI_TCK -{ - - private static final String NAMECHARS = "abcdefghijklmnopqrstuvwxyz"; - - private Random random = new Random(); - - @Test - public void run() - throws Exception - { - final ProjectVersionRef myRef = new SimpleProjectVersionRef( "my.group", "my-artifact", "1.0" ); - List rels = new ArrayList(); - for ( int i = 0; i < 550; i++ ) - { - rels.add(new SimpleDependencyRelationship( sourceURI(), RelationshipUtils.POM_ROOT_URI, myRef, newArtifact(), - DependencyScope.compile, i, false, false, false ) ); - } - - final RelationshipGraph graph = simpleGraph( myRef ); - - graph.storeRelationships( rels ); - - Set> result = graph.getAllRelationships(); - assertThat( result.size(), equalTo( rels.size() ) ); - - for ( ProjectRelationship rel: rels ) - { - assertThat( rel + " was not returned from the graph!", result.contains( rel ), equalTo( true ) ); - } - } - - private ArtifactRef newArtifact() - { - return new SimpleArtifactRef( genName(), genName(), genNum(), "jar", null ); - } - - private String genName() - { - StringBuilder sb = new StringBuilder(); - for ( int i = 0; i < 10; i++ ) - { - sb.append(NAMECHARS.charAt( Math.abs( random.nextInt() ) % NAMECHARS.length() ) ); - } - - return sb.toString(); - } - - private String genNum() - { - StringBuilder sb = new StringBuilder(); - for ( int i = 0; i < 4; i++ ) - { - sb.append(Integer.toString(Math.abs( random.nextInt() ) % 10 ) ); - } - - return sb.toString(); - } -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/conn/RelationshipGraphConnection_CreateAndRetrieveByIdTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/conn/RelationshipGraphConnection_CreateAndRetrieveByIdTCK.java deleted file mode 100644 index 299979cd..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/conn/RelationshipGraphConnection_CreateAndRetrieveByIdTCK.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.conn; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - -import java.util.Set; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Ignore; -import org.junit.Test; - -public class RelationshipGraphConnection_CreateAndRetrieveByIdTCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final String wsid = newWorkspaceId(); - final RelationshipGraphConnection connection = connectionFactory().openConnection( wsid, true ); - - System.out.println( "wsid: " + connection.getWorkspaceId() ); - - assertThat( connection, notNullValue() ); - - logger.info( "Created connection: {}", connection ); - - final RelationshipGraphConnection result = connectionFactory().openConnection( wsid, false ); - - logger.info( "Retrieved connection: {}", result ); - - assertThat( result, notNullValue() ); - assertThat( result.getWorkspaceId(), equalTo( connection.getWorkspaceId() ) ); - assertThat( result.equals( connection ), equalTo( true ) ); - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/conn/RelationshipGraphConnection_CreateAndVerifyInListingTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/conn/RelationshipGraphConnection_CreateAndVerifyInListingTCK.java deleted file mode 100644 index a853923d..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/conn/RelationshipGraphConnection_CreateAndVerifyInListingTCK.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.conn; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnection; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Ignore; -import org.junit.Test; - -import java.util.Set; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - -public class RelationshipGraphConnection_CreateAndVerifyInListingTCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final String wsid = newWorkspaceId(); - final RelationshipGraphConnection connection = connectionFactory().openConnection( wsid, true ); - - System.out.println( "wsid: " + connection.getWorkspaceId() ); - - assertThat( connection, notNullValue() ); - - logger.info( "Created connection: {}", connection ); - - final Set all = connectionFactory().listWorkspaces(); - - logger.info( "Retrieved all workspaces: {}", all ); - - assertThat( all, notNullValue() ); - assertThat( all.size(), equalTo( 1 ) ); - assertThat( all.contains( connection.getWorkspaceId() ), equalTo( true ) ); - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BackToRootTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BackToRootTCK.java deleted file mode 100644 index 228c4b8d..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BackToRootTCK.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.cycle; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.filter.DependencyFilter; -import org.commonjava.maven.atlas.graph.model.EProjectCycle; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Ignore; -import org.junit.Test; - -import java.net.URI; -import java.util.HashSet; -import java.util.Set; - -import static org.apache.commons.lang.StringUtils.join; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - -public class CycleDetection_BackToRootTCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final URI source = sourceURI(); - - final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); - final ProjectVersionRef dep = new SimpleProjectVersionRef( "org.other", "dep", "1.0" ); - final ProjectVersionRef dep2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0" ); - - final RelationshipGraph graph = simpleGraph( project ); - - /* @formatter:off */ - graph.storeRelationships( new SimpleDependencyRelationship( source, project, dep.asJarArtifact(), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, dep, dep2.asJarArtifact(), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, dep2, project.asJarArtifact(), null, 0, false, false, false ) ); - /* @formatter:on */ - - // final EProjectGraph graph = getManager().getGraph( session, project ); - - final Set cycles = graph.getCycles(); - System.out.println( "Cycles:\n\n" + join( cycles, "\n" ) ); - assertThat( cycles.size(), equalTo( 1 ) ); - - for ( final EProjectCycle cycle : cycles ) - { - final Set projects = cycle.getAllParticipatingProjects(); - assertThat( projects.contains( project ), equalTo( true ) ); - assertThat( projects.contains( dep ), equalTo( true ) ); - assertThat( projects.contains( dep2 ), equalTo( true ) ); - } - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java deleted file mode 100644 index bba4c295..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_BetweenDepLevelsTCK.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.cycle; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.filter.DependencyFilter; -import org.commonjava.maven.atlas.graph.model.EProjectCycle; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Ignore; -import org.junit.Test; - -import java.net.URI; -import java.util.HashSet; -import java.util.Set; - -import static org.apache.commons.lang.StringUtils.join; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - -public class CycleDetection_BetweenDepLevelsTCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final URI source = sourceURI(); - - final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); - final ProjectVersionRef dep = new SimpleProjectVersionRef( "org.other", "dep", "1.0" ); - final ProjectVersionRef dep2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0" ); - - final RelationshipGraph graph = simpleGraph( project ); - - /* @formatter:off */ - final Set> rejected = graph.storeRelationships( - new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, dep2, new SimpleArtifactRef( dep, null, null ), null, 0, false, false, false ) ); - /* @formatter:on */ - - assertThat( rejected, notNullValue() ); - - // System.out.println( "Rejects: " + rejected ); - // - // assertThat( rejected.size(), equalTo( 2 ) ); - // final ProjectRelationship reject = rejected.iterator() - // .next(); - // assertThat( reject.getDeclaring(), equalTo( dep2 ) ); - // assertThat( reject.getTarget() - // .asProjectVersionRef(), equalTo( dep ) ); - - final Set cycles = graph.getCycles(); - System.out.println( "Cycles:\n\n" + join( cycles, "\n" ) ); - assertThat( cycles.size(), equalTo( 1 ) ); - - for ( final EProjectCycle cycle : cycles ) - { - final Set projects = cycle.getAllParticipatingProjects(); - assertThat( projects.contains( project ), equalTo( false ) ); - assertThat( projects.contains( dep ), equalTo( true ) ); - assertThat( projects.contains( dep2 ), equalTo( true ) ); - } - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java deleted file mode 100644 index e0f07f16..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_FilterRemovesCycleTCK.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.cycle; - -import static org.apache.commons.lang.StringUtils.join; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - -import java.net.URI; -import java.util.HashSet; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.filter.DependencyFilter; -import org.commonjava.maven.atlas.graph.model.EProjectCycle; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Ignore; -import org.junit.Test; - -public class CycleDetection_FilterRemovesCycleTCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final URI source = sourceURI(); - - final ProjectVersionRef a = new SimpleProjectVersionRef( "project", "A", "1.0" ); - final ProjectVersionRef b = new SimpleProjectVersionRef( "project", "B", "1.0" ); - final ProjectVersionRef c = new SimpleProjectVersionRef( "project", "C", "1.0" ); - - final ProjectVersionRef d = new SimpleProjectVersionRef( "project", "D", "1.0" ); - final ProjectVersionRef e = new SimpleProjectVersionRef( "project", "E", "1.0" ); - - final RelationshipGraph graph = simpleGraph( a ); - - /* @formatter:off */ - // a --> b --> c --> a - // d --> e --> c --> a --> b --> c - graph.storeRelationships( new SimpleDependencyRelationship( source, a, new SimpleArtifactRef( b, null, null ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( a, null, null ), null, 0, false, false, false ), - new SimplePluginRelationship( source, b, c, 0, false, false ), - new SimpleDependencyRelationship( source, d, new SimpleArtifactRef( e, null, null ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, e, new SimpleArtifactRef( c, null, null ), null, 0, false, false, false ) ); - /* @formatter:on */ - - final RelationshipGraph graph2 = - graphFactory().open( new ViewParams.Builder( graph.getParams() ).withFilter( new DependencyFilter() ) - .withRoots( d ) - .build(), false ); - - final Set cycles1 = graph.getCycles(); - System.out.println( "Graph 1 Cycles:\n\n" + join( cycles1, "\n" ) ); - - final Set cycles2 = graph2.getCycles(); - System.out.println( "Graph 2 Cycles:\n\n" + join( cycles2, "\n" ) ); - - assertThat( cycles1.size(), equalTo( 1 ) ); - assertThat( cycles2.size(), equalTo( 0 ) ); - - final Set> cycleSets = new HashSet>(); - cycleSets.add( cycles1 ); - // cycleSets.add( cycles2 ); - - int i = 0; - for ( final Set cycles : cycleSets ) - { - int j = 0; - for ( final EProjectCycle cycle : cycles ) - { - final Set refs = cycle.getAllParticipatingProjects(); - System.out.printf( "Cycle (%d,%d) projects: %s\n\n", i, j, refs); - assertThat( i + ", " + j + " missing A", refs.contains( a ), equalTo( true ) ); - assertThat( i + ", " + j + " missing B", refs.contains( b ), equalTo( true ) ); - assertThat( i + ", " + j + " missing C", refs.contains( c ), equalTo( true ) ); - j++; - } - i++; - } - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java deleted file mode 100644 index 89036469..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_IntroduceToExistingTCK.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.cycle; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.filter.DependencyFilter; -import org.commonjava.maven.atlas.graph.model.EProjectCycle; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Ignore; -import org.junit.Test; - -import java.net.URI; -import java.util.HashSet; -import java.util.Set; - -import static org.apache.commons.lang.StringUtils.join; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - -public class CycleDetection_IntroduceToExistingTCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final URI source = sourceURI(); - - final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); - final ProjectVersionRef dep = new SimpleProjectVersionRef( "org.other", "dep", "1.0" ); - final ProjectVersionRef dep2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0" ); - - final RelationshipGraph graph = simpleGraph( project ); - - /* @formatter:off */ - graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( dep, null, null ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( dep2, null, null ), null, 0, false, false, false ) ); - - final boolean introduces = graph.introducesCycle( new SimpleDependencyRelationship( source, dep, new SimpleArtifactRef( project, null, null ), null, 0, false, false, false ) ); - /* @formatter:on */ - - assertThat( introduces, equalTo( true ) ); - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java deleted file mode 100644 index 6742555b..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/cycle/CycleDetection_RootDependentTCK.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.cycle; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.filter.DependencyFilter; -import org.commonjava.maven.atlas.graph.model.EProjectCycle; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Ignore; -import org.junit.Test; - -import java.net.URI; -import java.util.HashSet; -import java.util.Set; - -import static org.apache.commons.lang.StringUtils.join; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -public class CycleDetection_RootDependentTCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final URI source = sourceURI(); - - final ProjectVersionRef a = new SimpleProjectVersionRef( "project", "A", "1.0" ); - final ProjectVersionRef b = new SimpleProjectVersionRef( "project", "B", "1.0" ); - final ProjectVersionRef c = new SimpleProjectVersionRef( "project", "C", "1.0" ); - - final ProjectVersionRef d = new SimpleProjectVersionRef( "project", "D", "1.0" ); - final ProjectVersionRef e = new SimpleProjectVersionRef( "project", "E", "1.0" ); - - final RelationshipGraph graph = simpleGraph( a ); - - /* @formatter:off */ - // a --> b --> c --> a - // d --> e --> c --> a --> b --> c - graph.storeRelationships( new SimpleDependencyRelationship( source, a, new SimpleArtifactRef( b, null, null ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, b, new SimpleArtifactRef( c, null, null ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( a, null, null ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, d, new SimpleArtifactRef( e, null, null ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, e, new SimpleArtifactRef( c, null, null ), null, 0, false, false, false ) ); - /* @formatter:on */ - - final RelationshipGraph graph2 = - graphFactory().open( new ViewParams.Builder( graph.getParams() ).withRoots( d ) - .build(), false ); - - final Set cycles1 = graph.getCycles(); - System.out.println( "Graph 1 Cycles:\n\n" + join( cycles1, "\n" ) ); - - final Set cycles2 = graph2.getCycles(); - System.out.println( "Graph 2 Cycles:\n\n" + join( cycles2, "\n" ) ); - - assertThat( cycles1.size(), equalTo( 1 ) ); - assertThat( cycles2.size(), equalTo( 1 ) ); - - final Set> cycleSets = new HashSet>(); - cycleSets.add( cycles1 ); - cycleSets.add( cycles2 ); - - int i = 0; - for ( final Set cycles : cycleSets ) - { - int j = 0; - for ( final EProjectCycle cycle : cycles ) - { - final Set refs = cycle.getAllParticipatingProjects(); - assertThat( i + ", " + j + " missing A", refs.contains( a ), equalTo( true ) ); - assertThat( i + ", " + j + " missing B", refs.contains( b ), equalTo( true ) ); - assertThat( i + ", " + j + " missing C", refs.contains( c ), equalTo( true ) ); - j++; - } - i++; - } - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/fac/RelationshipGraphFactory_OpenStoreDeleteReopenTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/fac/RelationshipGraphFactory_OpenStoreDeleteReopenTCK.java deleted file mode 100644 index f9966dcd..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/fac/RelationshipGraphFactory_OpenStoreDeleteReopenTCK.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.fac; - -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - -import java.net.URI; -import java.util.List; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.RelationshipGraphException; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionException; -import org.commonjava.maven.atlas.graph.traverse.RelationshipGraphTraversal; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Ignore; -import org.junit.Test; - -public class RelationshipGraphFactory_OpenStoreDeleteReopenTCK - extends AbstractSPI_TCK -{ - - @Test -// @Ignore - public void run() - throws Exception - { - final ProjectVersionRef r = new SimpleProjectVersionRef( "org.test", "root", "1" ); - final ProjectVersionRef p = new SimpleProjectVersionRef( "org.test", "parent", "1.0" ); - final ProjectVersionRef c = new SimpleProjectVersionRef( "org.test", "child", "1.0" ); - - final URI source = sourceURI(); - - final String wsid = newWorkspaceId(); - - final RelationshipGraph child = openGraph( new ViewParams( wsid, c ), true ); - - child.storeRelationships( new SimpleParentRelationship( source, c, p ) ); - - openGraph( new ViewParams( wsid, p ), true ).storeRelationships( new SimpleParentRelationship( source, p, r ) ); - - RelationshipGraph graph = openGraph( new ViewParams( wsid, r ), true ); - graph.storeRelationships( new SimpleParentRelationship( source, r ) ); - - // final Thread t = new Thread( new DelayTraverseRunnable( graph ) ); - // t.setDaemon( true ); - // t.start(); - - try - { - graphFactory().deleteWorkspace( wsid ); - - graph = openGraph( new ViewParams( wsid, c ), true ); - assertThat( graph, notNullValue() ); - - graph.storeRelationships( new SimpleParentRelationship( source, c, p ) ); - } - finally - { - // t.interrupt(); - } - } - - public static final class DelayTraverseRunnable - implements Runnable - { - private final RelationshipGraph graph; - - DelayTraverseRunnable( final RelationshipGraph graph ) - { - this.graph = graph; - } - - @Override - public void run() - { - try - { - graph.traverse( new RelationshipGraphTraversal() - { - @Override - public boolean traverseEdge( final ProjectRelationship relationship, - final List> path ) - { - try - { - Thread.sleep( 2000 ); - } - catch ( final InterruptedException e ) - { - return false; - } - return true; - } - - @Override - public void startTraverse( final RelationshipGraph graph ) - throws RelationshipGraphConnectionException - { - } - - @Override - public boolean preCheck( final ProjectRelationship relationship, - final List> path ) - { - return true; - } - - @Override - public void endTraverse( final RelationshipGraph graph ) - throws RelationshipGraphConnectionException - { - } - - @Override - public void edgeTraversed( final ProjectRelationship relationship, - final List> path ) - { - } - } ); - } - catch ( final RelationshipGraphException e ) - { - e.printStackTrace(); - } - } - - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_ConnectOutOfOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_ConnectOutOfOrderTCK.java deleted file mode 100644 index 523c2dce..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_ConnectOutOfOrderTCK.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.manip; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -import java.net.URI; -import java.util.Iterator; -import java.util.List; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.filter.DependencyFilter; -import org.commonjava.maven.atlas.graph.model.GraphPath; -import org.commonjava.maven.atlas.graph.mutate.ManagedDependencyMutator; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.traverse.AncestryTraversal; -import org.commonjava.maven.atlas.graph.traverse.TraversalType; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Ignore; -import org.junit.Test; -import org.slf4j.LoggerFactory; - -public class RelationshipGraph_ConnectOutOfOrderTCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final ProjectVersionRef r = new SimpleProjectVersionRef( "org.test", "root", "1" ); - final ProjectVersionRef p = new SimpleProjectVersionRef( "org.test", "parent", "1.0" ); - final ProjectVersionRef c = new SimpleProjectVersionRef( "org.test", "child", "1.0" ); - - final URI source = sourceURI(); - - final String wsid = newWorkspaceId(); - - final RelationshipGraph child = openGraph( new ViewParams( wsid, c ), true ); - - child.storeRelationships( new SimpleParentRelationship( source, c, p ) ); - - openGraph( new ViewParams( wsid, p ), true ).storeRelationships( new SimpleParentRelationship( source, p, r ) ); - - openGraph( new ViewParams( wsid, r ), true ).storeRelationships( new SimpleParentRelationship( source, r ) ); - - assertThat( child.isComplete(), equalTo( true ) ); - - final AncestryTraversal ancestryTraversal = new AncestryTraversal(); - child.traverse( ancestryTraversal, TraversalType.depth_first ); - - final List ancestry = ancestryTraversal.getAncestry(); - LoggerFactory.getLogger( getClass() ) - .info( "Ancestry: {}", ancestry ); - - assertThat( ancestry, notNullValue() ); - assertThat( ancestry.size(), equalTo( 3 ) ); - - final Iterator iterator = ancestry.iterator(); - assertThat( iterator.next(), equalTo( c ) ); - assertThat( iterator.next(), equalTo( p ) ); - assertThat( iterator.next(), equalTo( r ) ); - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_ConnectWParentInterTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_ConnectWParentInterTCK.java deleted file mode 100644 index e68a95ba..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_ConnectWParentInterTCK.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.manip; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.traverse.AncestryTraversal; -import org.commonjava.maven.atlas.graph.traverse.TraversalType; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Ignore; -import org.junit.Test; -import org.slf4j.LoggerFactory; - -import java.net.URI; -import java.util.Iterator; -import java.util.List; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - -public class RelationshipGraph_ConnectWParentInterTCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final ProjectVersionRef r = new SimpleProjectVersionRef( "org.test", "root", "1" ); - final ProjectVersionRef p = new SimpleProjectVersionRef( "org.test", "parent", "1.0" ); - final ProjectVersionRef c = new SimpleProjectVersionRef( "org.test", "child", "1.0" ); - - final URI source = sourceURI(); - - final String wsid = newWorkspaceId(); - - openGraph( new ViewParams( wsid, r ), true ).storeRelationships( new SimpleParentRelationship( r ) ); - - openGraph( new ViewParams( wsid, p ), true ).storeRelationships( new SimpleParentRelationship( source, p, r ) ); - - final RelationshipGraph child = openGraph( new ViewParams( wsid, c ), true ); - - child.storeRelationships( new SimpleParentRelationship( source, c, p ) ); - - System.out.println( "Incomplete subgraphs: " + child.getIncompleteSubgraphs() ); - System.out.flush(); - assertThat( child.isComplete(), equalTo( true ) ); - - final AncestryTraversal ancestryTraversal = new AncestryTraversal(); - child.traverse( ancestryTraversal, TraversalType.depth_first ); - - final List ancestry = ancestryTraversal.getAncestry(); - LoggerFactory.getLogger( getClass() ) - .info( "Ancestry: {}", ancestry ); - - assertThat( ancestry, notNullValue() ); - assertThat( ancestry.size(), equalTo( 3 ) ); - - final Iterator iterator = ancestry.iterator(); - assertThat( iterator.next(), equalTo( c ) ); - assertThat( iterator.next(), equalTo( p ) ); - assertThat( iterator.next(), equalTo( r ) ); - } -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_NullPathOnTargetExprVersionTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_NullPathOnTargetExprVersionTCK.java deleted file mode 100644 index 3f0489ee..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_NullPathOnTargetExprVersionTCK.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.manip; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.filter.DependencyFilter; -import org.commonjava.maven.atlas.graph.model.GraphPath; -import org.commonjava.maven.atlas.graph.mutate.ManagedDependencyMutator; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.traverse.AncestryTraversal; -import org.commonjava.maven.atlas.graph.traverse.TraversalType; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Test; -import org.slf4j.LoggerFactory; - -import java.net.URI; -import java.util.Iterator; -import java.util.List; - -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.assertThat; - -public class RelationshipGraph_NullPathOnTargetExprVersionTCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final ProjectVersionRef from = new SimpleProjectVersionRef( "org.from", "project", "1.0" ); - final ProjectVersionRef to = new SimpleProjectVersionRef( "org.to", "artifact", "${version.target}" ); - - final URI src = new URI( "test:source-uri" ); - final ProjectRelationship rel = - new SimpleDependencyRelationship( src, from, to.asArtifactRef( "jar", null ), DependencyScope.compile, 0, false, false, false ); - - final RelationshipGraph graph = simpleGraph( from ); - final GraphPath path = graph.createPath( rel ); - - assertThat( path, nullValue() ); - } -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java deleted file mode 100644 index 75ecabb6..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/manip/RelationshipGraph_StoreAndVerifyInView_TCK.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.manip; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.filter.DependencyFilter; -import org.commonjava.maven.atlas.graph.mutate.ManagedDependencyMutator; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.traverse.AncestryTraversal; -import org.commonjava.maven.atlas.graph.traverse.TraversalType; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Test; -import org.slf4j.LoggerFactory; - -import java.net.URI; -import java.util.Iterator; -import java.util.List; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - -public class RelationshipGraph_StoreAndVerifyInView_TCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final URI src = sourceURI(); - final ProjectVersionRef gav = new SimpleProjectVersionRef( "g", "a", "v" ); - - final ProjectVersionRef d1 = new SimpleProjectVersionRef( "g", "d1", "1" ); - final ProjectVersionRef d2 = new SimpleProjectVersionRef( "g", "d2", "2" ); - - final RelationshipGraph graph = - openGraph( new ViewParams( newWorkspaceId(), new DependencyFilter(), ManagedDependencyMutator.INSTANCE, gav ), - true ); - - /* @formatter:off */ - graph.storeRelationships( - new SimpleParentRelationship(src, gav), - new SimpleDependencyRelationship(src, gav, d1.asArtifactRef("jar", - null), DependencyScope.compile, 0, true, false, false ), - new SimpleDependencyRelationship(src, gav, d2.asArtifactRef("jar", - null), DependencyScope.compile, 1, true, false, false )); - /* @formatter:on */ - - graph.containsGraph( gav ); - } -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java deleted file mode 100644 index 238dbeb4..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelectionTCK.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.selection; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -import java.net.URI; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Ignore; -import org.junit.Test; - -public class SubGraphSelectionTCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); - final ProjectVersionRef varDep = new SimpleProjectVersionRef( "org.other", "dep", "1.0-SNAPSHOT" ); - final ProjectVersionRef varD2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0-SNAPSHOT" ); - final ProjectVersionRef selected = new SimpleProjectVersionRef( varDep, "1.0-20130314.161200-1" ); - final ProjectVersionRef sel2 = new SimpleProjectVersionRef( varD2, "1.0-20130314.161200-1" ); - - assertThat( varDep.isVariableVersion(), equalTo( true ) ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( project ); - - /* @formatter:off */ - graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null ), null, 0, false, false, false ) ); - /* @formatter:on */ - - Set variables = graph.getVariableSubgraphs(); - System.out.println( "Before selection here are the variable nodes: " + variables ); - assertThat( variables.contains( varDep ), equalTo( true ) ); - - final RelationshipGraph graph2 = - graphFactory().open( - new ViewParams.Builder( graph.getParams() ).withSelection( varDep.asProjectRef(), selected ) - .withSelection( varD2.asProjectRef(), sel2 ) - .build(), false ); - - // final ProjectVersionRef selDep = view.selectVersion( varDep.asProjectRef(), selected ); - // assertThat( selDep.asProjectRef(), equalTo( varDep.asProjectRef() ) ); - - variables = graph2.getVariableSubgraphs(); - System.out.println( "After selection here are the variable nodes: " + variables ); - assertThat( variables.isEmpty(), equalTo( true ) ); - - final Set incomplete = graph2.getIncompleteSubgraphs(); - System.out.println( "Checking missing subgraphs for: " + selected ); - assertThat( incomplete.contains( selected ), equalTo( true ) ); - } -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelection_ContextualToViewTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelection_ContextualToViewTCK.java deleted file mode 100644 index 17626951..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/selection/SubGraphSelection_ContextualToViewTCK.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.selection; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Ignore; -import org.junit.Test; - -import java.net.URI; -import java.util.Set; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -public class SubGraphSelection_ContextualToViewTCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final ProjectVersionRef project = new SimpleProjectVersionRef( "org.my", "project", "1.0" ); - final ProjectVersionRef varDep = new SimpleProjectVersionRef( "org.other", "dep", "1.0-SNAPSHOT" ); - final ProjectVersionRef varD2 = new SimpleProjectVersionRef( "org.other", "dep2", "1.0-SNAPSHOT" ); - final ProjectVersionRef selected = new SimpleProjectVersionRef( varDep, "1.0-20130314.161200-1" ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( project ); - - /* @formatter:off */ - graph.storeRelationships( new SimpleDependencyRelationship( source, project, new SimpleArtifactRef( varDep, null, null ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, varDep, new SimpleArtifactRef( varD2, null, null ), null, 0, false, false, false ) ); - /* @formatter:on */ - - Set variables = graph.getVariableSubgraphs(); - assertThat( variables.contains( varDep ), equalTo( true ) ); - - // Select a concrete version for the session associated with the FIRST graph. - // Second graph session should remain unchanged. - final RelationshipGraph graph2 = - graphFactory().open( new ViewParams.Builder( graph.getParams() ).withSelection( varDep.asProjectRef(), - selected ) - .build(), false ); - - assertThat( graph.getParams() - .getSelection( varDep ), nullValue() ); - assertThat( graph2.getParams() - .getSelection( varDep ), equalTo( selected ) ); - - assertThat( selected.asProjectRef(), equalTo( varDep.asProjectRef() ) ); - - assertThat( selected.asProjectVersionRef() - .equals( varDep.asProjectVersionRef() ), equalTo( false ) ); - - variables = graph.getVariableSubgraphs(); - assertThat( variables.contains( varDep ), equalTo( true ) ); - - variables = graph2.getVariableSubgraphs(); - assertThat( variables.contains( varDep ), equalTo( false ) ); - - Set incomplete = graph.getIncompleteSubgraphs(); - assertThat( incomplete.contains( selected ), equalTo( false ) ); - - incomplete = graph2.getIncompleteSubgraphs(); - assertThat( incomplete.contains( selected ), equalTo( true ) ); - - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/testutil/TCKDriver.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/testutil/TCKDriver.java deleted file mode 100644 index 6704b1e0..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/testutil/TCKDriver.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.testutil; - -import org.commonjava.maven.atlas.graph.spi.RelationshipGraphConnectionFactory; -import org.junit.rules.TemporaryFolder; - -import java.io.Closeable; - -/** - * Created by jdcasey on 8/24/15. - */ -public interface TCKDriver extends Closeable -{ - - void setup( TemporaryFolder temp ) - throws Exception; - - RelationshipGraphConnectionFactory getConnectionFactory() - throws Exception; -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_EmptyGrandparentRels_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_EmptyGrandparentRels_TCK.java deleted file mode 100644 index d76918e8..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_EmptyGrandparentRels_TCK.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.traverse.ancestry; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleExtensionRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; -import org.commonjava.maven.atlas.graph.traverse.AncestryTraversal; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Ignore; -import org.junit.Test; - -import java.net.URI; -import java.util.List; -import java.util.Set; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -public class AncestryTraversal_EmptyGrandparentRels_TCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final ProjectVersionRef myRef = new SimpleProjectVersionRef( "my.group", "my-artifact", "1.0" ); - final ProjectVersionRef parentRef = new SimpleProjectVersionRef( "my.group", "my-dad", "1" ); - final ProjectVersionRef grandRef = new SimpleProjectVersionRef( "other.group", "grandpa", "20120821" ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( myRef ); - - graph.storeRelationships( new SimpleParentRelationship( source, myRef, parentRef ), - new SimpleParentRelationship( source, parentRef, grandRef ) ); - - final AncestryTraversal ancestry = new AncestryTraversal(); - graph.traverse( ancestry ); - - final List ancestorRefs = ancestry.getAncestry(); - - assertThat( ancestorRefs.size(), equalTo( 3 ) ); - - int idx = 0; - ProjectVersionRef ref = ancestorRefs.get( idx++ ); - - assertThat( ref.getGroupId(), equalTo( "my.group" ) ); - assertThat( ref.getArtifactId(), equalTo( "my-artifact" ) ); - - ref = ancestorRefs.get( idx++ ); - - assertThat( ref.getGroupId(), equalTo( "my.group" ) ); - assertThat( ref.getArtifactId(), equalTo( "my-dad" ) ); - - ref = ancestorRefs.get( idx++ ); - - assertThat( ref.getGroupId(), equalTo( "other.group" ) ); - assertThat( ref.getArtifactId(), equalTo( "grandpa" ) ); - - } -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java deleted file mode 100644 index 07fa2a81..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_IgnoreNonParentRels_TCK.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.traverse.ancestry; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -import java.net.URI; -import java.util.List; -import java.util.Set; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.rel.*; -import org.commonjava.maven.atlas.graph.traverse.AncestryTraversal; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Ignore; -import org.junit.Test; - -public class AncestryTraversal_IgnoreNonParentRels_TCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final ProjectVersionRef myRef = new SimpleProjectVersionRef( "my.group", "my-artifact", "1.0" ); - final ProjectVersionRef parentRef = new SimpleProjectVersionRef( "my.group", "my-dad", "1" ); - final ProjectVersionRef grandRef = new SimpleProjectVersionRef( "other.group", "grandpa", "20120821" ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( myRef ); - - /* @formatter:off */ - graph.storeRelationships( new SimpleParentRelationship( source, myRef, parentRef ), - new SimpleDependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "foo", "1.0" ), null, null ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, myRef, new SimpleArtifactRef( new SimpleProjectVersionRef( "some.group", "bar", "1.2.1" ), null, null ), null, 1, false, false, false ), - new SimplePluginRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.5.1" ), 0, false, false ), - new SimplePluginRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins","maven-jar-plugin", "2.2" ), 1, false, false ), - new SimpleExtensionRelationship( source, myRef, new SimpleProjectVersionRef( "org.apache.maven.plugins", "maven-compiler-plugin", "2.5.1" ), 0, false ), - new SimpleParentRelationship( source, parentRef, grandRef ), - new SimpleDependencyRelationship( source, parentRef, new SimpleProjectVersionRef( "other.group", "utils", "3-1" ).asJarArtifact(), null, 0, false, false, false ) - ); - /* @formatter:on */ - - final AncestryTraversal ancestry = new AncestryTraversal(); - graph.traverse( ancestry ); - - final List ancestorRefs = ancestry.getAncestry(); - - assertThat( ancestorRefs.size(), equalTo( 3 ) ); - - int idx = 0; - ProjectVersionRef ref = ancestorRefs.get( idx++ ); - - assertThat( ref.getGroupId(), equalTo( "my.group" ) ); - assertThat( ref.getArtifactId(), equalTo( "my-artifact" ) ); - - ref = ancestorRefs.get( idx++ ); - - assertThat( ref.getGroupId(), equalTo( "my.group" ) ); - assertThat( ref.getArtifactId(), equalTo( "my-dad" ) ); - - ref = ancestorRefs.get( idx++ ); - - assertThat( ref.getGroupId(), equalTo( "other.group" ) ); - assertThat( ref.getArtifactId(), equalTo( "grandpa" ) ); - - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_TwoAncestors_TCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_TwoAncestors_TCK.java deleted file mode 100644 index 2ea347d5..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/ancestry/AncestryTraversal_TwoAncestors_TCK.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.traverse.ancestry; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleExtensionRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; -import org.commonjava.maven.atlas.graph.traverse.AncestryTraversal; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Ignore; -import org.junit.Test; - -import java.net.URI; -import java.util.List; -import java.util.Set; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -public class AncestryTraversal_TwoAncestors_TCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final ProjectVersionRef myRef = new SimpleProjectVersionRef( "my.group", "my-artifact", "1.0" ); - final ProjectVersionRef parentRef = new SimpleProjectVersionRef( "my.group", "my-dad", "1" ); - final ProjectVersionRef grandRef = new SimpleProjectVersionRef( "other.group", "grandpa", "20120821" ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( myRef ); - - graph.storeRelationships( new SimpleParentRelationship( source, myRef, parentRef ), - new SimpleParentRelationship( source, parentRef, grandRef ), - new SimpleParentRelationship( grandRef ) ); - - final Set projects = graph.getAllProjects(); - assertThat( projects.size(), equalTo( 3 ) ); - assertThat( projects.contains( myRef ), equalTo( true ) ); - assertThat( projects.contains( parentRef ), equalTo( true ) ); - assertThat( projects.contains( grandRef ), equalTo( true ) ); - - final AncestryTraversal ancestry = new AncestryTraversal(); - graph.traverse( ancestry ); - - final List ancestorRefs = ancestry.getAncestry(); - - logger.info( "Ancestry: {}", ancestorRefs ); - - assertThat( ancestorRefs.size(), equalTo( 3 ) ); - - int idx = 0; - ProjectVersionRef ref = ancestorRefs.get( idx++ ); - - assertThat( ref.getGroupId(), equalTo( "my.group" ) ); - assertThat( ref.getArtifactId(), equalTo( "my-artifact" ) ); - - ref = ancestorRefs.get( idx++ ); - - assertThat( ref.getGroupId(), equalTo( "my.group" ) ); - assertThat( ref.getArtifactId(), equalTo( "my-dad" ) ); - - ref = ancestorRefs.get( idx++ ); - - assertThat( ref.getGroupId(), equalTo( "other.group" ) ); - assertThat( ref.getArtifactId(), equalTo( "grandpa" ) ); - - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/AbstractBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/AbstractBuildOrderTCK.java deleted file mode 100644 index 683fea4f..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/AbstractBuildOrderTCK.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; - -import static org.apache.commons.lang.StringUtils.join; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.filter.DependencyFilter; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; -import org.commonjava.maven.atlas.graph.traverse.BuildOrderTraversal; -import org.commonjava.maven.atlas.graph.traverse.model.BuildOrder; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Test; -import org.slf4j.LoggerFactory; - -public class AbstractBuildOrderTCK - extends AbstractSPI_TCK -{ - - protected void assertRelativeOrder( final Map relativeOrder, - final List buildOrder ) - { - for ( final Map.Entry entry : relativeOrder.entrySet() ) - { - final ProjectRef k = entry.getKey() - .asProjectRef(); - final ProjectRef v = entry.getValue() - .asProjectRef(); - - final int kidx = buildOrder.indexOf( k ); - final int vidx = buildOrder.indexOf( v ); - - if ( kidx < 0 ) - { - fail( "Cannot find: " + k + " in build order: " + buildOrder ); - } - - if ( vidx < 0 ) - { - fail( "Cannot find: " + v + " in build order: " + buildOrder ); - } - - if ( vidx >= kidx ) - { - fail( "prerequisite project: " + v + " of: " + k + " appears AFTER it in the build order: " - + buildOrder ); - } - } - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java deleted file mode 100644 index 10589876..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyBuildOrderIgnoringPluginPathTCK.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.filter.DependencyFilter; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; -import org.commonjava.maven.atlas.graph.traverse.BuildOrderTraversal; -import org.commonjava.maven.atlas.graph.traverse.model.BuildOrder; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.junit.Ignore; -import org.junit.Test; - -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -/** - * Created by jdcasey on 8/24/15. - */ -public class DependencyBuildOrderIgnoringPluginPathTCK - extends AbstractBuildOrderTCK -{ - - @Test - public void run() - throws Exception - { - final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); - final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); - final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); - final ProjectVersionRef pa = new SimpleProjectVersionRef( "plugin.id", "p-a", "1" ); - final ProjectVersionRef pb = new SimpleProjectVersionRef( "plugin.id", "p-b", "2" ); - - final Map relativeOrder = - new HashMap(); - relativeOrder.put( c, b ); - relativeOrder.put( b, a ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( c ); - - /* @formatter:off */ - graph.storeRelationships( new SimpleParentRelationship( source, c ), - new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false, false ), - new SimplePluginRelationship( source, c, pb, 0, false, false ), - new SimpleDependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, b, a.asJarArtifact(), null, 0, false, false, false ) - ); - /* @formatter:on */ - - assertThat( graph.getAllRelationships() - .size(), equalTo( 4 ) ); - - final BuildOrderTraversal bo = new BuildOrderTraversal( new DependencyFilter( DependencyScope.test ) ); - graph.traverse( bo ); - - final BuildOrder buildOrderObj = bo.getBuildOrder(); - final List buildOrder = buildOrderObj.getOrder(); - - assertRelativeOrder( relativeOrder, buildOrder ); - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java deleted file mode 100644 index 89df7965..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/DependencyExcludesBuildOrderTCK.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.filter.DependencyFilter; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.traverse.BuildOrderTraversal; -import org.commonjava.maven.atlas.graph.traverse.model.BuildOrder; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.junit.Ignore; -import org.junit.Test; - -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -/** - * Created by jdcasey on 8/24/15. - */ -public class DependencyExcludesBuildOrderTCK - extends AbstractBuildOrderTCK -{ - @Test - public void run() - throws Exception - { - final ProjectVersionRef d = new SimpleProjectVersionRef( "group.id", "d", "4" ); - final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); - final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); - final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); - - final Map relativeOrder = - new HashMap(); - relativeOrder.put( c, b ); - relativeOrder.put( b, a ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( c ); - - /* @formatter:off */ - graph.storeRelationships( new SimpleParentRelationship( c ), - new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false, false, d ), - new SimpleDependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false, false, false ), - new SimpleDependencyRelationship( source, b, d.asJarArtifact(), DependencyScope.runtime, 1, false, false, false ) - ); - /* @formatter:on */ - - assertThat( graph.getAllRelationships() - .size(), equalTo( 3 ) ); - - final BuildOrderTraversal bo = new BuildOrderTraversal( new DependencyFilter( DependencyScope.runtime ) ); - graph.traverse( bo ); - - final BuildOrder buildOrderObj = bo.getBuildOrder(); - final List buildOrder = buildOrderObj.getOrder(); - - logger.info( "Build order: {}", buildOrder ); - assertThat( buildOrder.size(), equalTo( 3 ) ); - - assertRelativeOrder( relativeOrder, buildOrder ); - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java deleted file mode 100644 index d5afd24c..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/ParentDependencyBuildOrderTCK.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.filter.DependencyFilter; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.traverse.BuildOrderTraversal; -import org.commonjava.maven.atlas.graph.traverse.model.BuildOrder; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.junit.Ignore; -import org.junit.Test; -import org.slf4j.LoggerFactory; - -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -/** - * Created by jdcasey on 8/24/15. - */ -public class ParentDependencyBuildOrderTCK - extends AbstractBuildOrderTCK -{ - @Test - public void run() - throws Exception - - { - final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); - final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); - final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); - final ProjectVersionRef p = new SimpleProjectVersionRef( "group.id", "b-parent", "1001" ); - - final Map relativeOrder = - new HashMap(); - relativeOrder.put( c, b ); - relativeOrder.put( b, a ); - relativeOrder.put( b, p ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( c ); - - /* @formatter:off */ - graph.storeRelationships( new SimpleParentRelationship( source, c ), - new SimpleParentRelationship( source, b, p ), - new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, b, a.asJarArtifact(), null, 0, false, false, false ) - ); - /* @formatter:on */ - - assertThat( graph.getAllRelationships() - .size(), equalTo( 3 ) ); - - final BuildOrderTraversal bo = new BuildOrderTraversal( new DependencyFilter( DependencyScope.test ) ); - graph.traverse( bo ); - - final BuildOrder buildOrderObj = bo.getBuildOrder(); - final List buildOrder = buildOrderObj.getOrder(); - - LoggerFactory.getLogger( getClass() ) - .info( "Build order: {}", buildOrder ); - - assertThat( buildOrder.size(), equalTo( 4 ) ); - - assertRelativeOrder( relativeOrder, buildOrder ); - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java deleted file mode 100644 index 3b5c1d65..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/RuntimeDependencyBuildOrderTCK.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.filter.DependencyFilter; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; -import org.commonjava.maven.atlas.graph.traverse.BuildOrderTraversal; -import org.commonjava.maven.atlas.graph.traverse.model.BuildOrder; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.junit.Ignore; -import org.junit.Test; - -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -/** - * Created by jdcasey on 8/24/15. - */ -public class RuntimeDependencyBuildOrderTCK - extends AbstractBuildOrderTCK -{ - - @Test - public void run() - throws Exception - { - final ProjectVersionRef e = new SimpleProjectVersionRef( "group.id", "e", "5" ); - final ProjectVersionRef d = new SimpleProjectVersionRef( "group.id", "d", "4" ); - final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); - final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); - final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); - final ProjectVersionRef pa = new SimpleProjectVersionRef( "plugin.id", "p-a", "1" ); - final ProjectVersionRef pb = new SimpleProjectVersionRef( "plugin.id", "p-b", "2" ); - - final Map relativeOrder = - new HashMap(); - relativeOrder.put( c, b ); - relativeOrder.put( b, a ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( c ); - - /* @formatter:off */ - graph.storeRelationships( new SimpleParentRelationship( source, c ), - new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, c, d.asJarArtifact(), DependencyScope.test, 1, false, false, false ), - new SimplePluginRelationship( source, c, pb, 0, false, false ), - new SimpleDependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false, false, false ), - new SimpleDependencyRelationship( source, d, e.asJarArtifact(), DependencyScope.runtime, 0, false, false, false ), - new SimpleDependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false, false, false ) - ); - /* @formatter:on */ - - assertThat( graph.getAllRelationships() - .size(), equalTo( 6 ) ); - - final BuildOrderTraversal bo = new BuildOrderTraversal( new DependencyFilter( DependencyScope.runtime ) ); - graph.traverse( bo ); - - final BuildOrder buildOrderObj = bo.getBuildOrder(); - final List buildOrder = buildOrderObj.getOrder(); - - assertThat( buildOrder.size(), equalTo( 3 ) ); - - assertRelativeOrder( relativeOrder, buildOrder ); - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java deleted file mode 100644 index c1f634fe..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleDependencyBuildOrderTCK.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.filter.DependencyFilter; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.traverse.BuildOrderTraversal; -import org.commonjava.maven.atlas.graph.traverse.model.BuildOrder; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.junit.Ignore; -import org.junit.Test; - -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -/** - * Created by jdcasey on 8/24/15. - */ -public class SimpleDependencyBuildOrderTCK - extends AbstractBuildOrderTCK -{ - @Test - public void run() - throws Exception - { - final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); - final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); - final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); - - final Map relativeOrder = - new HashMap(); - relativeOrder.put( c, b ); - relativeOrder.put( b, a ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( c ); - - /* @formatter:off */ - graph.storeRelationships( new SimpleDependencyRelationship( source, c, new SimpleArtifactRef( b, null, null ), null, 0, false, false, false ), - new SimpleDependencyRelationship( source, b, new SimpleArtifactRef( a, null, null ), null, 0, false, false, false ) ); - /* @formatter:on */ - - assertThat( graph.getAllRelationships() - .size(), equalTo( 2 ) ); - - logger.info( "Starting build-order traversal" ); - final BuildOrderTraversal bo = new BuildOrderTraversal( new DependencyFilter( DependencyScope.test ) ); - graph.traverse( bo ); - - final BuildOrder buildOrderObj = bo.getBuildOrder(); - final List buildOrder = buildOrderObj.getOrder(); - - assertRelativeOrder( relativeOrder, buildOrder ); - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java deleted file mode 100644 index 52e4bfad..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/buildorder/SimpleEverythingBuildOrderTCK.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.traverse.buildorder; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; -import org.commonjava.maven.atlas.graph.traverse.BuildOrderTraversal; -import org.commonjava.maven.atlas.graph.traverse.model.BuildOrder; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.junit.Ignore; -import org.junit.Test; - -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.apache.commons.lang.StringUtils.join; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -/** - * Created by jdcasey on 8/24/15. - */ -public class SimpleEverythingBuildOrderTCK - extends AbstractBuildOrderTCK -{ - - @Test - public void run() - throws Exception - { - final ProjectVersionRef c = new SimpleProjectVersionRef( "group.id", "c", "3" ); - final ProjectVersionRef b = new SimpleProjectVersionRef( "group.id", "b", "2" ); - final ProjectVersionRef a = new SimpleProjectVersionRef( "group.id", "a", "1" ); - final ProjectVersionRef pa = new SimpleProjectVersionRef( "plugin.dep.id", "p-a", "1" ); - final ProjectVersionRef pb = new SimpleProjectVersionRef( "plugin.id", "p-b", "2" ); - - final Map relativeOrder = - new HashMap(); - relativeOrder.put( c, b ); - relativeOrder.put( b, a ); - relativeOrder.put( c, pb ); - relativeOrder.put( pb, pa ); - - final URI source = sourceURI(); - final RelationshipGraph graph = simpleGraph( c ); - - /* @formatter:off */ - graph.storeRelationships( new SimpleParentRelationship( source, c ), - new SimpleDependencyRelationship( source, c, b.asJarArtifact(), null, 0, false, false, false ), - new SimplePluginRelationship( source, c, pb, 0, false, false ), - new SimpleDependencyRelationship( source, b, a.asJarArtifact(), DependencyScope.runtime, 0, false, false, false ), - new SimpleDependencyRelationship( source, pb, pa.asJarArtifact(), null, 0, false, false, false ) - ); - /* @formatter:on */ - - System.out.println( "Got relationships:\n\n " + join( graph.getAllRelationships(), "\n " ) ); - assertThat( graph.getAllRelationships() - .size(), equalTo( 4 ) ); - - final BuildOrderTraversal bo = new BuildOrderTraversal(); - graph.traverse( bo ); - - final BuildOrder buildOrderObj = bo.getBuildOrder(); - final List buildOrder = buildOrderObj.getOrder(); - - System.out.printf( "Build order: %s\n", buildOrder ); - - assertRelativeOrder( relativeOrder, buildOrder ); - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDepTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDepTCK.java deleted file mode 100644 index 2779e9b2..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDepTCK.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.traverse.transdep; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.traverse.TransitiveDependencyTraversal; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Ignore; -import org.junit.Test; - -import java.net.URI; -import java.util.List; - -import static org.commonjava.maven.atlas.ident.DependencyScope.compile; -import static org.commonjava.maven.atlas.ident.util.IdentityUtils.projectVersion; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -public class TransitiveDependencyTraversal_DepOfDepTCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final URI source = sourceURI(); - final ProjectVersionRef root = projectVersion( "group.id", "my-project", "1.0" ); - final ProjectVersionRef d1 = projectVersion( "other.group", "dep-L1", "1.0.1" ); - final ProjectVersionRef d2 = projectVersion( "foo", "dep-L2", "1.1.1" ); - - final RelationshipGraph graph = simpleGraph( root ); - - /* @formatter:off */ - graph.storeRelationships( new SimpleParentRelationship( source, root ), - new SimpleDependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false, false, false ), - new SimpleDependencyRelationship( source, d1, d2.asJarArtifact(), compile, 0, false, false, false ) - ); - /* @formatter:on */ - - final TransitiveDependencyTraversal depTraversal = new TransitiveDependencyTraversal(); - graph.traverse( depTraversal ); - - final List artifacts = depTraversal.getArtifacts(); - - assertThat( artifacts.size(), equalTo( 2 ) ); - - int idx = 0; - - ArtifactRef ref = artifacts.get( idx++ ); - assertThat( ref.getArtifactId(), equalTo( "dep-L1" ) ); - - ref = artifacts.get( idx++ ); - assertThat( ref.getArtifactId(), equalTo( "dep-L2" ) ); - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDep_ExtMgmtTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDep_ExtMgmtTCK.java deleted file mode 100644 index ff3e078f..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_DepOfDep_ExtMgmtTCK.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.traverse.transdep; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.traverse.TransitiveDependencyTraversal; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Ignore; -import org.junit.Test; - -import java.net.URI; -import java.util.List; - -import static org.commonjava.maven.atlas.ident.DependencyScope.compile; -import static org.commonjava.maven.atlas.ident.util.IdentityUtils.projectVersion; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -public class TransitiveDependencyTraversal_DepOfDep_ExtMgmtTCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final URI source = sourceURI(); - final ProjectVersionRef root = projectVersion( "group.id", "my-project", "1.0" ); - final ProjectVersionRef d1 = projectVersion( "other.group", "dep-L1", "1.0.1" ); - final ProjectVersionRef d2 = projectVersion( "foo", "dep-L2", "1.1.1" ); - final ProjectVersionRef d3 = projectVersion( "foo", "dep-L2", "1.1.2" ); - - RelationshipGraph graph = simpleGraph( root ); - - /* @formatter:off */ - graph.storeRelationships( new SimpleParentRelationship( source, root ), - new SimpleDependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false, false, false ), - new SimpleDependencyRelationship( source, d1, d2.asJarArtifact(), compile, 0, false, false, false ) - ); - /* @formatter:on */ - - graph = graphFactory().open( new ViewParams.Builder( graph.getParams() ).withSelection( d2.asProjectRef(), d3 ) - .build(), false ); - - // graph.getView() - // .selectVersion( d2.asProjectRef(), d3 ); - - final TransitiveDependencyTraversal depTraversal = new TransitiveDependencyTraversal(); - graph.traverse( depTraversal ); - - final List artifacts = depTraversal.getArtifacts(); - - assertThat( artifacts.size(), equalTo( 2 ) ); - - int idx = 0; - - ArtifactRef ref = artifacts.get( idx++ ); - assertThat( ref.getArtifactId(), equalTo( "dep-L1" ) ); - - ref = artifacts.get( idx++ ); - assertThat( ref.getArtifactId(), equalTo( "dep-L2" ) ); - assertThat( ref.getVersionString(), equalTo( d3.getVersionString() ) ); - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferDirectTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferDirectTCK.java deleted file mode 100644 index 78fee1ed..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferDirectTCK.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.traverse.transdep; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.traverse.TransitiveDependencyTraversal; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Ignore; -import org.junit.Test; - -import java.net.URI; -import java.util.List; - -import static org.commonjava.maven.atlas.ident.DependencyScope.compile; -import static org.commonjava.maven.atlas.ident.util.IdentityUtils.projectVersion; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -public class TransitiveDependencyTraversal_PreferDirectTCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final URI source = sourceURI(); - - final ProjectVersionRef root = projectVersion( "group.id", "my-project", "1.0" ); - final ProjectVersionRef d1 = projectVersion( "other.group", "dep-L1", "1.0.1" ); - final ProjectVersionRef d2a = projectVersion( "foo", "dep-L2", "1.1.1" ); - final ProjectVersionRef d2b = projectVersion( "foo", "dep-L2", "1.0" ); - - final RelationshipGraph graph = simpleGraph( root ); - - /* @formatter:off */ - graph.storeRelationships( new SimpleParentRelationship( source, root ), - new SimpleDependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false, false, false ), - new SimpleDependencyRelationship( source, root, d2a.asJarArtifact(), compile, 1, false, false, false ), - new SimpleDependencyRelationship( source, d1, d2b.asJarArtifact(), compile, 0, false, false, false ) - ); - /* @formatter:on */ - - final TransitiveDependencyTraversal depTraversal = new TransitiveDependencyTraversal(); - graph.traverse( depTraversal ); - - final List artifacts = depTraversal.getArtifacts(); - - assertThat( artifacts.size(), equalTo( 2 ) ); - - int idx = 0; - - ArtifactRef ref = artifacts.get( idx++ ); - assertThat( ref.getArtifactId(), equalTo( "dep-L1" ) ); - - ref = artifacts.get( idx++ ); - assertThat( ref.getArtifactId(), equalTo( "dep-L2" ) ); - assertThat( ref.getVersionSpec() - .renderStandard(), equalTo( "1.1.1" ) ); - } - -} diff --git a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferLocalTCK.java b/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferLocalTCK.java deleted file mode 100644 index d38ba9cc..00000000 --- a/tck/src/main/java/org/commonjava/maven/atlas/tck/graph/traverse/transdep/TransitiveDependencyTraversal_PreferLocalTCK.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.commonjava.maven.atlas.tck.graph.traverse.transdep; - -import static org.commonjava.maven.atlas.ident.DependencyScope.compile; -import static org.commonjava.maven.atlas.ident.util.IdentityUtils.projectVersion; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -import java.net.URI; -import java.util.List; - -import org.commonjava.maven.atlas.graph.RelationshipGraph; -import org.commonjava.maven.atlas.graph.ViewParams; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.traverse.TransitiveDependencyTraversal; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.tck.graph.AbstractSPI_TCK; -import org.junit.Ignore; -import org.junit.Test; - -public class TransitiveDependencyTraversal_PreferLocalTCK - extends AbstractSPI_TCK -{ - - @Test - public void run() - throws Exception - { - final URI source = sourceURI(); - - final ProjectVersionRef root = projectVersion( "group.id", "my-project", "1.0" ); - final ProjectVersionRef parent = projectVersion( "group.id", "parent", "1" ); - final ProjectVersionRef d1a = projectVersion( "other.group", "dep-L1", "1.1.1" ); - final ProjectVersionRef d1b = projectVersion( "other.group", "dep-L1", "1.0" ); - - final RelationshipGraph graph = simpleGraph( root ); - - /* @formatter:off */ - graph.storeRelationships( new SimpleParentRelationship( source, root, parent ), - new SimpleDependencyRelationship( source, root, d1a.asJarArtifact(), compile, 0, false, false, false ), - new SimpleDependencyRelationship( source, parent, d1b.asJarArtifact(), compile, 0, false, false, false ) - ); - /* @formatter:on */ - - final TransitiveDependencyTraversal depTraversal = new TransitiveDependencyTraversal(); - graph.traverse( depTraversal ); - - final List artifacts = depTraversal.getArtifacts(); - - assertThat( artifacts.size(), equalTo( 1 ) ); - - int idx = 0; - - final ArtifactRef ref = artifacts.get( idx++ ); - assertThat( ref.getArtifactId(), equalTo( "dep-L1" ) ); - - assertThat( ref.getVersionSpec() - .renderStandard(), equalTo( "1.1.1" ) ); - } - -} From 78f23066f066a334fd6ae8b9142ee31dfd727604 Mon Sep 17 00:00:00 2001 From: Rui Han Date: Tue, 13 Dec 2016 17:50:43 +0800 Subject: [PATCH 143/240] Add profileLocation() back to RelationshipUtils because galley use it --- .../atlas/graph/util/RelationshipUtils.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java index 10d0da82..c73b1dfd 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java @@ -15,9 +15,11 @@ */ package org.commonjava.maven.atlas.graph.util; +import static org.commonjava.maven.atlas.graph.rel.RelationshipConstants.POM_ROOT_URI; import static org.commonjava.maven.atlas.ident.util.IdentityUtils.artifact; import java.net.URI; +import java.net.URISyntaxException; import java.util.Collection; import java.util.Iterator; @@ -139,4 +141,21 @@ public static void filterTerminalParents( final Collection Date: Tue, 17 Jan 2017 10:02:19 -0600 Subject: [PATCH 144/240] add missing license header and update bom version --- pom.xml | 2 +- .../atlas/graph/rel/RelationshipConstants.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ea568e64..45371e09 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,7 @@ org.commonjava.boms web-commons-bom - 17 + 21 import pom diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipConstants.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipConstants.java index a295b0ec..04903fc8 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipConstants.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipConstants.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.rel; import java.net.URI; From 6cb1cd943d61f6816e915f2c2fdf87074c3d09ee Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 17 Jan 2017 10:02:52 -0600 Subject: [PATCH 145/240] [maven-release-plugin] prepare release atlas-parent-0.17.0 --- bindings/jackson-identities/pom.xml | 2 +- bindings/jackson-relationships/pom.xml | 2 +- bindings/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 12 ++++++------ relationships-api/pom.xml | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 586c12ae..2ef274ab 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.16.3-SNAPSHOT + 0.17.0 atlas-bindings-jackson-identities diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml index 76b7ac0f..deaa8991 100644 --- a/bindings/jackson-relationships/pom.xml +++ b/bindings/jackson-relationships/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.16.3-SNAPSHOT + 0.17.0 atlas-bindings-jackson-relationships diff --git a/bindings/pom.xml b/bindings/pom.xml index e503af42..7849b541 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.3-SNAPSHOT + 0.17.0 atlas-bindings-parent diff --git a/identities/pom.xml b/identities/pom.xml index a53045a3..bfe3c8bd 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.3-SNAPSHOT + 0.17.0 atlas-identities diff --git a/pom.xml b/pom.xml index 45371e09..c6f35644 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.3-SNAPSHOT + 0.17.0 pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - HEAD + atlas-parent-0.17.0 @@ -48,22 +48,22 @@ org.commonjava.maven.atlas atlas-identities - 0.16.3-SNAPSHOT + 0.17.0 org.commonjava.maven.atlas atlas-relationships-api - 0.16.3-SNAPSHOT + 0.17.0 org.commonjava.maven.atlas atlas-bindings-jackson-identities - 0.16.3-SNAPSHOT + 0.17.0 org.commonjava.maven.atlas atlas-bindings-jackson-relationships - 0.16.3-SNAPSHOT + 0.17.0 org.commonjava.boms diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index fed556e0..2d5b4b6e 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.16.3-SNAPSHOT + 0.17.0 atlas-relationships-api From 17f2e463b9c92ba61f2fd5cef5e4819e2341d7a1 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 17 Jan 2017 10:03:03 -0600 Subject: [PATCH 146/240] [maven-release-plugin] prepare for next development iteration --- bindings/jackson-identities/pom.xml | 2 +- bindings/jackson-relationships/pom.xml | 2 +- bindings/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 12 ++++++------ relationships-api/pom.xml | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 2ef274ab..1d69d3ee 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.17.0 + 0.17.1-SNAPSHOT atlas-bindings-jackson-identities diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml index deaa8991..47244fca 100644 --- a/bindings/jackson-relationships/pom.xml +++ b/bindings/jackson-relationships/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.17.0 + 0.17.1-SNAPSHOT atlas-bindings-jackson-relationships diff --git a/bindings/pom.xml b/bindings/pom.xml index 7849b541..1065a532 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.0 + 0.17.1-SNAPSHOT atlas-bindings-parent diff --git a/identities/pom.xml b/identities/pom.xml index bfe3c8bd..95250076 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.0 + 0.17.1-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index c6f35644..033d73bc 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.0 + 0.17.1-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - atlas-parent-0.17.0 + HEAD @@ -48,22 +48,22 @@ org.commonjava.maven.atlas atlas-identities - 0.17.0 + 0.17.1-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.17.0 + 0.17.1-SNAPSHOT org.commonjava.maven.atlas atlas-bindings-jackson-identities - 0.17.0 + 0.17.1-SNAPSHOT org.commonjava.maven.atlas atlas-bindings-jackson-relationships - 0.17.0 + 0.17.1-SNAPSHOT org.commonjava.boms diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 2d5b4b6e..0e067c7f 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.0 + 0.17.1-SNAPSHOT atlas-relationships-api From b9deb2c7a1ecfbf23e8f06c7e7f162b9818888cf Mon Sep 17 00:00:00 2001 From: Rui Han Date: Thu, 23 Feb 2017 15:53:57 +0800 Subject: [PATCH 147/240] Support to serialize/deserialize EProjectRelationships --- bindings/jackson-relationships/pom.xml | 52 ------- bindings/pom.xml | 5 - relationships-api/pom.xml | 16 ++ .../graph/jackson/PluginKeyDeserializer.java | 40 +++++ .../graph/jackson/PluginKeySerializer.java | 24 +++ .../ProjectRelationshipDeserializer.java | 0 .../ProjectRelationshipSerializer.java | 0 .../ProjectRelationshipSerializerModule.java | 3 + .../graph/jackson/SerializationConstants.java | 0 .../model/EProjectDirectRelationships.java | 78 ++++++---- .../maven/atlas/graph/model/PluginKey.java | 146 ++++++++++++++++++ .../EProjectRelationshipsSerializerTest.java | 121 +++++++++++++++ ...ojectRelationshipSerializerModuleTest.java | 0 13 files changed, 399 insertions(+), 86 deletions(-) delete mode 100644 bindings/jackson-relationships/pom.xml create mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/PluginKeyDeserializer.java create mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/PluginKeySerializer.java rename {bindings/jackson-relationships => relationships-api}/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java (100%) rename {bindings/jackson-relationships => relationships-api}/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java (100%) rename {bindings/jackson-relationships => relationships-api}/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java (93%) rename {bindings/jackson-relationships => relationships-api}/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java (100%) create mode 100644 relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/PluginKey.java create mode 100644 relationships-api/src/test/java/org/commonjava/maven/atlas/graph/jackson/EProjectRelationshipsSerializerTest.java rename {bindings/jackson-relationships => relationships-api}/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java (100%) diff --git a/bindings/jackson-relationships/pom.xml b/bindings/jackson-relationships/pom.xml deleted file mode 100644 index 47244fca..00000000 --- a/bindings/jackson-relationships/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - 4.0.0 - - - org.commonjava.maven.atlas - atlas-bindings-parent - 0.17.1-SNAPSHOT - - - atlas-bindings-jackson-relationships - - Atlas :: Maven Project-Graph :: Jackson Relationships API Bindings - - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-core - - - org.commonjava.maven.atlas - atlas-relationships-api - - - org.commonjava.maven.atlas - atlas-bindings-jackson-identities - test - - - - diff --git a/bindings/pom.xml b/bindings/pom.xml index 1065a532..67351b47 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -35,14 +35,9 @@ org.commonjava.maven.atlas atlas-identities - - org.commonjava.maven.atlas - atlas-relationships-api - jackson-identities - jackson-relationships diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 0e067c7f..316a3f19 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -34,6 +34,22 @@ org.commonjava.maven.atlas atlas-identities + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-core + + + org.commonjava.maven.atlas + atlas-bindings-jackson-identities + commons-codec commons-codec diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/PluginKeyDeserializer.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/PluginKeyDeserializer.java new file mode 100644 index 00000000..379bd0d8 --- /dev/null +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/PluginKeyDeserializer.java @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.jackson; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.KeyDeserializer; +import org.commonjava.maven.atlas.graph.model.PluginKey; + +import java.io.IOException; + +/** + * Created by ruhan on 3/16/17. + */ +@SuppressWarnings( { "rawtypes", "unchecked" } ) +public final class PluginKeyDeserializer + extends KeyDeserializer +{ + public PluginKeyDeserializer() {} + + @Override + public Object deserializeKey(String json, DeserializationContext ctx) + throws IOException, JsonProcessingException + { + return PluginKey.parse( json ); + } +} diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/PluginKeySerializer.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/PluginKeySerializer.java new file mode 100644 index 00000000..0f9d959b --- /dev/null +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/PluginKeySerializer.java @@ -0,0 +1,24 @@ +package org.commonjava.maven.atlas.graph.jackson; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import org.commonjava.maven.atlas.graph.model.PluginKey; + +import java.io.IOException; + +/** + * Created by ruhan on 3/17/17. + */ +public class PluginKeySerializer + extends JsonSerializer +{ + + @Override + public void serialize(PluginKey pluginKey, JsonGenerator gen, SerializerProvider provider) + throws IOException, JsonProcessingException + { + gen.writeFieldName( pluginKey.toString() ); + } +} diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java similarity index 100% rename from bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java rename to relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java similarity index 100% rename from bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java rename to relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java similarity index 93% rename from bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java rename to relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java index 9d802700..6e39bd3d 100644 --- a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java @@ -16,6 +16,7 @@ package org.commonjava.maven.atlas.graph.jackson; import com.fasterxml.jackson.databind.module.SimpleModule; +import org.commonjava.maven.atlas.graph.model.PluginKey; import org.commonjava.maven.atlas.graph.rel.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,6 +52,8 @@ public ProjectRelationshipSerializerModule() { register( cls ); } + addKeySerializer( PluginKey.class, new PluginKeySerializer() ); + addKeyDeserializer( PluginKey.class, new PluginKeyDeserializer() ); } private void register( Class cls ) diff --git a/bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java similarity index 100% rename from bindings/jackson-relationships/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java rename to relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java index 51be378c..47a355fa 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java @@ -30,7 +30,18 @@ import java.util.Map; import java.util.Set; -import org.commonjava.maven.atlas.graph.rel.*; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.commonjava.maven.atlas.graph.rel.BomRelationship; +import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; +import org.commonjava.maven.atlas.graph.rel.ParentRelationship; +import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.PluginRelationship; +import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleExtensionRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; +import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; import org.commonjava.maven.atlas.ident.DependencyScope; import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; import org.commonjava.maven.atlas.ident.ref.ProjectRef; @@ -42,25 +53,27 @@ public class EProjectDirectRelationships private static final long serialVersionUID = 1L; - private final URI source; + private URI source; - private final ProjectVersionRef ref; + private ProjectVersionRef projectRef; - private final List boms; + private List boms; - private final List dependencies; + private List dependencies; - private final List managedDependencies; + private List managedDependencies; - private final List plugins; + private List plugins; - private final List managedPlugins; + private List managedPlugins; - private final List extensions; + private List extensions; - private final ParentRelationship parent; + private ParentRelationship parent; - private final Map> pluginDependencies; + private Map> pluginDependencies; + + public EProjectDirectRelationships() {} public EProjectDirectRelationships( final URI source, final ProjectVersionRef ref, @@ -69,10 +82,10 @@ public EProjectDirectRelationships( final URI source, final List dependencies, final List plugins, final List managedDependencies, final List managedPlugins, final List extensions, - final Map> pluginDependencies ) + final Map> pluginDependencies ) { this.source = source; - this.ref = ref; + this.projectRef = ref; this.parent = parent; this.boms = Collections.unmodifiableList( boms ); this.dependencies = Collections.unmodifiableList( dependencies ); @@ -81,10 +94,10 @@ public EProjectDirectRelationships( final URI source, this.managedPlugins = Collections.unmodifiableList( managedPlugins ); this.extensions = Collections.unmodifiableList( extensions ); - final HashMap> pdrels = - new HashMap>(); + final HashMap> pdrels = + new HashMap>(); - for ( final Map.Entry> entry : pluginDependencies.entrySet() ) + for ( final Map.Entry> entry : pluginDependencies.entrySet() ) { pdrels.put( entry.getKey(), Collections.unmodifiableList( entry.getValue() ) ); } @@ -92,9 +105,14 @@ public EProjectDirectRelationships( final URI source, this.pluginDependencies = Collections.unmodifiableMap( pdrels ); } + public final URI getSource() + { + return source; + } + public final ProjectVersionRef getProjectRef() { - return ref; + return projectRef; } public final List getDependencies() @@ -127,7 +145,7 @@ public final ParentRelationship getParent() return parent; } - public final Map> getPluginDependencies() + public final Map> getPluginDependencies() { return pluginDependencies; } @@ -135,8 +153,8 @@ public final Map> getPlug public final List getPluginDependencies( final ProjectVersionRef plugin, final boolean managed, final boolean inherited ) { - final PluginRelationship pr = new SimplePluginRelationship( source, getProjectRef(), plugin, 0, managed, inherited ); - return pluginDependencies.get( pr ); + PluginKey pk = new PluginKey( plugin, managed ); + return pluginDependencies.get( pk ); } public final List getBoms() @@ -144,6 +162,7 @@ public final List getBoms() return boms; } + @JsonIgnore @Override public Set> getAllRelationships() { @@ -153,6 +172,7 @@ public final List getBoms() return rels; } + @JsonIgnore @Override public Set> getExactAllRelationships() { @@ -197,8 +217,8 @@ public static final class Builder private ParentRelationship parent; - private final Map> pluginDependencies = - new HashMap>(); + private final Map> pluginDependencies = + new HashMap>(); public Builder( final URI source, final ProjectVersionRef projectRef, final String... activeProfiles ) { @@ -329,14 +349,14 @@ public Builder withPluginDependencies( final Collection pdrs = pluginDependencies.get( pr ); + List pdrs = pluginDependencies.get( pk ); if ( pdrs == null ) { pdrs = new ArrayList(); - pluginDependencies.put( pr, pdrs ); + pluginDependencies.put( pk, pdrs ); } if ( !pdrs.contains( rel ) ) @@ -451,7 +471,7 @@ public int getNextPluginDependencyIndex( final ProjectVersionRef plugin, final b final boolean inherited ) { final List list = - pluginDependencies.get( new SimplePluginRelationship( source, ref, plugin, 0, managed, inherited ) ); + pluginDependencies.get( new PluginKey( plugin, managed ) ); return list == null ? 0 : list.size(); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/PluginKey.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/PluginKey.java new file mode 100644 index 00000000..7409e0ce --- /dev/null +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/PluginKey.java @@ -0,0 +1,146 @@ +package org.commonjava.maven.atlas.graph.model; + +import org.commonjava.maven.atlas.graph.rel.PluginRelationship; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; + +import java.io.Serializable; + +/** + * Created by ruhan on 3/17/17. + */ +public final class PluginKey + implements Serializable +{ + private String groupId; + + private String artifactId; + + private String version; + + private boolean managed; + + public PluginKey() {} + + public PluginKey(ProjectVersionRef target, boolean managed) + { + this.groupId = target.getGroupId(); + this.artifactId = target.getArtifactId(); + this.version = target.getVersionString(); + this.managed = managed; + } + + public PluginKey(PluginRelationship rel) + { + this(rel.getTarget(), rel.isManaged()); + } + + public String getGroupId() + { + return groupId; + } + + public String getArtifactId() + { + return artifactId; + } + + public String getVersion() + { + return version; + } + + public boolean getManaged() + { + return managed; + } + + @Override + public String toString() + { + return String.format( "%s:%s:%s:%s", groupId, artifactId, version, managed ); + } + + public static PluginKey parse( final String pk ) + { + final String[] parts = pk.split( ":" ); + if ( parts.length < 4 ) + { + throw new RuntimeException( "PluginKey parse failed. (Given: '" + pk + "')" ); + } + PluginKey ret = new PluginKey(); + ret.groupId = parts[0]; + ret.artifactId = parts[1]; + ret.version = parts[2]; + ret.managed = Boolean.parseBoolean(parts[3]); + return ret; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ((groupId == null) ? 0 : groupId.hashCode()); + result = prime * result + ((artifactId == null) ? 0 : artifactId.hashCode()); + result = prime * result + ((version == null) ? 0 : version.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) + { + if (this == obj) + { + return true; + } + if (obj == null) + { + return false; + } + if (!(obj instanceof PluginKey)) + { + return false; + } + + final PluginKey other = (PluginKey) obj; + + if (groupId == null) + { + if (other.getGroupId() != null) + { + return false; + } + } + else if (!groupId.equals(other.getGroupId())) + { + return false; + } + + if (artifactId == null) + { + if (other.getArtifactId() != null) + { + return false; + } + } + else if (!artifactId.equals(other.getArtifactId())) + { + return false; + } + + if (version == null) + { + if (other.getVersion() != null) + { + return false; + } + } + else if (!version.equals(other.getVersion())) + { + return false; + } + + return managed == other.getManaged(); + } + +} diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/jackson/EProjectRelationshipsSerializerTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/jackson/EProjectRelationshipsSerializerTest.java new file mode 100644 index 00000000..db71641a --- /dev/null +++ b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/jackson/EProjectRelationshipsSerializerTest.java @@ -0,0 +1,121 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.maven.atlas.graph.jackson; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.commonjava.maven.atlas.graph.model.EProjectDirectRelationships; +import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; +import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.PluginRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimpleExtensionRelationship; +import org.commonjava.maven.atlas.graph.rel.SimplePluginDependencyRelationship; +import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; +import org.commonjava.maven.atlas.ident.DependencyScope; +import org.commonjava.maven.atlas.ident.jackson.ProjectVersionRefSerializerModule; +import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; +import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.junit.Before; +import org.junit.Test; + +import java.net.URI; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +/** + * Created by ruhan on 3/16/17. + */ +public class EProjectRelationshipsSerializerTest +{ + + private ObjectMapper mapper; + + @Before + public void before() + { + mapper = new ObjectMapper(); + mapper.registerModules( new ProjectVersionRefSerializerModule(), new ProjectRelationshipSerializerModule() ); + } + + @Test + public void roundTrip_EProjectDirectRelationships() + throws Exception + { + URI sourceUri = new URI( "test:source" ); + ProjectVersionRef p = new SimpleProjectVersionRef( "org.apache.maven", "maven-core", "3.0.3" ); + + EProjectDirectRelationships.Builder prb = new EProjectDirectRelationships.Builder( sourceUri, p ); + + ProjectVersionRef parent = new SimpleProjectVersionRef( "org.apache.maven", "maven", "3.0.3" ); + + int idx = 0; + int pidx = 0; + int pdidx = 0; + final DependencyRelationship papi = + new SimpleDependencyRelationship( sourceUri, p, new SimpleArtifactRef( "org.apache.maven", "maven-plugin-api", "3.0.3", + null, null ), DependencyScope.compile, + idx++, false, false, false ); + final DependencyRelationship art = + new SimpleDependencyRelationship( sourceUri, p, new SimpleArtifactRef( "org.apache.maven", "maven-artifact", "3.0.3", + null, null ), DependencyScope.compile, + idx++, false, false, false ); + final PluginRelationship jarp = + new SimplePluginRelationship( sourceUri, p, new SimpleProjectVersionRef( "org.apache.maven.plugins", + "maven-jar-plugin", "2.2" ), pidx++, false, false ); + final PluginRelationship comp = + new SimplePluginRelationship( sourceUri, p, new SimpleProjectVersionRef( "org.apache.maven.plugins", + "maven-compiler-plugin", "2.3.2" ), pidx++, + false, false ); + final PluginDependencyRelationship pdr = + new SimplePluginDependencyRelationship( sourceUri, p, + new SimpleProjectRef( "org.apache.maven.plugins", "maven-compiler-plugin" ), + new SimpleArtifactRef( new SimpleProjectVersionRef("org.apache.test", "test", "1.1"), "pom", null ), + pdidx++, + false, false ); + final ExtensionRelationship wag = + new SimpleExtensionRelationship( sourceUri, p, new SimpleProjectVersionRef( "org.apache.maven.wagon", + "wagon-provider-webdav", "1.0" ), 0, false ); + + prb.withParent( parent ); + prb.withDependencies( papi, art ); + prb.withPlugins( jarp, comp ); + prb.withPlugins( comp ); + prb.withPluginDependencies( pdr ); + prb.withExtensions( wag ); + + final EProjectDirectRelationships rels = prb.build(); + + String json = mapper.writeValueAsString( rels ); + System.out.println( json ); + + EProjectDirectRelationships clone = mapper.readValue(json, EProjectDirectRelationships.class); + + assertThat( clone.getSource(), equalTo( rels.getSource() ) ); + assertThat( clone.getProjectRef(), equalTo( rels.getProjectRef() ) ); + assertThat( clone.getParent(), equalTo( rels.getParent() ) ); + assertThat( clone.getBoms(), equalTo( rels.getBoms() ) ); + assertThat( clone.getDependencies(), equalTo( rels.getDependencies() ) ); + assertThat( clone.getPlugins(), equalTo( rels.getPlugins() ) ); + assertThat( clone.getPluginDependencies(), equalTo( rels.getPluginDependencies() ) ); + assertThat( clone.getExtensions(), equalTo( rels.getExtensions() ) ); + assertThat( clone.getManagedDependencies(), equalTo( rels.getManagedDependencies() ) ); + assertThat( clone.getManagedPlugins(), equalTo( rels.getManagedPlugins() ) ); + } +} diff --git a/bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java b/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java similarity index 100% rename from bindings/jackson-relationships/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java rename to relationships-api/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java From 7188bbf49d07dda0e88c1e74470d7b79e71822b9 Mon Sep 17 00:00:00 2001 From: Gang Li Date: Fri, 14 Apr 2017 12:56:53 +0800 Subject: [PATCH 148/240] Fix phrases parsing for case of *rebuild-SNAPSHOT --- .../atlas/ident/version/SingleVersion.java | 5 +++- .../ident/ref/ProjectVersionRefTest.java | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/SingleVersion.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/SingleVersion.java index 703c1ffa..35b80464 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/SingleVersion.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/version/SingleVersion.java @@ -92,7 +92,10 @@ private List parsePhrases( final List p ) if ( ( part instanceof SeparatorPart ) && ( VersionPartSeparator.DASH == ( (SeparatorPart) part ).getValue() ) ) { - if ( prev != null && !( prev instanceof StringPart ) ) + // the next part is considering something like: "rebuild-SNAPTHOT" + final boolean prevNotString = !( prev instanceof StringPart ); + final boolean nextIsSnapshot = ( next != null && ( next instanceof SnapshotPart ) ); + if ( prev != null && ( prevNotString || nextIsSnapshot ) ) { try { diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRefTest.java b/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRefTest.java index aa99d9e0..45445e77 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRefTest.java +++ b/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRefTest.java @@ -17,12 +17,15 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; import java.util.HashSet; +import java.util.List; import java.util.Set; import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; import org.commonjava.maven.atlas.ident.version.VersionSpec; +import org.commonjava.maven.atlas.ident.version.part.VersionPhrase; import org.junit.Test; public class ProjectVersionRefTest @@ -87,4 +90,27 @@ public void addTwoIdenticalCompoundRefsToASetAndVerifyThatOnlyOneIsAdded() assertThat( set.add( ref2 ), equalTo( false ) ); } + @Test + public void parseSnapshotWithNumericRebuildSuffix() + throws InvalidVersionSpecificationException + { + final String ver = "org.bar:foo:2.1.1.rebuild-SNAPSHOT"; + + final ProjectVersionRef ref = SimpleProjectVersionRef.parse( ver ); + //new SimpleProjectVersionRef( "g", "a", ver ); + final VersionSpec spec = ref.getVersionSpec(); + final List phrases = spec.getSingleVersion().getVersionPhrases(); + + System.out.println ("### ref " + ref + " and snap " + ref.getVersionSpec().isSnapshot()); + System.out.println ("### spec " + spec.getSingleVersion() + " and " + spec.renderStandard()); + System.out.println ("### phrases " + phrases); + System.out.println ("### snap " + spec.getSingleVersion().getSnapshotPart().renderStandard()); + System.out.println ("### snap " + spec.getSingleVersion().isSnapshot()); + + assertTrue ( ref.isSnapshot() ); + assertThat( "org.bar:foo:" + spec.renderStandard(), equalTo( ver ) ); + assertTrue( "SNAPSHOT".equals( spec.getSingleVersion().getSnapshotPart().renderStandard() ) ); + assertTrue( phrases.size() == 3); + } + } From bc7c29b24bd1c6e06bcae3fe1ed6c995fe803699 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 18 Apr 2017 14:03:46 -0500 Subject: [PATCH 149/240] fix license headers --- .../atlas/graph/jackson/PluginKeySerializer.java | 15 +++++++++++++++ .../maven/atlas/graph/model/PluginKey.java | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/PluginKeySerializer.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/PluginKeySerializer.java index 0f9d959b..834046bb 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/PluginKeySerializer.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/PluginKeySerializer.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.jackson; import com.fasterxml.jackson.core.JsonGenerator; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/PluginKey.java b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/PluginKey.java index 7409e0ce..42cb80a3 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/PluginKey.java +++ b/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/PluginKey.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (jdcasey@commonjava.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.commonjava.maven.atlas.graph.model; import org.commonjava.maven.atlas.graph.rel.PluginRelationship; From 05b21fd22577f4c3778596e098dc26620bdc0f87 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 18 Apr 2017 14:04:17 -0500 Subject: [PATCH 150/240] [maven-release-plugin] prepare release atlas-parent-0.17.1 --- bindings/jackson-identities/pom.xml | 2 +- bindings/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 1d69d3ee..7de2c9df 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.17.1-SNAPSHOT + 0.17.1 atlas-bindings-jackson-identities diff --git a/bindings/pom.xml b/bindings/pom.xml index 67351b47..023c0a4c 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.1-SNAPSHOT + 0.17.1 atlas-bindings-parent diff --git a/identities/pom.xml b/identities/pom.xml index 95250076..6c6ff076 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.1-SNAPSHOT + 0.17.1 atlas-identities diff --git a/pom.xml b/pom.xml index 033d73bc..28bc4154 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.1-SNAPSHOT + 0.17.1 pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - HEAD + atlas-parent-0.17.1 @@ -48,17 +48,17 @@ org.commonjava.maven.atlas atlas-identities - 0.17.1-SNAPSHOT + 0.17.1 org.commonjava.maven.atlas atlas-relationships-api - 0.17.1-SNAPSHOT + 0.17.1 org.commonjava.maven.atlas atlas-bindings-jackson-identities - 0.17.1-SNAPSHOT + 0.17.1 org.commonjava.maven.atlas diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 316a3f19..9d9ffb05 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.1-SNAPSHOT + 0.17.1 atlas-relationships-api From f7e9d1d4f00831bcaf37bd32b23c18be9f172b85 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 18 Apr 2017 14:04:23 -0500 Subject: [PATCH 151/240] [maven-release-plugin] prepare for next development iteration --- bindings/jackson-identities/pom.xml | 2 +- bindings/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 7de2c9df..4f6d3a35 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.17.1 + 0.17.2-SNAPSHOT atlas-bindings-jackson-identities diff --git a/bindings/pom.xml b/bindings/pom.xml index 023c0a4c..0857b5fb 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.1 + 0.17.2-SNAPSHOT atlas-bindings-parent diff --git a/identities/pom.xml b/identities/pom.xml index 6c6ff076..ee9a6edc 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.1 + 0.17.2-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index 28bc4154..f0744796 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.1 + 0.17.2-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - atlas-parent-0.17.1 + HEAD @@ -48,17 +48,17 @@ org.commonjava.maven.atlas atlas-identities - 0.17.1 + 0.17.2-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.17.1 + 0.17.2-SNAPSHOT org.commonjava.maven.atlas atlas-bindings-jackson-identities - 0.17.1 + 0.17.2-SNAPSHOT org.commonjava.maven.atlas diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 9d9ffb05..2ac48e11 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.1 + 0.17.2-SNAPSHOT atlas-relationships-api From 4eff12a00fc1886474350f22f1d2de22e46ab220 Mon Sep 17 00:00:00 2001 From: yma Date: Mon, 5 Jun 2017 16:44:48 +0800 Subject: [PATCH 152/240] add isValidSingleVersion method and tests for further version string validity check --- .../maven/atlas/ident/util/VersionUtils.java | 22 +++++++++++++++++++ .../atlas/ident/version/VersionUtilsTest.java | 15 ++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionUtils.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionUtils.java index 7efee472..2c4ff3f7 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionUtils.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionUtils.java @@ -108,4 +108,26 @@ public static SingleVersion createSingleVersion( final String version ) } } + public static boolean isValidSingleVersion( final String version ) + { + boolean result = true; + if ( version == null || version.trim().length() < 1 ) + { + result = false; + } + try + { + SingleVersion singleVersion = new VersionParser( version ).single(); + } + catch ( final ParseException e ) + { + result = false; + } + catch ( final TokenMgrError e ) + { + result = false; + } + return result; + } + } diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionUtilsTest.java b/identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionUtilsTest.java index 2c9cb931..c867ac10 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionUtilsTest.java +++ b/identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionUtilsTest.java @@ -16,9 +16,11 @@ package org.commonjava.maven.atlas.ident.version; import org.commonjava.maven.atlas.ident.util.VersionUtils; -import org.commonjava.maven.atlas.ident.version.SingleVersion; import org.junit.Test; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + public class VersionUtilsTest { @@ -32,4 +34,15 @@ public void createSingleTimestampVersionFormat() System.out.println( version ); } + @Test + public void SingleVersionStringValidationTest() throws Exception + { + final String invalid1 = "abc@1"; + final String invalid2 = "abc//1"; + final String valid = "abc123a."; + + assertThat( VersionUtils.isValidSingleVersion( invalid1 ), equalTo( false ) ); + assertThat( VersionUtils.isValidSingleVersion( invalid2 ), equalTo( false ) ); + assertThat( VersionUtils.isValidSingleVersion( valid ), equalTo( true ) ); + } } From 5dced04bed3d24aa83416337968440033d49d958 Mon Sep 17 00:00:00 2001 From: yma Date: Tue, 6 Jun 2017 08:40:40 +0800 Subject: [PATCH 153/240] return false tweak for the VersionUtils isValidSingleVersion --- .../org/commonjava/maven/atlas/ident/util/VersionUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionUtils.java b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionUtils.java index 2c4ff3f7..24ad566e 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionUtils.java +++ b/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionUtils.java @@ -111,9 +111,10 @@ public static SingleVersion createSingleVersion( final String version ) public static boolean isValidSingleVersion( final String version ) { boolean result = true; + if ( version == null || version.trim().length() < 1 ) { - result = false; + return false; } try { From 95e1cf49ccc1b1949bf3fcad8578da14a9a5d364 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 12 Sep 2017 13:52:43 -0500 Subject: [PATCH 154/240] [maven-release-plugin] prepare release atlas-parent-0.17.2 --- bindings/jackson-identities/pom.xml | 2 +- bindings/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 4f6d3a35..8ac37167 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.17.2-SNAPSHOT + 0.17.2 atlas-bindings-jackson-identities diff --git a/bindings/pom.xml b/bindings/pom.xml index 0857b5fb..11078407 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.2-SNAPSHOT + 0.17.2 atlas-bindings-parent diff --git a/identities/pom.xml b/identities/pom.xml index ee9a6edc..6de53e31 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.2-SNAPSHOT + 0.17.2 atlas-identities diff --git a/pom.xml b/pom.xml index f0744796..8dfe7c34 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.2-SNAPSHOT + 0.17.2 pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - HEAD + atlas-parent-0.17.2 @@ -48,17 +48,17 @@ org.commonjava.maven.atlas atlas-identities - 0.17.2-SNAPSHOT + 0.17.2 org.commonjava.maven.atlas atlas-relationships-api - 0.17.2-SNAPSHOT + 0.17.2 org.commonjava.maven.atlas atlas-bindings-jackson-identities - 0.17.2-SNAPSHOT + 0.17.2 org.commonjava.maven.atlas diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 2ac48e11..4e28d883 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.2-SNAPSHOT + 0.17.2 atlas-relationships-api From 783c107ddd81dbbda6be6ebd5d3f5d46c410d2e0 Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 12 Sep 2017 13:52:50 -0500 Subject: [PATCH 155/240] [maven-release-plugin] prepare for next development iteration --- bindings/jackson-identities/pom.xml | 2 +- bindings/pom.xml | 2 +- identities/pom.xml | 2 +- pom.xml | 10 +++++----- relationships-api/pom.xml | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 8ac37167..555f5cd6 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-bindings-parent - 0.17.2 + 0.17.3-SNAPSHOT atlas-bindings-jackson-identities diff --git a/bindings/pom.xml b/bindings/pom.xml index 11078407..d2ed1fa3 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.2 + 0.17.3-SNAPSHOT atlas-bindings-parent diff --git a/identities/pom.xml b/identities/pom.xml index 6de53e31..d05bdad0 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.2 + 0.17.3-SNAPSHOT atlas-identities diff --git a/pom.xml b/pom.xml index 8dfe7c34..49662d91 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.2 + 0.17.3-SNAPSHOT pom Atlas :: Maven Project-Graph :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - atlas-parent-0.17.2 + HEAD @@ -48,17 +48,17 @@ org.commonjava.maven.atlas atlas-identities - 0.17.2 + 0.17.3-SNAPSHOT org.commonjava.maven.atlas atlas-relationships-api - 0.17.2 + 0.17.3-SNAPSHOT org.commonjava.maven.atlas atlas-bindings-jackson-identities - 0.17.2 + 0.17.3-SNAPSHOT org.commonjava.maven.atlas diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 4e28d883..7867e6a3 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.maven.atlas atlas-parent - 0.17.2 + 0.17.3-SNAPSHOT atlas-relationships-api From 54aa8d4d744c5329c9d0d2d8525b224fb3cf7fd2 Mon Sep 17 00:00:00 2001 From: Rui Han Date: Tue, 16 Oct 2018 14:48:20 +0800 Subject: [PATCH 156/240] Rename groupId and package name to org.commonjava.atlas --- bindings/jackson-identities/pom.xml | 2 +- .../ident/jackson/ProjectRefDeserializer.java | 4 +- .../jackson/ProjectRefKeyDeserializer.java | 4 +- .../ident/jackson/ProjectRefSerializer.java | 4 +- .../ProjectVersionRefSerializerModule.java | 11 +++- .../jackson/SerializerIdentityUtils.java | 11 +++- ...ProjectVersionRefSerializerModuleTest.java | 6 +- bindings/pom.xml | 4 +- identities/pom.xml | 2 +- .../maven}/ident/DependencyScope.java | 2 +- .../maven}/ident/ScopeTransitivity.java | 8 +-- .../maven}/ident/ref/ArtifactRef.java | 2 +- .../maven}/ident/ref/InvalidRefException.java | 2 +- .../maven}/ident/ref/ProjectRef.java | 2 +- .../maven}/ident/ref/ProjectVersionRef.java | 6 +- .../maven}/ident/ref/SimpleArtifactRef.java | 8 +-- .../maven}/ident/ref/SimpleProjectRef.java | 2 +- .../ident/ref/SimpleProjectVersionRef.java | 10 ++-- .../ident/ref/SimpleTypeAndClassifier.java | 2 +- .../ref/SimpleVersionlessArtifactRef.java | 4 +- .../maven}/ident/ref/TypeAndClassifier.java | 2 +- .../maven}/ident/ref/VersionedRef.java | 6 +- .../ident/ref/VersionlessArtifactRef.java | 2 +- .../maven}/ident/util/ArtifactPathInfo.java | 12 ++-- .../ident/util/ArtifactRefComparator.java | 5 +- .../maven}/ident/util/IdentityUtils.java | 11 +++- .../maven}/ident/util/JoinString.java | 2 +- .../util/ProjectVersionRefComparator.java | 7 +-- .../maven}/ident/util/SnapshotUtils.java | 4 +- .../maven}/ident/util/VersionUtils.java | 16 +++--- .../VersionlessArtifactRefComparator.java | 4 +- .../ident/version/CompoundVersionSpec.java | 2 +- .../InvalidVersionSpecificationException.java | 2 +- .../ident/version/MultiVersionSpec.java | 2 +- .../ident/version/RangeVersionSpec.java | 2 +- .../maven}/ident/version/SingleVersion.java | 16 +++--- .../maven}/ident/version/VersionSpec.java | 2 +- .../ident/version/VersionSpecComparisons.java | 10 ++-- .../ident/version/part/NumericPart.java | 2 +- .../ident/version/part/SeparatorPart.java | 2 +- .../ident/version/part/SnapshotPart.java | 4 +- .../maven}/ident/version/part/StringPart.java | 2 +- .../ident/version/part/VersionPart.java | 2 +- .../version/part/VersionPartSeparator.java | 2 +- .../ident/version/part/VersionPhrase.java | 6 +- identities/src/main/javacc/version.jj | 8 +-- .../maven}/ident/ref/ProjectRefTest.java | 4 +- .../ident/ref/ProjectVersionRefTest.java | 10 ++-- .../ident/ref/SimpleArtifactRefTest.java | 5 +- .../ident/ref/VersionlessArtifactRefTest.java | 8 ++- .../ident/util/ArtifactPathInfoTest.java | 3 +- .../maven}/ident/util/SnapshotUtilsTest.java | 3 +- .../version/SingleVersionComparisonsTest.java | 4 +- .../ident/version/VersionParserTest.java | 6 +- .../ident/version/VersionRangeTest.java | 6 +- .../ident/version/VersionUtilsTest.java | 4 +- .../ident/version/part/NumericPartTest.java | 6 +- .../ident/version/part/SnapshotPartTest.java | 4 +- pom.xml | 12 ++-- relationships-api/pom.xml | 6 +- .../graph/jackson/PluginKeyDeserializer.java | 4 +- .../graph/jackson/PluginKeySerializer.java | 4 +- .../ProjectRelationshipDeserializer.java | 57 +++++++++++-------- .../ProjectRelationshipSerializer.java | 42 +++++++------- .../ProjectRelationshipSerializerModule.java | 18 +++++- .../graph/jackson/SerializationConstants.java | 4 +- .../maven}/graph/model/EProjectCycle.java | 10 ++-- .../model/EProjectDirectRelationships.java | 36 ++++++------ .../model/EProjectRelationshipCollection.java | 4 +- .../maven}/graph/model/PluginKey.java | 6 +- .../AbstractSimpleProjectRelationship.java | 18 +++--- .../maven}/graph/rel/BomRelationship.java | 6 +- .../graph/rel/DependencyRelationship.java | 10 ++-- .../graph/rel/ExtensionRelationship.java | 6 +- .../maven}/graph/rel/ParentRelationship.java | 7 +-- .../rel/PluginDependencyRelationship.java | 8 +-- .../maven}/graph/rel/PluginRelationship.java | 6 +- .../maven}/graph/rel/ProjectRelationship.java | 9 +-- .../graph/rel/RelationshipComparator.java | 12 ++-- .../graph/rel/RelationshipConstants.java | 2 +- .../graph/rel/RelationshipPathComparator.java | 2 +- .../maven}/graph/rel/RelationshipType.java | 2 +- .../graph/rel/SimpleBomRelationship.java | 8 +-- .../rel/SimpleDependencyRelationship.java | 12 ++-- .../rel/SimpleExtensionRelationship.java | 10 ++-- .../graph/rel/SimpleParentRelationship.java | 10 ++-- .../SimplePluginDependencyRelationship.java | 12 ++-- .../graph/rel/SimplePluginRelationship.java | 10 ++-- .../maven}/graph/util/RelationshipUtils.java | 20 ++++--- .../EProjectRelationshipsSerializerTest.java | 33 +++++------ ...ojectRelationshipSerializerModuleTest.java | 22 ++++--- .../graph/rel/ParentRelationshipTest.java | 12 ++-- .../graph/rel/RelationshipComparatorTest.java | 12 ++-- .../rel/RelationshipPathComparatorTest.java | 13 +++-- 94 files changed, 409 insertions(+), 350 deletions(-) rename bindings/jackson-identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/jackson/ProjectRefDeserializer.java (93%) rename bindings/jackson-identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/jackson/ProjectRefKeyDeserializer.java (92%) rename bindings/jackson-identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/jackson/ProjectRefSerializer.java (93%) rename bindings/jackson-identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/jackson/ProjectVersionRefSerializerModule.java (82%) rename bindings/jackson-identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/jackson/SerializerIdentityUtils.java (81%) rename bindings/jackson-identities/src/test/java/org/commonjava/{maven/atlas => atlas/maven}/ident/jackson/ProjectVersionRefSerializerModuleTest.java (92%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/DependencyScope.java (98%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/ScopeTransitivity.java (85%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/ref/ArtifactRef.java (95%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/ref/InvalidRefException.java (97%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/ref/ProjectRef.java (96%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/ref/ProjectVersionRef.java (92%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/ref/SimpleArtifactRef.java (96%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/ref/SimpleProjectRef.java (99%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/ref/SimpleProjectVersionRef.java (97%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/ref/SimpleTypeAndClassifier.java (98%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/ref/SimpleVersionlessArtifactRef.java (98%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/ref/TypeAndClassifier.java (94%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/ref/VersionedRef.java (87%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/ref/VersionlessArtifactRef.java (96%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/util/ArtifactPathInfo.java (95%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/util/ArtifactRefComparator.java (91%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/util/IdentityUtils.java (87%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/util/JoinString.java (96%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/util/ProjectVersionRefComparator.java (82%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/util/SnapshotUtils.java (97%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/util/VersionUtils.java (89%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/util/VersionlessArtifactRefComparator.java (93%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/CompoundVersionSpec.java (99%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/InvalidVersionSpecificationException.java (97%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/MultiVersionSpec.java (94%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/RangeVersionSpec.java (99%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/SingleVersion.java (96%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/VersionSpec.java (97%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/VersionSpecComparisons.java (97%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/part/NumericPart.java (98%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/part/SeparatorPart.java (97%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/part/SnapshotPart.java (97%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/part/StringPart.java (99%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/part/VersionPart.java (95%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/part/VersionPartSeparator.java (95%) rename identities/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/part/VersionPhrase.java (98%) rename identities/src/test/java/org/commonjava/{maven/atlas => atlas/maven}/ident/ref/ProjectRefTest.java (93%) rename identities/src/test/java/org/commonjava/{maven/atlas => atlas/maven}/ident/ref/ProjectVersionRefTest.java (92%) rename identities/src/test/java/org/commonjava/{maven/atlas => atlas/maven}/ident/ref/SimpleArtifactRefTest.java (92%) rename identities/src/test/java/org/commonjava/{maven/atlas => atlas/maven}/ident/ref/VersionlessArtifactRefTest.java (94%) rename identities/src/test/java/org/commonjava/{maven/atlas => atlas/maven}/ident/util/ArtifactPathInfoTest.java (93%) rename identities/src/test/java/org/commonjava/{maven/atlas => atlas/maven}/ident/util/SnapshotUtilsTest.java (95%) rename identities/src/test/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/SingleVersionComparisonsTest.java (99%) rename identities/src/test/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/VersionParserTest.java (92%) rename identities/src/test/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/VersionRangeTest.java (83%) rename identities/src/test/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/VersionUtilsTest.java (93%) rename identities/src/test/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/part/NumericPartTest.java (84%) rename identities/src/test/java/org/commonjava/{maven/atlas => atlas/maven}/ident/version/part/SnapshotPartTest.java (93%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/jackson/PluginKeyDeserializer.java (92%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/jackson/PluginKeySerializer.java (92%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/jackson/ProjectRelationshipDeserializer.java (76%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/jackson/ProjectRelationshipSerializer.java (58%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/jackson/ProjectRelationshipSerializerModule.java (73%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/jackson/SerializationConstants.java (95%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/model/EProjectCycle.java (96%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/model/EProjectDirectRelationships.java (93%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/model/EProjectRelationshipCollection.java (89%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/model/PluginKey.java (95%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/AbstractSimpleProjectRelationship.java (91%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/BomRelationship.java (86%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/DependencyRelationship.java (82%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/ExtensionRelationship.java (87%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/ParentRelationship.java (85%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/PluginDependencyRelationship.java (84%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/PluginRelationship.java (87%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/ProjectRelationship.java (79%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/RelationshipComparator.java (77%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/RelationshipConstants.java (97%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/RelationshipPathComparator.java (98%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/RelationshipType.java (97%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/SimpleBomRelationship.java (95%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/SimpleDependencyRelationship.java (95%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/SimpleExtensionRelationship.java (93%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/SimpleParentRelationship.java (93%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/SimplePluginDependencyRelationship.java (95%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/SimplePluginRelationship.java (95%) rename relationships-api/src/main/java/org/commonjava/{maven/atlas => atlas/maven}/graph/util/RelationshipUtils.java (91%) rename relationships-api/src/test/java/org/commonjava/{maven/atlas => atlas/maven}/graph/jackson/EProjectRelationshipsSerializerTest.java (81%) rename relationships-api/src/test/java/org/commonjava/{maven/atlas => atlas/maven}/graph/jackson/ProjectRelationshipSerializerModuleTest.java (73%) rename relationships-api/src/test/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/ParentRelationshipTest.java (83%) rename relationships-api/src/test/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/RelationshipComparatorTest.java (85%) rename relationships-api/src/test/java/org/commonjava/{maven/atlas => atlas/maven}/graph/rel/RelationshipPathComparatorTest.java (84%) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 555f5cd6..f7506a30 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -20,7 +20,7 @@ 4.0.0 - org.commonjava.maven.atlas + org.commonjava.atlas atlas-bindings-parent 0.17.3-SNAPSHOT diff --git a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefDeserializer.java b/bindings/jackson-identities/src/main/java/org/commonjava/atlas/maven/ident/jackson/ProjectRefDeserializer.java similarity index 93% rename from bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefDeserializer.java rename to bindings/jackson-identities/src/main/java/org/commonjava/atlas/maven/ident/jackson/ProjectRefDeserializer.java index 0cb5d4f9..28d962e9 100644 --- a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefDeserializer.java +++ b/bindings/jackson-identities/src/main/java/org/commonjava/atlas/maven/ident/jackson/ProjectRefDeserializer.java @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.jackson; +package org.commonjava.atlas.maven.ident.jackson; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.atlas.maven.ident.ref.ProjectRef; import java.io.IOException; diff --git a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefKeyDeserializer.java b/bindings/jackson-identities/src/main/java/org/commonjava/atlas/maven/ident/jackson/ProjectRefKeyDeserializer.java similarity index 92% rename from bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefKeyDeserializer.java rename to bindings/jackson-identities/src/main/java/org/commonjava/atlas/maven/ident/jackson/ProjectRefKeyDeserializer.java index 7555a815..31517ea4 100644 --- a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefKeyDeserializer.java +++ b/bindings/jackson-identities/src/main/java/org/commonjava/atlas/maven/ident/jackson/ProjectRefKeyDeserializer.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.jackson; +package org.commonjava.atlas.maven.ident.jackson; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.KeyDeserializer; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.atlas.maven.ident.ref.ProjectRef; import java.io.IOException; diff --git a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefSerializer.java b/bindings/jackson-identities/src/main/java/org/commonjava/atlas/maven/ident/jackson/ProjectRefSerializer.java similarity index 93% rename from bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefSerializer.java rename to bindings/jackson-identities/src/main/java/org/commonjava/atlas/maven/ident/jackson/ProjectRefSerializer.java index 5be3902b..5b385986 100644 --- a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectRefSerializer.java +++ b/bindings/jackson-identities/src/main/java/org/commonjava/atlas/maven/ident/jackson/ProjectRefSerializer.java @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.jackson; +package org.commonjava.atlas.maven.ident.jackson; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdSerializer; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; +import org.commonjava.atlas.maven.ident.ref.ProjectRef; import java.io.IOException; diff --git a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java b/bindings/jackson-identities/src/main/java/org/commonjava/atlas/maven/ident/jackson/ProjectVersionRefSerializerModule.java similarity index 82% rename from bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java rename to bindings/jackson-identities/src/main/java/org/commonjava/atlas/maven/ident/jackson/ProjectVersionRefSerializerModule.java index 8c384a06..d6931c51 100644 --- a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModule.java +++ b/bindings/jackson-identities/src/main/java/org/commonjava/atlas/maven/ident/jackson/ProjectVersionRefSerializerModule.java @@ -13,14 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.jackson; +package org.commonjava.atlas.maven.ident.jackson; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Set; -import org.commonjava.maven.atlas.ident.ref.*; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.SimpleArtifactRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.SimpleVersionlessArtifactRef; +import org.commonjava.atlas.maven.ident.ref.VersionlessArtifactRef; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/SerializerIdentityUtils.java b/bindings/jackson-identities/src/main/java/org/commonjava/atlas/maven/ident/jackson/SerializerIdentityUtils.java similarity index 81% rename from bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/SerializerIdentityUtils.java rename to bindings/jackson-identities/src/main/java/org/commonjava/atlas/maven/ident/jackson/SerializerIdentityUtils.java index dde549b3..78075864 100644 --- a/bindings/jackson-identities/src/main/java/org/commonjava/maven/atlas/ident/jackson/SerializerIdentityUtils.java +++ b/bindings/jackson-identities/src/main/java/org/commonjava/atlas/maven/ident/jackson/SerializerIdentityUtils.java @@ -13,9 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.jackson; +package org.commonjava.atlas.maven.ident.jackson; -import org.commonjava.maven.atlas.ident.ref.*; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.SimpleArtifactRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.SimpleVersionlessArtifactRef; +import org.commonjava.atlas.maven.ident.ref.VersionlessArtifactRef; import java.io.IOException; import java.lang.reflect.InvocationTargetException; diff --git a/bindings/jackson-identities/src/test/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModuleTest.java b/bindings/jackson-identities/src/test/java/org/commonjava/atlas/maven/ident/jackson/ProjectVersionRefSerializerModuleTest.java similarity index 92% rename from bindings/jackson-identities/src/test/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModuleTest.java rename to bindings/jackson-identities/src/test/java/org/commonjava/atlas/maven/ident/jackson/ProjectVersionRefSerializerModuleTest.java index 6ff3d8a6..52eae7f5 100644 --- a/bindings/jackson-identities/src/test/java/org/commonjava/maven/atlas/ident/jackson/ProjectVersionRefSerializerModuleTest.java +++ b/bindings/jackson-identities/src/test/java/org/commonjava/atlas/maven/ident/jackson/ProjectVersionRefSerializerModuleTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.jackson; +package org.commonjava.atlas.maven.ident.jackson; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; @@ -21,8 +21,8 @@ import java.util.HashMap; import java.util.Map; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; +import org.commonjava.atlas.maven.ident.ref.ProjectRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectRef; import org.junit.Before; import org.junit.Test; diff --git a/bindings/pom.xml b/bindings/pom.xml index d2ed1fa3..282eeb7f 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -20,7 +20,7 @@ 4.0.0 - org.commonjava.maven.atlas + org.commonjava.atlas atlas-parent 0.17.3-SNAPSHOT @@ -32,7 +32,7 @@ - org.commonjava.maven.atlas + org.commonjava.atlas atlas-identities diff --git a/identities/pom.xml b/identities/pom.xml index d05bdad0..773cc0d4 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -20,7 +20,7 @@ 4.0.0 - org.commonjava.maven.atlas + org.commonjava.atlas atlas-parent 0.17.3-SNAPSHOT diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/DependencyScope.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/DependencyScope.java similarity index 98% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/DependencyScope.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/DependencyScope.java index b6ac945c..c7fc8a97 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/DependencyScope.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/DependencyScope.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident; +package org.commonjava.atlas.maven.ident; import java.util.ArrayList; import java.util.Arrays; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ScopeTransitivity.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/ScopeTransitivity.java similarity index 85% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/ScopeTransitivity.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/ScopeTransitivity.java index f302fd9b..5d08a03f 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ScopeTransitivity.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/ScopeTransitivity.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident; +package org.commonjava.atlas.maven.ident; -import static org.commonjava.maven.atlas.ident.DependencyScope.embedded; -import static org.commonjava.maven.atlas.ident.DependencyScope.runtime; -import static org.commonjava.maven.atlas.ident.DependencyScope.toolchain; +import static org.commonjava.atlas.maven.ident.DependencyScope.embedded; +import static org.commonjava.atlas.maven.ident.DependencyScope.runtime; +import static org.commonjava.atlas.maven.ident.DependencyScope.toolchain; public enum ScopeTransitivity { diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/ArtifactRef.java similarity index 95% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/ref/ArtifactRef.java index 21f8086e..515b376d 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ArtifactRef.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/ArtifactRef.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.ref; +package org.commonjava.atlas.maven.ident.ref; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/InvalidRefException.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/InvalidRefException.java similarity index 97% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/ref/InvalidRefException.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/ref/InvalidRefException.java index 427350aa..d51e9426 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/InvalidRefException.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/InvalidRefException.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.ref; +package org.commonjava.atlas.maven.ident.ref; import java.util.IllegalFormatException; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/ProjectRef.java similarity index 96% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/ref/ProjectRef.java index 9e0ea881..9102246f 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectRef.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/ProjectRef.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.ref; +package org.commonjava.atlas.maven.ident.ref; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/ProjectVersionRef.java similarity index 92% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/ref/ProjectVersionRef.java index 7f5c6014..53f1163a 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRef.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/ProjectVersionRef.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.ref; +package org.commonjava.atlas.maven.ident.ref; -import org.commonjava.maven.atlas.ident.version.SingleVersion; -import org.commonjava.maven.atlas.ident.version.VersionSpec; +import org.commonjava.atlas.maven.ident.version.SingleVersion; +import org.commonjava.atlas.maven.ident.version.VersionSpec; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRef.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleArtifactRef.java similarity index 96% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRef.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleArtifactRef.java index 49356aef..f5f7e3df 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRef.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleArtifactRef.java @@ -13,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.ref; +package org.commonjava.atlas.maven.ident.ref; import static org.apache.commons.lang.StringUtils.isEmpty; import java.io.Serializable; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; -import org.commonjava.maven.atlas.ident.version.SingleVersion; -import org.commonjava.maven.atlas.ident.version.VersionSpec; +import org.commonjava.atlas.maven.ident.version.InvalidVersionSpecificationException; +import org.commonjava.atlas.maven.ident.version.SingleVersion; +import org.commonjava.atlas.maven.ident.version.VersionSpec; /** * Represents an artifact, in Maven parlance. A tangible result of a build, which is typically made available in a Maven repository for others diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectRef.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleProjectRef.java similarity index 99% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectRef.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleProjectRef.java index 666673c2..b6f7a99e 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectRef.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleProjectRef.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.ref; +package org.commonjava.atlas.maven.ident.ref; import static org.apache.commons.lang.StringUtils.isEmpty; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleProjectVersionRef.java similarity index 97% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleProjectVersionRef.java index 3d7379c7..7ff6a5ad 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleProjectVersionRef.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleProjectVersionRef.java @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.ref; +package org.commonjava.atlas.maven.ident.ref; import org.apache.commons.lang.StringUtils; -import org.commonjava.maven.atlas.ident.util.VersionUtils; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; -import org.commonjava.maven.atlas.ident.version.SingleVersion; -import org.commonjava.maven.atlas.ident.version.VersionSpec; +import org.commonjava.atlas.maven.ident.util.VersionUtils; +import org.commonjava.atlas.maven.ident.version.InvalidVersionSpecificationException; +import org.commonjava.atlas.maven.ident.version.SingleVersion; +import org.commonjava.atlas.maven.ident.version.VersionSpec; import static org.apache.commons.lang.StringUtils.isEmpty; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleTypeAndClassifier.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleTypeAndClassifier.java similarity index 98% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleTypeAndClassifier.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleTypeAndClassifier.java index 3db0756b..975ff535 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleTypeAndClassifier.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleTypeAndClassifier.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.ref; +package org.commonjava.atlas.maven.ident.ref; import static org.apache.commons.lang.StringUtils.isEmpty; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleVersionlessArtifactRef.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleVersionlessArtifactRef.java similarity index 98% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleVersionlessArtifactRef.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleVersionlessArtifactRef.java index 6999a3b6..84c8fb20 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/SimpleVersionlessArtifactRef.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleVersionlessArtifactRef.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.ref; +package org.commonjava.atlas.maven.ident.ref; import static org.apache.commons.lang.StringUtils.isEmpty; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; +import org.commonjava.atlas.maven.ident.version.InvalidVersionSpecificationException; /** * Special implementation of {@link SimpleArtifactRef} that forces all versions to ZERO, to allow calculation of transitive diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/TypeAndClassifier.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/TypeAndClassifier.java similarity index 94% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/ref/TypeAndClassifier.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/ref/TypeAndClassifier.java index 1f2a9700..4b2a87bf 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/TypeAndClassifier.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/TypeAndClassifier.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.ref; +package org.commonjava.atlas.maven.ident.ref; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionedRef.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/VersionedRef.java similarity index 87% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionedRef.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/ref/VersionedRef.java index d05819ad..892e24ed 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionedRef.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/VersionedRef.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.ref; +package org.commonjava.atlas.maven.ident.ref; import java.io.Serializable; -import org.commonjava.maven.atlas.ident.version.SingleVersion; -import org.commonjava.maven.atlas.ident.version.VersionSpec; +import org.commonjava.atlas.maven.ident.version.SingleVersion; +import org.commonjava.atlas.maven.ident.version.VersionSpec; public interface VersionedRef extends Serializable diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/VersionlessArtifactRef.java similarity index 96% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/ref/VersionlessArtifactRef.java index 56556c91..f4b5f83b 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRef.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/VersionlessArtifactRef.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.ref; +package org.commonjava.atlas.maven.ident.ref; /** * Created by jdcasey on 8/21/15. diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java similarity index 95% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java index 3dc69e6a..b804711c 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfo.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.util; +package org.commonjava.atlas.maven.ident.util; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.ident.version.part.SnapshotPart; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.SimpleArtifactRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef; +import org.commonjava.atlas.maven.ident.version.part.SnapshotPart; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactRefComparator.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactRefComparator.java similarity index 91% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactRefComparator.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactRefComparator.java index 1b814046..9c65d208 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ArtifactRefComparator.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactRefComparator.java @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.util; +package org.commonjava.atlas.maven.ident.util; import java.util.Comparator; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; public class ArtifactRefComparator implements Comparator diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/IdentityUtils.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/IdentityUtils.java similarity index 87% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/util/IdentityUtils.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/util/IdentityUtils.java index fd637587..258cd1c8 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/IdentityUtils.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/IdentityUtils.java @@ -13,10 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.util; +package org.commonjava.atlas.maven.ident.util; -import org.commonjava.maven.atlas.ident.ref.*; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.SimpleArtifactRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef; +import org.commonjava.atlas.maven.ident.version.InvalidVersionSpecificationException; public final class IdentityUtils { diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/JoinString.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/JoinString.java similarity index 96% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/util/JoinString.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/util/JoinString.java index a2054319..bdc3d7ac 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/JoinString.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/JoinString.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.util; +package org.commonjava.atlas.maven.ident.util; import static org.apache.commons.lang.StringUtils.join; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ProjectVersionRefComparator.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ProjectVersionRefComparator.java similarity index 82% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/util/ProjectVersionRefComparator.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/util/ProjectVersionRefComparator.java index fe969931..c0f9c2f0 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/ProjectVersionRefComparator.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ProjectVersionRefComparator.java @@ -13,13 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.util; +package org.commonjava.atlas.maven.ident.util; import java.util.Comparator; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.ident.version.VersionSpec; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.version.VersionSpec; public class ProjectVersionRefComparator implements Comparator diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/SnapshotUtils.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/SnapshotUtils.java similarity index 97% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/util/SnapshotUtils.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/util/SnapshotUtils.java index e615fcc6..f75a0091 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/SnapshotUtils.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/SnapshotUtils.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.util; +package org.commonjava.atlas.maven.ident.util; import java.text.DateFormat; import java.text.ParseException; @@ -24,7 +24,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.commonjava.maven.atlas.ident.version.part.SnapshotPart; +import org.commonjava.atlas.maven.ident.version.part.SnapshotPart; public class SnapshotUtils { diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionUtils.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/VersionUtils.java similarity index 89% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionUtils.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/util/VersionUtils.java index 24ad566e..677cd5f7 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionUtils.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/VersionUtils.java @@ -13,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.util; +package org.commonjava.atlas.maven.ident.util; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; -import org.commonjava.maven.atlas.ident.version.RangeVersionSpec; -import org.commonjava.maven.atlas.ident.version.SingleVersion; -import org.commonjava.maven.atlas.ident.version.VersionSpec; -import org.commonjava.maven.atlas.ident.version.parse.ParseException; -import org.commonjava.maven.atlas.ident.version.parse.TokenMgrError; -import org.commonjava.maven.atlas.ident.version.parse.VersionParser; +import org.commonjava.atlas.maven.ident.version.InvalidVersionSpecificationException; +import org.commonjava.atlas.maven.ident.version.RangeVersionSpec; +import org.commonjava.atlas.maven.ident.version.SingleVersion; +import org.commonjava.atlas.maven.ident.version.VersionSpec; +import org.commonjava.atlas.maven.ident.version.parse.ParseException; +import org.commonjava.atlas.maven.ident.version.parse.TokenMgrError; +import org.commonjava.atlas.maven.ident.version.parse.VersionParser; public final class VersionUtils { diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionlessArtifactRefComparator.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/VersionlessArtifactRefComparator.java similarity index 93% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionlessArtifactRefComparator.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/util/VersionlessArtifactRefComparator.java index dfbe1df4..60718202 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/util/VersionlessArtifactRefComparator.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/VersionlessArtifactRefComparator.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.util; +package org.commonjava.atlas.maven.ident.util; -import org.commonjava.maven.atlas.ident.ref.VersionlessArtifactRef; +import org.commonjava.atlas.maven.ident.ref.VersionlessArtifactRef; import java.util.Comparator; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/CompoundVersionSpec.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/CompoundVersionSpec.java similarity index 99% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/version/CompoundVersionSpec.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/version/CompoundVersionSpec.java index 87eb7b67..da23e63a 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/CompoundVersionSpec.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/CompoundVersionSpec.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version; +package org.commonjava.atlas.maven.ident.version; import java.io.Serializable; import java.util.ArrayList; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/InvalidVersionSpecificationException.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/InvalidVersionSpecificationException.java similarity index 97% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/version/InvalidVersionSpecificationException.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/version/InvalidVersionSpecificationException.java index 7f1baf33..6de84ba5 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/InvalidVersionSpecificationException.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/InvalidVersionSpecificationException.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version; +package org.commonjava.atlas.maven.ident.version; import java.util.IllegalFormatException; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/MultiVersionSpec.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/MultiVersionSpec.java similarity index 94% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/version/MultiVersionSpec.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/version/MultiVersionSpec.java index bcc8842e..3b511a6e 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/MultiVersionSpec.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/MultiVersionSpec.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version; +package org.commonjava.atlas.maven.ident.version; public interface MultiVersionSpec { diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/RangeVersionSpec.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/RangeVersionSpec.java similarity index 99% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/version/RangeVersionSpec.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/version/RangeVersionSpec.java index 86767262..8b51be67 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/RangeVersionSpec.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/RangeVersionSpec.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version; +package org.commonjava.atlas.maven.ident.version; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/SingleVersion.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/SingleVersion.java similarity index 96% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/version/SingleVersion.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/version/SingleVersion.java index 35b80464..4c316c47 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/SingleVersion.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/SingleVersion.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version; +package org.commonjava.atlas.maven.ident.version; import static org.apache.commons.lang.StringUtils.join; @@ -23,13 +23,13 @@ import java.util.List; import java.util.StringTokenizer; -import org.commonjava.maven.atlas.ident.version.part.NumericPart; -import org.commonjava.maven.atlas.ident.version.part.SeparatorPart; -import org.commonjava.maven.atlas.ident.version.part.SnapshotPart; -import org.commonjava.maven.atlas.ident.version.part.StringPart; -import org.commonjava.maven.atlas.ident.version.part.VersionPart; -import org.commonjava.maven.atlas.ident.version.part.VersionPartSeparator; -import org.commonjava.maven.atlas.ident.version.part.VersionPhrase; +import org.commonjava.atlas.maven.ident.version.part.NumericPart; +import org.commonjava.atlas.maven.ident.version.part.SeparatorPart; +import org.commonjava.atlas.maven.ident.version.part.SnapshotPart; +import org.commonjava.atlas.maven.ident.version.part.StringPart; +import org.commonjava.atlas.maven.ident.version.part.VersionPart; +import org.commonjava.atlas.maven.ident.version.part.VersionPartSeparator; +import org.commonjava.atlas.maven.ident.version.part.VersionPhrase; public class SingleVersion implements VersionSpec, Serializable diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/VersionSpec.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/VersionSpec.java similarity index 97% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/version/VersionSpec.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/version/VersionSpec.java index 9989acfd..312db685 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/VersionSpec.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/VersionSpec.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version; +package org.commonjava.atlas.maven.ident.version; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/VersionSpecComparisons.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/VersionSpecComparisons.java similarity index 97% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/version/VersionSpecComparisons.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/version/VersionSpecComparisons.java index 91cc59f7..f400baff 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/VersionSpecComparisons.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/VersionSpecComparisons.java @@ -13,16 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version; +package org.commonjava.atlas.maven.ident.version; import java.util.ArrayList; import java.util.Comparator; import java.util.List; -import org.commonjava.maven.atlas.ident.version.part.NumericPart; -import org.commonjava.maven.atlas.ident.version.part.SeparatorPart; -import org.commonjava.maven.atlas.ident.version.part.VersionPart; -import org.commonjava.maven.atlas.ident.version.part.VersionPhrase; +import org.commonjava.atlas.maven.ident.version.part.NumericPart; +import org.commonjava.atlas.maven.ident.version.part.SeparatorPart; +import org.commonjava.atlas.maven.ident.version.part.VersionPart; +import org.commonjava.atlas.maven.ident.version.part.VersionPhrase; public final class VersionSpecComparisons { diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/NumericPart.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/NumericPart.java similarity index 98% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/NumericPart.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/NumericPart.java index a3fc65e6..a8db759a 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/NumericPart.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/NumericPart.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version.part; +package org.commonjava.atlas.maven.ident.version.part; import java.io.Serializable; import java.math.BigInteger; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SeparatorPart.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/SeparatorPart.java similarity index 97% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SeparatorPart.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/SeparatorPart.java index dccb1aa8..3dcc14d4 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SeparatorPart.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/SeparatorPart.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version.part; +package org.commonjava.atlas.maven.ident.version.part; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPart.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/SnapshotPart.java similarity index 97% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPart.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/SnapshotPart.java index 11f689da..ee3e7287 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPart.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/SnapshotPart.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version.part; +package org.commonjava.atlas.maven.ident.version.part; import java.io.Serializable; import java.util.Date; -import org.commonjava.maven.atlas.ident.util.SnapshotUtils; +import org.commonjava.atlas.maven.ident.util.SnapshotUtils; public class SnapshotPart extends VersionPart diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/StringPart.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/StringPart.java similarity index 99% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/StringPart.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/StringPart.java index 35006581..7deaf4f2 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/StringPart.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/StringPart.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version.part; +package org.commonjava.atlas.maven.ident.version.part; import java.io.Serializable; import java.util.ArrayList; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPart.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/VersionPart.java similarity index 95% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPart.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/VersionPart.java index 2951d75e..c30aab41 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPart.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/VersionPart.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version.part; +package org.commonjava.atlas.maven.ident.version.part; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPartSeparator.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/VersionPartSeparator.java similarity index 95% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPartSeparator.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/VersionPartSeparator.java index f13e1e68..88586788 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPartSeparator.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/VersionPartSeparator.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version.part; +package org.commonjava.atlas.maven.ident.version.part; public enum VersionPartSeparator { diff --git a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPhrase.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/VersionPhrase.java similarity index 98% rename from identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPhrase.java rename to identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/VersionPhrase.java index b677b415..c509c12e 100644 --- a/identities/src/main/java/org/commonjava/maven/atlas/ident/version/part/VersionPhrase.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/VersionPhrase.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version.part; +package org.commonjava.atlas.maven.ident.version.part; import java.io.Serializable; import java.util.ArrayList; @@ -21,8 +21,8 @@ import java.util.Iterator; import java.util.List; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; -import org.commonjava.maven.atlas.ident.version.VersionSpecComparisons; +import org.commonjava.atlas.maven.ident.version.InvalidVersionSpecificationException; +import org.commonjava.atlas.maven.ident.version.VersionSpecComparisons; public class VersionPhrase implements Comparable, Serializable diff --git a/identities/src/main/javacc/version.jj b/identities/src/main/javacc/version.jj index ea4c6fa9..a0ae0b14 100644 --- a/identities/src/main/javacc/version.jj +++ b/identities/src/main/javacc/version.jj @@ -8,11 +8,11 @@ options { } PARSER_BEGIN(VersionParser) -package org.commonjava.maven.atlas.ident.version.parse; +package org.commonjava.atlas.maven.ident.version.parse; -import org.commonjava.maven.atlas.ident.util.*; -import org.commonjava.maven.atlas.ident.version.*; -import org.commonjava.maven.atlas.ident.version.part.*; +import org.commonjava.atlas.maven.ident.util.*; +import org.commonjava.atlas.maven.ident.version.*; +import org.commonjava.atlas.maven.ident.version.part.*; import java.util.*; import java.text.*; import java.io.*; diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ProjectRefTest.java b/identities/src/test/java/org/commonjava/atlas/maven/ident/ref/ProjectRefTest.java similarity index 93% rename from identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ProjectRefTest.java rename to identities/src/test/java/org/commonjava/atlas/maven/ident/ref/ProjectRefTest.java index 2f5ac3c6..8b3f4c1b 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ProjectRefTest.java +++ b/identities/src/test/java/org/commonjava/atlas/maven/ident/ref/ProjectRefTest.java @@ -13,11 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.ref; +package org.commonjava.atlas.maven.ident.ref; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; +import org.commonjava.atlas.maven.ident.ref.ProjectRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectRef; import org.junit.Test; public class ProjectRefTest diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRefTest.java b/identities/src/test/java/org/commonjava/atlas/maven/ident/ref/ProjectVersionRefTest.java similarity index 92% rename from identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRefTest.java rename to identities/src/test/java/org/commonjava/atlas/maven/ident/ref/ProjectVersionRefTest.java index 45445e77..be399d2f 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/ProjectVersionRefTest.java +++ b/identities/src/test/java/org/commonjava/atlas/maven/ident/ref/ProjectVersionRefTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.ref; +package org.commonjava.atlas.maven.ident.ref; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; @@ -23,9 +23,11 @@ import java.util.List; import java.util.Set; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; -import org.commonjava.maven.atlas.ident.version.VersionSpec; -import org.commonjava.maven.atlas.ident.version.part.VersionPhrase; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef; +import org.commonjava.atlas.maven.ident.version.InvalidVersionSpecificationException; +import org.commonjava.atlas.maven.ident.version.VersionSpec; +import org.commonjava.atlas.maven.ident.version.part.VersionPhrase; import org.junit.Test; public class ProjectVersionRefTest diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRefTest.java b/identities/src/test/java/org/commonjava/atlas/maven/ident/ref/SimpleArtifactRefTest.java similarity index 92% rename from identities/src/test/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRefTest.java rename to identities/src/test/java/org/commonjava/atlas/maven/ident/ref/SimpleArtifactRefTest.java index a1b9bd5e..fb564121 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/SimpleArtifactRefTest.java +++ b/identities/src/test/java/org/commonjava/atlas/maven/ident/ref/SimpleArtifactRefTest.java @@ -13,12 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.ref; +package org.commonjava.atlas.maven.ident.ref; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.nullValue; import static org.junit.Assert.assertThat; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.InvalidRefException; +import org.commonjava.atlas.maven.ident.ref.SimpleArtifactRef; import org.junit.Test; public class SimpleArtifactRefTest diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRefTest.java b/identities/src/test/java/org/commonjava/atlas/maven/ident/ref/VersionlessArtifactRefTest.java similarity index 94% rename from identities/src/test/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRefTest.java rename to identities/src/test/java/org/commonjava/atlas/maven/ident/ref/VersionlessArtifactRefTest.java index 7566e10d..7aaa0cc4 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/ref/VersionlessArtifactRefTest.java +++ b/identities/src/test/java/org/commonjava/atlas/maven/ident/ref/VersionlessArtifactRefTest.java @@ -13,12 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.ref; +package org.commonjava.atlas.maven.ident.ref; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.nullValue; import static org.junit.Assert.assertThat; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.SimpleArtifactRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.SimpleVersionlessArtifactRef; +import org.commonjava.atlas.maven.ident.ref.VersionlessArtifactRef; import org.junit.Test; public class VersionlessArtifactRefTest diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfoTest.java b/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java similarity index 93% rename from identities/src/test/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfoTest.java rename to identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java index 75b4e989..a38450a5 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/util/ArtifactPathInfoTest.java +++ b/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.util; +package org.commonjava.atlas.maven.ident.util; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; +import org.commonjava.atlas.maven.ident.util.ArtifactPathInfo; import org.junit.Test; public class ArtifactPathInfoTest diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/util/SnapshotUtilsTest.java b/identities/src/test/java/org/commonjava/atlas/maven/ident/util/SnapshotUtilsTest.java similarity index 95% rename from identities/src/test/java/org/commonjava/maven/atlas/ident/util/SnapshotUtilsTest.java rename to identities/src/test/java/org/commonjava/atlas/maven/ident/util/SnapshotUtilsTest.java index 6044b407..4c8705fd 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/util/SnapshotUtilsTest.java +++ b/identities/src/test/java/org/commonjava/atlas/maven/ident/util/SnapshotUtilsTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.util; +package org.commonjava.atlas.maven.ident.util; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; @@ -21,6 +21,7 @@ import java.text.ParseException; import java.util.Date; +import org.commonjava.atlas.maven.ident.util.SnapshotUtils; import org.junit.Test; public class SnapshotUtilsTest diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/SingleVersionComparisonsTest.java b/identities/src/test/java/org/commonjava/atlas/maven/ident/version/SingleVersionComparisonsTest.java similarity index 99% rename from identities/src/test/java/org/commonjava/maven/atlas/ident/version/SingleVersionComparisonsTest.java rename to identities/src/test/java/org/commonjava/atlas/maven/ident/version/SingleVersionComparisonsTest.java index e91861e0..dd04c117 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/SingleVersionComparisonsTest.java +++ b/identities/src/test/java/org/commonjava/atlas/maven/ident/version/SingleVersionComparisonsTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version; +package org.commonjava.atlas.maven.ident.version; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -42,7 +42,7 @@ import java.util.List; import java.util.Locale; -import org.commonjava.maven.atlas.ident.util.VersionUtils; +import org.commonjava.atlas.maven.ident.util.VersionUtils; import org.junit.After; import org.junit.Rule; import org.junit.Test; diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionParserTest.java b/identities/src/test/java/org/commonjava/atlas/maven/ident/version/VersionParserTest.java similarity index 92% rename from identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionParserTest.java rename to identities/src/test/java/org/commonjava/atlas/maven/ident/version/VersionParserTest.java index ddc47787..51630143 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionParserTest.java +++ b/identities/src/test/java/org/commonjava/atlas/maven/ident/version/VersionParserTest.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version; +package org.commonjava.atlas.maven.ident.version; -import org.commonjava.maven.atlas.ident.version.VersionSpec; -import org.commonjava.maven.atlas.ident.version.parse.VersionParser; +import org.commonjava.atlas.maven.ident.version.VersionSpec; +import org.commonjava.atlas.maven.ident.version.parse.VersionParser; import org.junit.Test; public class VersionParserTest diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionRangeTest.java b/identities/src/test/java/org/commonjava/atlas/maven/ident/version/VersionRangeTest.java similarity index 83% rename from identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionRangeTest.java rename to identities/src/test/java/org/commonjava/atlas/maven/ident/version/VersionRangeTest.java index 6dddaba7..3d42fb9e 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionRangeTest.java +++ b/identities/src/test/java/org/commonjava/atlas/maven/ident/version/VersionRangeTest.java @@ -13,14 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version; +package org.commonjava.atlas.maven.ident.version; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; -import org.commonjava.maven.atlas.ident.util.VersionUtils; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; -import org.commonjava.maven.atlas.ident.version.RangeVersionSpec; +import org.commonjava.atlas.maven.ident.util.VersionUtils; import org.junit.Test; public class VersionRangeTest diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionUtilsTest.java b/identities/src/test/java/org/commonjava/atlas/maven/ident/version/VersionUtilsTest.java similarity index 93% rename from identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionUtilsTest.java rename to identities/src/test/java/org/commonjava/atlas/maven/ident/version/VersionUtilsTest.java index c867ac10..6a879fec 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/VersionUtilsTest.java +++ b/identities/src/test/java/org/commonjava/atlas/maven/ident/version/VersionUtilsTest.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version; +package org.commonjava.atlas.maven.ident.version; -import org.commonjava.maven.atlas.ident.util.VersionUtils; +import org.commonjava.atlas.maven.ident.util.VersionUtils; import org.junit.Test; import static org.hamcrest.CoreMatchers.equalTo; diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/part/NumericPartTest.java b/identities/src/test/java/org/commonjava/atlas/maven/ident/version/part/NumericPartTest.java similarity index 84% rename from identities/src/test/java/org/commonjava/maven/atlas/ident/version/part/NumericPartTest.java rename to identities/src/test/java/org/commonjava/atlas/maven/ident/version/part/NumericPartTest.java index 3583e5c4..c11d60bd 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/part/NumericPartTest.java +++ b/identities/src/test/java/org/commonjava/atlas/maven/ident/version/part/NumericPartTest.java @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version.part; +package org.commonjava.atlas.maven.ident.version.part; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; -import org.commonjava.maven.atlas.ident.version.part.NumericPart; +import org.commonjava.atlas.maven.ident.version.InvalidVersionSpecificationException; +import org.commonjava.atlas.maven.ident.version.part.NumericPart; import org.junit.Test; public class NumericPartTest diff --git a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPartTest.java b/identities/src/test/java/org/commonjava/atlas/maven/ident/version/part/SnapshotPartTest.java similarity index 93% rename from identities/src/test/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPartTest.java rename to identities/src/test/java/org/commonjava/atlas/maven/ident/version/part/SnapshotPartTest.java index cdcc4d9d..a45d155f 100644 --- a/identities/src/test/java/org/commonjava/maven/atlas/ident/version/part/SnapshotPartTest.java +++ b/identities/src/test/java/org/commonjava/atlas/maven/ident/version/part/SnapshotPartTest.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.ident.version.part; +package org.commonjava.atlas.maven.ident.version.part; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; -import org.commonjava.maven.atlas.ident.util.SnapshotUtils; +import org.commonjava.atlas.maven.ident.util.SnapshotUtils; import org.junit.Test; public class SnapshotPartTest diff --git a/pom.xml b/pom.xml index 49662d91..c43f1c25 100644 --- a/pom.xml +++ b/pom.xml @@ -25,12 +25,12 @@ 9 - org.commonjava.maven.atlas + org.commonjava.atlas atlas-parent 0.17.3-SNAPSHOT pom - Atlas :: Maven Project-Graph :: Parent + Atlas :: Parent scm:git:https://github.com/Commonjava/atlas.git @@ -46,22 +46,22 @@ - org.commonjava.maven.atlas + org.commonjava.atlas atlas-identities 0.17.3-SNAPSHOT - org.commonjava.maven.atlas + org.commonjava.atlas atlas-relationships-api 0.17.3-SNAPSHOT - org.commonjava.maven.atlas + org.commonjava.atlas atlas-bindings-jackson-identities 0.17.3-SNAPSHOT - org.commonjava.maven.atlas + org.commonjava.atlas atlas-bindings-jackson-relationships 0.17.1-SNAPSHOT diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 7867e6a3..d7355bf7 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -20,7 +20,7 @@ 4.0.0 - org.commonjava.maven.atlas + org.commonjava.atlas atlas-parent 0.17.3-SNAPSHOT @@ -31,7 +31,7 @@ - org.commonjava.maven.atlas + org.commonjava.atlas atlas-identities @@ -47,7 +47,7 @@ jackson-core - org.commonjava.maven.atlas + org.commonjava.atlas atlas-bindings-jackson-identities diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/PluginKeyDeserializer.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/jackson/PluginKeyDeserializer.java similarity index 92% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/PluginKeyDeserializer.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/jackson/PluginKeyDeserializer.java index 379bd0d8..59b8cd9a 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/PluginKeyDeserializer.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/jackson/PluginKeyDeserializer.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.jackson; +package org.commonjava.atlas.maven.graph.jackson; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.KeyDeserializer; -import org.commonjava.maven.atlas.graph.model.PluginKey; +import org.commonjava.atlas.maven.graph.model.PluginKey; import java.io.IOException; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/PluginKeySerializer.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/jackson/PluginKeySerializer.java similarity index 92% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/PluginKeySerializer.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/jackson/PluginKeySerializer.java index 834046bb..81f57bb4 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/PluginKeySerializer.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/jackson/PluginKeySerializer.java @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.jackson; +package org.commonjava.atlas.maven.graph.jackson; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; -import org.commonjava.maven.atlas.graph.model.PluginKey; +import org.commonjava.atlas.maven.graph.model.PluginKey; import java.io.IOException; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/jackson/ProjectRelationshipDeserializer.java similarity index 76% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/jackson/ProjectRelationshipDeserializer.java index 6cf1dd99..0ef6674c 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipDeserializer.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/jackson/ProjectRelationshipDeserializer.java @@ -13,14 +13,27 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.jackson; +package org.commonjava.atlas.maven.graph.jackson; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import org.commonjava.maven.atlas.graph.rel.*; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.*; +import org.commonjava.atlas.maven.graph.rel.ProjectRelationship; +import org.commonjava.atlas.maven.graph.rel.RelationshipConstants; +import org.commonjava.atlas.maven.graph.rel.RelationshipType; +import org.commonjava.atlas.maven.graph.rel.SimpleBomRelationship; +import org.commonjava.atlas.maven.graph.rel.SimpleDependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.SimpleExtensionRelationship; +import org.commonjava.atlas.maven.graph.rel.SimpleParentRelationship; +import org.commonjava.atlas.maven.graph.rel.SimplePluginDependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.SimplePluginRelationship; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.SimpleArtifactRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef; +import org.commonjava.atlas.maven.ident.DependencyScope; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,8 +42,6 @@ import java.net.URISyntaxException; import java.util.*; -import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.*; - /** * Created by jdcasey on 8/26/15. */ @@ -128,9 +139,9 @@ public T deserialize( final JsonParser jp, final DeserializationContext ctx ) logger.debug( sb.toString() ); - final RelationshipType type = RelationshipType.getType( (String) ast.get( RELATIONSHIP_TYPE ) ); + final RelationshipType type = RelationshipType.getType( (String) ast.get( SerializationConstants.RELATIONSHIP_TYPE ) ); - final String uri = (String) ast.get( POM_LOCATION_URI ); + final String uri = (String) ast.get( SerializationConstants.POM_LOCATION_URI ); URI pomLocation; if ( uri == null ) { @@ -144,13 +155,13 @@ public T deserialize( final JsonParser jp, final DeserializationContext ctx ) } catch ( final URISyntaxException e ) { - throw new JsonParseException( "Invalid " + POM_LOCATION_URI + ": '" + uri + "': " + e.getMessage(), - locations.get( POM_LOCATION_URI ), e ); + throw new JsonParseException( "Invalid " + SerializationConstants.POM_LOCATION_URI + ": '" + uri + "': " + e.getMessage(), + locations.get( SerializationConstants.POM_LOCATION_URI ), e ); } } Collection sources = new HashSet(); - List srcs = (List) ast.get( SOURCE_URIS ); + List srcs = (List) ast.get( SerializationConstants.SOURCE_URIS ); if ( srcs != null ) { for ( String u : srcs ) @@ -162,26 +173,26 @@ public T deserialize( final JsonParser jp, final DeserializationContext ctx ) catch ( URISyntaxException e ) { throw new JsonParseException( "Failed to parse source URI: " + u, - locations.get( SOURCE_URIS ) ); + locations.get( SerializationConstants.SOURCE_URIS ) ); } } } - String decl = (String) ast.get( DECLARING_REF ); + String decl = (String) ast.get( SerializationConstants.DECLARING_REF ); final ProjectVersionRef declaring = SimpleProjectVersionRef.parse( decl ); - String tgt = (String) ast.get( TARGET_REF ); - Integer index = (Integer) ast.get( INDEX ); + String tgt = (String) ast.get( SerializationConstants.TARGET_REF ); + Integer index = (Integer) ast.get( SerializationConstants.INDEX ); if ( index == null ) { index = 0; } // handle null implicitly by comparing to true. - boolean managed = Boolean.TRUE.equals( ast.get( MANAGED ) ); - boolean inherited = Boolean.TRUE.equals( ast.get( INHERITED ) ); - boolean mixin = Boolean.TRUE.equals( ast.get( MIXIN ) ); - boolean optional = Boolean.TRUE.equals( ast.get( OPTIONAL ) ); + boolean managed = Boolean.TRUE.equals( ast.get( SerializationConstants.MANAGED ) ); + boolean inherited = Boolean.TRUE.equals( ast.get( SerializationConstants.INHERITED ) ); + boolean mixin = Boolean.TRUE.equals( ast.get( SerializationConstants.MIXIN ) ); + boolean optional = Boolean.TRUE.equals( ast.get( SerializationConstants.OPTIONAL ) ); ProjectRelationship rel = null; switch ( type ) @@ -190,7 +201,7 @@ public T deserialize( final JsonParser jp, final DeserializationContext ctx ) { final ArtifactRef target = SimpleArtifactRef.parse( tgt ); - String scp = (String) ast.get( SCOPE ); + String scp = (String) ast.get( SerializationConstants.SCOPE ); final DependencyScope scope; if ( scp == null ) { @@ -223,17 +234,17 @@ public T deserialize( final JsonParser jp, final DeserializationContext ctx ) { final ProjectVersionRef target = SimpleProjectVersionRef.parse( tgt ); - Boolean report = (Boolean) ast.get( REPORTING ); + Boolean report = (Boolean) ast.get( SerializationConstants.REPORTING ); rel = new SimplePluginRelationship( sources, pomLocation, declaring, target, index, managed, Boolean.TRUE.equals( report ), inherited ); break; } case PLUGIN_DEP: { - String plug = (String) ast.get( PLUGIN_REF ); + String plug = (String) ast.get( SerializationConstants.PLUGIN_REF ); if ( plug == null ) { - throw new JsonParseException( "No plugin reference (field: " + PLUGIN_REF + throw new JsonParseException( "No plugin reference (field: " + SerializationConstants.PLUGIN_REF + ") found in plugin-dependency relationship!", jp.getCurrentLocation() ); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/jackson/ProjectRelationshipSerializer.java similarity index 58% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/jackson/ProjectRelationshipSerializer.java index 3f32fba5..a7e2de19 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializer.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/jackson/ProjectRelationshipSerializer.java @@ -13,24 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.jackson; +package org.commonjava.atlas.maven.graph.jackson; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdSerializer; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.atlas.maven.graph.rel.DependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.PluginDependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.PluginRelationship; +import org.commonjava.atlas.maven.graph.rel.ProjectRelationship; import java.io.IOException; import java.net.URI; import java.util.Iterator; import java.util.Set; -import static org.commonjava.maven.atlas.graph.jackson.SerializationConstants.*; - /** * Created by jdcasey on 8/26/15. */ @@ -49,9 +47,9 @@ public void serialize( final T value, final JsonGenerator gen, final SerializerP throws IOException, JsonGenerationException { gen.writeStartObject(); - gen.writeStringField( RELATIONSHIP_TYPE, value.getType().name() ); - gen.writeStringField( POM_LOCATION_URI, value.getPomLocation().toString() ); - gen.writeBooleanField( INHERITED, value.isInherited() ); + gen.writeStringField( SerializationConstants.RELATIONSHIP_TYPE, value.getType().name() ); + gen.writeStringField( SerializationConstants.POM_LOCATION_URI, value.getPomLocation().toString() ); + gen.writeBooleanField( SerializationConstants.INHERITED, value.isInherited() ); Set sources = value.getSources(); if ( sources != null ) @@ -65,7 +63,7 @@ public void serialize( final T value, final JsonGenerator gen, final SerializerP } if ( !sources.isEmpty() ) { - gen.writeArrayFieldStart( SOURCE_URIS ); + gen.writeArrayFieldStart( SerializationConstants.SOURCE_URIS ); for ( URI uri : sources ) { if ( uri == null ) @@ -77,38 +75,38 @@ public void serialize( final T value, final JsonGenerator gen, final SerializerP gen.writeEndArray(); } } - provider.defaultSerializeField( DECLARING_REF, value.getDeclaring(), gen ); - provider.defaultSerializeField( TARGET_REF, value.getTarget(), gen ); + provider.defaultSerializeField( SerializationConstants.DECLARING_REF, value.getDeclaring(), gen ); + provider.defaultSerializeField( SerializationConstants.TARGET_REF, value.getTarget(), gen ); switch ( value.getType() ) { case BOM: - gen.writeBooleanField( MIXIN, value.isMixin() ); + gen.writeBooleanField( SerializationConstants.MIXIN, value.isMixin() ); break; case DEPENDENCY: { - gen.writeStringField( SCOPE, ( (DependencyRelationship) value ).getScope().realName() ); - gen.writeBooleanField( MANAGED, value.isManaged() ); - gen.writeBooleanField( OPTIONAL, ( (DependencyRelationship) value ).isOptional() ); + gen.writeStringField( SerializationConstants.SCOPE, ( (DependencyRelationship) value ).getScope().realName() ); + gen.writeBooleanField( SerializationConstants.MANAGED, value.isManaged() ); + gen.writeBooleanField( SerializationConstants.OPTIONAL, ( (DependencyRelationship) value ).isOptional() ); break; } case PLUGIN_DEP: { - provider.defaultSerializeField( PLUGIN_REF, ( (PluginDependencyRelationship) value ).getPlugin(), + provider.defaultSerializeField( SerializationConstants.PLUGIN_REF, ( (PluginDependencyRelationship) value ).getPlugin(), gen ); - gen.writeBooleanField( MANAGED, value.isManaged() ); + gen.writeBooleanField( SerializationConstants.MANAGED, value.isManaged() ); break; } case PLUGIN: { - gen.writeBooleanField( MANAGED, value.isManaged() ); - gen.writeBooleanField( REPORTING, ( (PluginRelationship) value ).isReporting() ); + gen.writeBooleanField( SerializationConstants.MANAGED, value.isManaged() ); + gen.writeBooleanField( SerializationConstants.REPORTING, ( (PluginRelationship) value ).isReporting() ); break; } } - gen.writeNumberField( INDEX, value.getIndex() ); + gen.writeNumberField( SerializationConstants.INDEX, value.getIndex() ); gen.writeEndObject(); } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/jackson/ProjectRelationshipSerializerModule.java similarity index 73% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/jackson/ProjectRelationshipSerializerModule.java index 6e39bd3d..89143209 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModule.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/jackson/ProjectRelationshipSerializerModule.java @@ -13,11 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.jackson; +package org.commonjava.atlas.maven.graph.jackson; import com.fasterxml.jackson.databind.module.SimpleModule; -import org.commonjava.maven.atlas.graph.model.PluginKey; -import org.commonjava.maven.atlas.graph.rel.*; +import org.commonjava.atlas.maven.graph.rel.BomRelationship; +import org.commonjava.atlas.maven.graph.rel.DependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.ExtensionRelationship; +import org.commonjava.atlas.maven.graph.rel.ParentRelationship; +import org.commonjava.atlas.maven.graph.rel.PluginDependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.PluginRelationship; +import org.commonjava.atlas.maven.graph.rel.ProjectRelationship; +import org.commonjava.atlas.maven.graph.rel.SimpleBomRelationship; +import org.commonjava.atlas.maven.graph.rel.SimpleDependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.SimpleExtensionRelationship; +import org.commonjava.atlas.maven.graph.rel.SimpleParentRelationship; +import org.commonjava.atlas.maven.graph.rel.SimplePluginDependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.SimplePluginRelationship; +import org.commonjava.atlas.maven.graph.model.PluginKey; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/jackson/SerializationConstants.java similarity index 95% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/jackson/SerializationConstants.java index 8f096a6b..8a5af47c 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/jackson/SerializationConstants.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/jackson/SerializationConstants.java @@ -13,9 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.jackson; - -import com.fasterxml.jackson.core.io.SerializedString; +package org.commonjava.atlas.maven.graph.jackson; public final class SerializationConstants { diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/model/EProjectCycle.java similarity index 96% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/model/EProjectCycle.java index 5c2bc5a7..4af86805 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectCycle.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/model/EProjectCycle.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.model; +package org.commonjava.atlas.maven.graph.model; import static org.apache.commons.lang.StringUtils.join; @@ -26,10 +26,10 @@ import java.util.List; import java.util.Set; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.RelationshipComparator; -import org.commonjava.maven.atlas.graph.util.RelationshipUtils; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.graph.rel.ProjectRelationship; +import org.commonjava.atlas.maven.graph.rel.RelationshipComparator; +import org.commonjava.atlas.maven.graph.util.RelationshipUtils; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; public class EProjectCycle implements Iterable>, EProjectRelationshipCollection diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/model/EProjectDirectRelationships.java similarity index 93% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/model/EProjectDirectRelationships.java index 47a355fa..e4d163be 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectDirectRelationships.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/model/EProjectDirectRelationships.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.model; +package org.commonjava.atlas.maven.graph.model; -import static org.commonjava.maven.atlas.graph.rel.RelationshipConstants.POM_ROOT_URI; -import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.filterTerminalParents; +import static org.commonjava.atlas.maven.graph.rel.RelationshipConstants.POM_ROOT_URI; +import static org.commonjava.atlas.maven.graph.util.RelationshipUtils.filterTerminalParents; import java.io.Serializable; import java.net.URI; @@ -31,21 +31,21 @@ import java.util.Set; import com.fasterxml.jackson.annotation.JsonIgnore; -import org.commonjava.maven.atlas.graph.rel.BomRelationship; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; -import org.commonjava.maven.atlas.graph.rel.ParentRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleExtensionRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship; -import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.graph.rel.BomRelationship; +import org.commonjava.atlas.maven.graph.rel.DependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.ExtensionRelationship; +import org.commonjava.atlas.maven.graph.rel.ParentRelationship; +import org.commonjava.atlas.maven.graph.rel.PluginDependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.PluginRelationship; +import org.commonjava.atlas.maven.graph.rel.ProjectRelationship; +import org.commonjava.atlas.maven.graph.rel.SimpleDependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.SimpleExtensionRelationship; +import org.commonjava.atlas.maven.graph.rel.SimpleParentRelationship; +import org.commonjava.atlas.maven.graph.rel.SimplePluginRelationship; +import org.commonjava.atlas.maven.ident.DependencyScope; +import org.commonjava.atlas.maven.ident.ref.SimpleArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; public class EProjectDirectRelationships implements EProjectRelationshipCollection, Serializable diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectRelationshipCollection.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/model/EProjectRelationshipCollection.java similarity index 89% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectRelationshipCollection.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/model/EProjectRelationshipCollection.java index c4f216ba..3568f552 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/EProjectRelationshipCollection.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/model/EProjectRelationshipCollection.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.model; +package org.commonjava.atlas.maven.graph.model; import java.io.Serializable; import java.util.Collection; -import org.commonjava.maven.atlas.graph.rel.ProjectRelationship; +import org.commonjava.atlas.maven.graph.rel.ProjectRelationship; public interface EProjectRelationshipCollection extends Serializable diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/PluginKey.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/model/PluginKey.java similarity index 95% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/PluginKey.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/model/PluginKey.java index 42cb80a3..6885b3bc 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/model/PluginKey.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/model/PluginKey.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.model; +package org.commonjava.atlas.maven.graph.model; -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.graph.rel.PluginRelationship; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; import java.io.Serializable; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/AbstractSimpleProjectRelationship.java similarity index 91% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/AbstractSimpleProjectRelationship.java index 145619d5..382f17d0 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/AbstractSimpleProjectRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/AbstractSimpleProjectRelationship.java @@ -13,19 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef; import java.io.Serializable; import java.lang.reflect.Constructor; import java.net.URI; import java.util.*; -import static org.commonjava.maven.atlas.graph.rel.RelationshipConstants.POM_ROOT_URI; - public abstract class AbstractSimpleProjectRelationship, T extends ProjectVersionRef> implements ProjectRelationship, Serializable { @@ -59,28 +57,28 @@ protected AbstractSimpleProjectRelationship( final URI source, final Relationshi final ProjectVersionRef declaring, final T target, final int index, final boolean inherited, final boolean mixin ) { - this( Collections.singleton( source ), POM_ROOT_URI, type, declaring, target, index, false, inherited, mixin ); + this( Collections.singleton( source ), RelationshipConstants.POM_ROOT_URI, type, declaring, target, index, false, inherited, mixin ); } protected AbstractSimpleProjectRelationship( final Collection sources, final RelationshipType type, final ProjectVersionRef declaring, final T target, final int index, final boolean inherited, final boolean mixin ) { - this( sources, POM_ROOT_URI, type, declaring, target, index, false, inherited, mixin ); + this( sources, RelationshipConstants.POM_ROOT_URI, type, declaring, target, index, false, inherited, mixin ); } protected AbstractSimpleProjectRelationship( final URI source, final RelationshipType type, final ProjectVersionRef declaring, final T target, final int index, final boolean managed, final boolean inherited, final boolean mixin ) { - this( Collections.singleton( source ), POM_ROOT_URI, type, declaring, target, index, managed, inherited, mixin ); + this( Collections.singleton( source ), RelationshipConstants.POM_ROOT_URI, type, declaring, target, index, managed, inherited, mixin ); } protected AbstractSimpleProjectRelationship( final Collection sources, final RelationshipType type, final ProjectVersionRef declaring, final T target, final int index, final boolean managed, final boolean inherited, final boolean mixin ) { - this( sources, POM_ROOT_URI, type, declaring, target, index, managed, inherited, mixin ); + this( sources, RelationshipConstants.POM_ROOT_URI, type, declaring, target, index, managed, inherited, mixin ); } protected AbstractSimpleProjectRelationship( final URI source, final URI pomLocation, final RelationshipType type, diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/BomRelationship.java similarity index 86% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/BomRelationship.java index 80bdce8e..e6beafc2 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/BomRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/BomRelationship.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; import java.io.Serializable; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/DependencyRelationship.java similarity index 82% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/DependencyRelationship.java index 263f241d..ec6b69c9 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/DependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/DependencyRelationship.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.DependencyScope; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; import java.io.Serializable; import java.util.Set; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/ExtensionRelationship.java similarity index 87% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/ExtensionRelationship.java index e90685be..4c4d137c 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ExtensionRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/ExtensionRelationship.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; import java.io.Serializable; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/ParentRelationship.java similarity index 85% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/ParentRelationship.java index d0f55221..98e6884c 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ParentRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/ParentRelationship.java @@ -13,13 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; import java.io.Serializable; -import java.net.URI; /** * Created by jdcasey on 8/24/15. diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/PluginDependencyRelationship.java similarity index 84% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/PluginDependencyRelationship.java index afe84257..bc646c4f 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginDependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/PluginDependencyRelationship.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; import java.io.Serializable; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/PluginRelationship.java similarity index 87% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/PluginRelationship.java index 0b88fe10..de27ec9f 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/PluginRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/PluginRelationship.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; import java.io.Serializable; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ProjectRelationship.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/ProjectRelationship.java similarity index 79% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ProjectRelationship.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/ProjectRelationship.java index eedeec5d..b46e6673 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/ProjectRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/ProjectRelationship.java @@ -13,18 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; import java.io.Serializable; import java.net.URI; import java.util.Collection; import java.util.Set; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.ident.version.SingleVersion; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; public interface ProjectRelationship, T extends ProjectVersionRef> extends Serializable diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparator.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/RelationshipComparator.java similarity index 77% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparator.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/RelationshipComparator.java index 2c90c4ea..8e09a8f7 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparator.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/RelationshipComparator.java @@ -13,9 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; - -import static org.commonjava.maven.atlas.graph.rel.RelationshipConstants.POM_ROOT_URI; +package org.commonjava.atlas.maven.graph.rel; import java.util.Comparator; @@ -35,14 +33,14 @@ public int compare( final ProjectRelationship one, final ProjectRelationsh if ( one.getType() == two.getType() ) { if ( one.getPomLocation() - .equals( POM_ROOT_URI ) && !two.getPomLocation() - .equals( POM_ROOT_URI ) ) + .equals( RelationshipConstants.POM_ROOT_URI ) && !two.getPomLocation() + .equals( RelationshipConstants.POM_ROOT_URI ) ) { return -1; } else if ( !one.getPomLocation() - .equals( POM_ROOT_URI ) && two.getPomLocation() - .equals( POM_ROOT_URI ) ) + .equals( RelationshipConstants.POM_ROOT_URI ) && two.getPomLocation() + .equals( RelationshipConstants.POM_ROOT_URI ) ) { return 1; } diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipConstants.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/RelationshipConstants.java similarity index 97% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipConstants.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/RelationshipConstants.java index 04903fc8..f91963d1 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipConstants.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/RelationshipConstants.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; import java.net.URI; import java.net.URISyntaxException; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparator.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/RelationshipPathComparator.java similarity index 98% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparator.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/RelationshipPathComparator.java index 5795144d..d306a678 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparator.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/RelationshipPathComparator.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipType.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/RelationshipType.java similarity index 97% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipType.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/RelationshipType.java index 07cd9b29..6831122b 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/RelationshipType.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/RelationshipType.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; import java.util.Arrays; import java.util.Collections; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleBomRelationship.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/SimpleBomRelationship.java similarity index 95% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleBomRelationship.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/SimpleBomRelationship.java index a739588a..de1696cd 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleBomRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/SimpleBomRelationship.java @@ -13,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; import java.net.URI; import java.util.Collection; import java.util.Set; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef; /** NOTE: BOM relationships are actually marked as concrete. * This may be somewhat counter-intuitive, but they are structural (like a parent POM). diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/SimpleDependencyRelationship.java similarity index 95% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/SimpleDependencyRelationship.java index 30b8c799..e0bb222c 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleDependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/SimpleDependencyRelationship.java @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; +import org.commonjava.atlas.maven.ident.DependencyScope; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.SimpleArtifactRef; import java.io.Serializable; import java.net.URI; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/SimpleExtensionRelationship.java similarity index 93% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/SimpleExtensionRelationship.java index 1ccc864a..dc3e2ba9 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleExtensionRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/SimpleExtensionRelationship.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.SimpleArtifactRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef; import java.io.Serializable; import java.net.URI; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/SimpleParentRelationship.java similarity index 93% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/SimpleParentRelationship.java index 773dea48..ff5816ae 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimpleParentRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/SimpleParentRelationship.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.SimpleArtifactRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef; import java.io.Serializable; import java.net.URI; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/SimplePluginDependencyRelationship.java similarity index 95% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/SimplePluginDependencyRelationship.java index 34bd8ac9..0c9bcf47 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginDependencyRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/SimplePluginDependencyRelationship.java @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.SimpleArtifactRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectRef; import java.io.Serializable; import java.net.URI; diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/SimplePluginRelationship.java similarity index 95% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/SimplePluginRelationship.java index 5932b7c9..e4a5f3a5 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/rel/SimplePluginRelationship.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/rel/SimplePluginRelationship.java @@ -13,17 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; import java.io.Serializable; import java.net.URI; import java.util.Collection; import java.util.Set; -import org.commonjava.maven.atlas.ident.ref.ArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.ArtifactRef; +import org.commonjava.atlas.maven.ident.ref.SimpleArtifactRef; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef; public final class SimplePluginRelationship extends AbstractSimpleProjectRelationship diff --git a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/util/RelationshipUtils.java similarity index 91% rename from relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java rename to relationships-api/src/main/java/org/commonjava/atlas/maven/graph/util/RelationshipUtils.java index c73b1dfd..79919fc8 100644 --- a/relationships-api/src/main/java/org/commonjava/maven/atlas/graph/util/RelationshipUtils.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/util/RelationshipUtils.java @@ -13,20 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.util; +package org.commonjava.atlas.maven.graph.util; -import static org.commonjava.maven.atlas.graph.rel.RelationshipConstants.POM_ROOT_URI; -import static org.commonjava.maven.atlas.ident.util.IdentityUtils.artifact; +import static org.commonjava.atlas.maven.graph.rel.RelationshipConstants.POM_ROOT_URI; +import static org.commonjava.atlas.maven.ident.util.IdentityUtils.artifact; import java.net.URI; import java.net.URISyntaxException; import java.util.Collection; import java.util.Iterator; -import org.commonjava.maven.atlas.graph.rel.*; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; +import org.commonjava.atlas.maven.graph.rel.DependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.ParentRelationship; +import org.commonjava.atlas.maven.graph.rel.ProjectRelationship; +import org.commonjava.atlas.maven.graph.rel.SimpleDependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.SimpleParentRelationship; +import org.commonjava.atlas.maven.ident.DependencyScope; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.version.InvalidVersionSpecificationException; public final class RelationshipUtils { @@ -134,7 +138,7 @@ public static void filterTerminalParents( final Collection> it = rels.iterator(); it.hasNext(); ) { final ProjectRelationship rel = it.next(); - if ( ( rel instanceof SimpleParentRelationship) && ( (ParentRelationship) rel ).isTerminus() ) + if ( ( rel instanceof SimpleParentRelationship ) && ( (ParentRelationship) rel ).isTerminus() ) { it.remove(); } diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/jackson/EProjectRelationshipsSerializerTest.java b/relationships-api/src/test/java/org/commonjava/atlas/maven/graph/jackson/EProjectRelationshipsSerializerTest.java similarity index 81% rename from relationships-api/src/test/java/org/commonjava/maven/atlas/graph/jackson/EProjectRelationshipsSerializerTest.java rename to relationships-api/src/test/java/org/commonjava/atlas/maven/graph/jackson/EProjectRelationshipsSerializerTest.java index db71641a..3c482b70 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/jackson/EProjectRelationshipsSerializerTest.java +++ b/relationships-api/src/test/java/org/commonjava/atlas/maven/graph/jackson/EProjectRelationshipsSerializerTest.java @@ -13,24 +13,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.jackson; +package org.commonjava.atlas.maven.graph.jackson; import com.fasterxml.jackson.databind.ObjectMapper; -import org.commonjava.maven.atlas.graph.model.EProjectDirectRelationships; -import org.commonjava.maven.atlas.graph.rel.DependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.ExtensionRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.PluginRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimpleExtensionRelationship; -import org.commonjava.maven.atlas.graph.rel.SimplePluginDependencyRelationship; -import org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.jackson.ProjectVersionRefSerializerModule; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.atlas.maven.graph.jackson.ProjectRelationshipSerializerModule; +import org.commonjava.atlas.maven.graph.model.EProjectDirectRelationships; +import org.commonjava.atlas.maven.graph.rel.DependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.ExtensionRelationship; +import org.commonjava.atlas.maven.graph.rel.PluginDependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.PluginRelationship; +import org.commonjava.atlas.maven.graph.rel.SimpleDependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.SimpleExtensionRelationship; +import org.commonjava.atlas.maven.graph.rel.SimplePluginDependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.SimplePluginRelationship; +import org.commonjava.atlas.maven.ident.DependencyScope; +import org.commonjava.atlas.maven.ident.jackson.ProjectVersionRefSerializerModule; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.SimpleArtifactRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef; import org.junit.Before; import org.junit.Test; diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java b/relationships-api/src/test/java/org/commonjava/atlas/maven/graph/jackson/ProjectRelationshipSerializerModuleTest.java similarity index 73% rename from relationships-api/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java rename to relationships-api/src/test/java/org/commonjava/atlas/maven/graph/jackson/ProjectRelationshipSerializerModuleTest.java index 4496629d..793b5f48 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/jackson/ProjectRelationshipSerializerModuleTest.java +++ b/relationships-api/src/test/java/org/commonjava/atlas/maven/graph/jackson/ProjectRelationshipSerializerModuleTest.java @@ -13,13 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.jackson; +package org.commonjava.atlas.maven.graph.jackson; import com.fasterxml.jackson.databind.ObjectMapper; -import org.commonjava.maven.atlas.graph.rel.*; -import org.commonjava.maven.atlas.ident.DependencyScope; -import org.commonjava.maven.atlas.ident.jackson.ProjectVersionRefSerializerModule; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; +import org.commonjava.atlas.maven.graph.jackson.ProjectRelationshipSerializerModule; +import org.commonjava.atlas.maven.graph.rel.DependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.ParentRelationship; +import org.commonjava.atlas.maven.graph.rel.ProjectRelationship; +import org.commonjava.atlas.maven.graph.rel.RelationshipConstants; +import org.commonjava.atlas.maven.graph.rel.SimpleDependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.SimpleParentRelationship; +import org.commonjava.atlas.maven.ident.DependencyScope; +import org.commonjava.atlas.maven.ident.jackson.ProjectVersionRefSerializerModule; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef; import org.junit.Before; import org.junit.Test; @@ -79,9 +85,9 @@ public void roundTrip_SimpleConcreteDependency() { DependencyRelationship rel = new SimpleDependencyRelationship( URI.create( "some:test:location" ), RelationshipConstants.POM_ROOT_URI, - new SimpleProjectVersionRef( "org.foo", "bar", "1" ), - new SimpleProjectVersionRef( "org.foo", "dep", "1.1" ).asJarArtifact(), - DependencyScope.compile, 0, false, false, false ); + new SimpleProjectVersionRef( "org.foo", "bar", "1" ), + new SimpleProjectVersionRef( "org.foo", "dep", "1.1" ).asJarArtifact(), + DependencyScope.compile, 0, false, false, false ); String json = mapper.writeValueAsString( rel ); System.out.println( json ); diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/ParentRelationshipTest.java b/relationships-api/src/test/java/org/commonjava/atlas/maven/graph/rel/ParentRelationshipTest.java similarity index 83% rename from relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/ParentRelationshipTest.java rename to relationships-api/src/test/java/org/commonjava/atlas/maven/graph/rel/ParentRelationshipTest.java index ef72863c..401d3639 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/ParentRelationshipTest.java +++ b/relationships-api/src/test/java/org/commonjava/atlas/maven/graph/rel/ParentRelationshipTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; @@ -21,10 +21,12 @@ import java.net.URI; import java.net.URISyntaxException; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef; -import org.commonjava.maven.atlas.ident.util.VersionUtils; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; +import org.commonjava.atlas.maven.graph.rel.ParentRelationship; +import org.commonjava.atlas.maven.graph.rel.SimpleParentRelationship; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef; +import org.commonjava.atlas.maven.ident.util.VersionUtils; +import org.commonjava.atlas.maven.ident.version.InvalidVersionSpecificationException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestName; diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java b/relationships-api/src/test/java/org/commonjava/atlas/maven/graph/rel/RelationshipComparatorTest.java similarity index 85% rename from relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java rename to relationships-api/src/test/java/org/commonjava/atlas/maven/graph/rel/RelationshipComparatorTest.java index ca38417c..13f212cb 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipComparatorTest.java +++ b/relationships-api/src/test/java/org/commonjava/atlas/maven/graph/rel/RelationshipComparatorTest.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; -import static org.commonjava.maven.atlas.graph.rel.RelationshipConstants.POM_ROOT_URI; -import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.dependency; -import static org.commonjava.maven.atlas.ident.util.IdentityUtils.projectVersion; +import static org.commonjava.atlas.maven.graph.rel.RelationshipConstants.POM_ROOT_URI; +import static org.commonjava.atlas.maven.graph.util.RelationshipUtils.dependency; +import static org.commonjava.atlas.maven.ident.util.IdentityUtils.projectVersion; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.graph.rel.DependencyRelationship; +import org.commonjava.atlas.maven.graph.rel.RelationshipComparator; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; import org.junit.Test; public class RelationshipComparatorTest diff --git a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparatorTest.java b/relationships-api/src/test/java/org/commonjava/atlas/maven/graph/rel/RelationshipPathComparatorTest.java similarity index 84% rename from relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparatorTest.java rename to relationships-api/src/test/java/org/commonjava/atlas/maven/graph/rel/RelationshipPathComparatorTest.java index b0395714..7e561a01 100644 --- a/relationships-api/src/test/java/org/commonjava/maven/atlas/graph/rel/RelationshipPathComparatorTest.java +++ b/relationships-api/src/test/java/org/commonjava/atlas/maven/graph/rel/RelationshipPathComparatorTest.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.commonjava.maven.atlas.graph.rel; +package org.commonjava.atlas.maven.graph.rel; -import static org.commonjava.maven.atlas.graph.util.RelationshipUtils.dependency; -import static org.commonjava.maven.atlas.ident.util.IdentityUtils.projectVersion; +import static org.commonjava.atlas.maven.graph.util.RelationshipUtils.dependency; +import static org.commonjava.atlas.maven.ident.util.IdentityUtils.projectVersion; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; @@ -26,8 +26,11 @@ import java.util.Collections; import java.util.List; -import org.commonjava.maven.atlas.ident.ref.ProjectVersionRef; -import org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException; +import org.commonjava.atlas.maven.graph.rel.ProjectRelationship; +import org.commonjava.atlas.maven.graph.rel.RelationshipPathComparator; +import org.commonjava.atlas.maven.graph.rel.SimpleParentRelationship; +import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef; +import org.commonjava.atlas.maven.ident.version.InvalidVersionSpecificationException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestName; From 9b759fb3cc146bac141d7b3e9de7d694acf3f34e Mon Sep 17 00:00:00 2001 From: Rui Han Date: Tue, 16 Oct 2018 14:27:07 +0800 Subject: [PATCH 157/240] Add NPM ArtifactRef --- npm-identities/pom.xml | 21 +++++++ .../atlas/npm/ident/ref/ArtifactRef.java | 61 +++++++++++++++++++ .../atlas/npm/ident/util/VersionUtils.java | 14 +++++ .../atlas/npm/ident/ref/ArtifactRefTest.java | 38 ++++++++++++ pom.xml | 13 +++- 5 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 npm-identities/pom.xml create mode 100644 npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/ArtifactRef.java create mode 100644 npm-identities/src/main/java/org/commonjava/atlas/npm/ident/util/VersionUtils.java create mode 100644 npm-identities/src/test/java/org/commonjava/atlas/npm/ident/ref/ArtifactRefTest.java diff --git a/npm-identities/pom.xml b/npm-identities/pom.xml new file mode 100644 index 00000000..6e14d079 --- /dev/null +++ b/npm-identities/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + + org.commonjava.atlas + atlas-parent + 0.17.3-SNAPSHOT + + + atlas-npm-identities + + + + com.github.zafarkhaja + java-semver + + + \ No newline at end of file diff --git a/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/ArtifactRef.java b/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/ArtifactRef.java new file mode 100644 index 00000000..0d91fab1 --- /dev/null +++ b/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/ArtifactRef.java @@ -0,0 +1,61 @@ +package org.commonjava.atlas.npm.ident.ref; + +import com.github.zafarkhaja.semver.Version; + +/** + * ArtifactRef use jsemver Version object. Ref https://github.com/zafarkhaja/jsemver + * + * Created by ruhan on 10/17/18. + */ +public class ArtifactRef +{ + private String name; + + private Version version; + + public ArtifactRef( String name, Version version ) + { + this.name = name; + this.version = version; + } + + public String getName() + { + return name; + } + + public Version getVersion() + { + return version; + } + + @Override + public String toString() + { + return "ArtifactRef{" + "name='" + name + '\'' + ", version=" + version + '}'; + } + + @Override + public boolean equals( Object o ) + { + if ( this == o ) + return true; + if ( o == null || getClass() != o.getClass() ) + return false; + + ArtifactRef that = (ArtifactRef) o; + + if ( !name.equals( that.name ) ) + return false; + return version.equals( that.version ); + + } + + @Override + public int hashCode() + { + int result = name.hashCode(); + result = 31 * result + version.hashCode(); + return result; + } +} diff --git a/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/util/VersionUtils.java b/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/util/VersionUtils.java new file mode 100644 index 00000000..74ae72d5 --- /dev/null +++ b/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/util/VersionUtils.java @@ -0,0 +1,14 @@ +package org.commonjava.atlas.npm.ident.util; + +import com.github.zafarkhaja.semver.Version; + +/** + * Created by ruhan on 10/17/18. + */ +public class VersionUtils +{ + public static Version valueOf( String ver ) + { + return Version.valueOf( ver ); + } +} diff --git a/npm-identities/src/test/java/org/commonjava/atlas/npm/ident/ref/ArtifactRefTest.java b/npm-identities/src/test/java/org/commonjava/atlas/npm/ident/ref/ArtifactRefTest.java new file mode 100644 index 00000000..be78cd90 --- /dev/null +++ b/npm-identities/src/test/java/org/commonjava/atlas/npm/ident/ref/ArtifactRefTest.java @@ -0,0 +1,38 @@ +package org.commonjava.atlas.npm.ident.ref; + +import com.github.zafarkhaja.semver.Version; +import org.commonjava.atlas.npm.ident.util.VersionUtils; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; + +/** + * Created by ruhan on 10/17/18. + */ +public class ArtifactRefTest +{ + @Test + public void versionTest() + { + Version v = VersionUtils.valueOf( "1.0.0-rc.1+build.1" ); + + int major = v.getMajorVersion(); // 1 + int minor = v.getMinorVersion(); // 0 + int patch = v.getPatchVersion(); // 0 + + assertTrue( major == 1 ); + assertTrue( minor == 0 ); + assertTrue( patch == 0 ); + + String normal = v.getNormalVersion(); // "1.0.0" + String preRelease = v.getPreReleaseVersion(); // "rc.1" + String build = v.getBuildMetadata(); // "build.1" + + assertTrue( normal.equals( "1.0.0" ) ); + assertTrue( preRelease.equals( "rc.1" ) ); + assertTrue( build.equals( "build.1" ) ); + + String str = v.toString(); // "1.0.0-rc.1+build.1" + assertTrue( str.equals( "1.0.0-rc.1+build.1" ) ); + } +} diff --git a/pom.xml b/pom.xml index c43f1c25..82be8dfc 100644 --- a/pom.xml +++ b/pom.xml @@ -63,7 +63,17 @@ org.commonjava.atlas atlas-bindings-jackson-relationships - 0.17.1-SNAPSHOT + 0.17.3-SNAPSHOT + + + org.commonjava.atlas + atlas-npm-identities + 0.17.3-SNAPSHOT + + + com.github.zafarkhaja + java-semver + 0.9.0 org.commonjava.boms @@ -119,6 +129,7 @@ identities + npm-identities relationships-api bindings From 4f6b120dd01b3f58ef27ffc0814c42a825ba2474 Mon Sep 17 00:00:00 2001 From: Gang Li Date: Thu, 18 Oct 2018 14:29:26 +0800 Subject: [PATCH 158/240] Update web-commons-bom to 24 to fix jackson CVE --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 82be8dfc..f99dd453 100644 --- a/pom.xml +++ b/pom.xml @@ -78,7 +78,7 @@ org.commonjava.boms web-commons-bom - 21 + 24 import pom From d64673912979b4b6c0e6f3b847872ae93bca2230 Mon Sep 17 00:00:00 2001 From: Rui Han Date: Wed, 31 Oct 2018 10:50:27 +0800 Subject: [PATCH 159/240] Rename npm ArtifactRef to NpmArtifactRef and make it Externalizable --- .../{ArtifactRef.java => NpmArtifactRef.java} | 30 ++++++++- ...VersionUtils.java => NpmVersionUtils.java} | 2 +- .../atlas/npm/ident/ref/ArtifactRefTest.java | 38 ----------- .../npm/ident/ref/NpmArtifactRefTest.java | 65 +++++++++++++++++++ 4 files changed, 93 insertions(+), 42 deletions(-) rename npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/{ArtifactRef.java => NpmArtifactRef.java} (56%) rename npm-identities/src/main/java/org/commonjava/atlas/npm/ident/util/{VersionUtils.java => NpmVersionUtils.java} (89%) delete mode 100644 npm-identities/src/test/java/org/commonjava/atlas/npm/ident/ref/ArtifactRefTest.java create mode 100644 npm-identities/src/test/java/org/commonjava/atlas/npm/ident/ref/NpmArtifactRefTest.java diff --git a/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/ArtifactRef.java b/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/NpmArtifactRef.java similarity index 56% rename from npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/ArtifactRef.java rename to npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/NpmArtifactRef.java index 0d91fab1..06280123 100644 --- a/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/ArtifactRef.java +++ b/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/NpmArtifactRef.java @@ -1,19 +1,29 @@ package org.commonjava.atlas.npm.ident.ref; import com.github.zafarkhaja.semver.Version; +import org.commonjava.atlas.npm.ident.util.NpmVersionUtils; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; /** * ArtifactRef use jsemver Version object. Ref https://github.com/zafarkhaja/jsemver * * Created by ruhan on 10/17/18. */ -public class ArtifactRef +public class NpmArtifactRef implements Externalizable { private String name; private Version version; - public ArtifactRef( String name, Version version ) + public NpmArtifactRef() + { + } + + public NpmArtifactRef( String name, Version version ) { this.name = name; this.version = version; @@ -43,7 +53,7 @@ public boolean equals( Object o ) if ( o == null || getClass() != o.getClass() ) return false; - ArtifactRef that = (ArtifactRef) o; + NpmArtifactRef that = (NpmArtifactRef) o; if ( !name.equals( that.name ) ) return false; @@ -58,4 +68,18 @@ public int hashCode() result = 31 * result + version.hashCode(); return result; } + + @Override + public void writeExternal( ObjectOutput objectOutput ) throws IOException + { + objectOutput.writeObject( name ); + objectOutput.writeObject( version.toString() ); + } + + @Override + public void readExternal( ObjectInput objectInput ) throws IOException, ClassNotFoundException + { + this.name = (String) objectInput.readObject(); + this.version = NpmVersionUtils.valueOf( (String) objectInput.readObject() ); + } } diff --git a/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/util/VersionUtils.java b/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/util/NpmVersionUtils.java similarity index 89% rename from npm-identities/src/main/java/org/commonjava/atlas/npm/ident/util/VersionUtils.java rename to npm-identities/src/main/java/org/commonjava/atlas/npm/ident/util/NpmVersionUtils.java index 74ae72d5..9144c46f 100644 --- a/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/util/VersionUtils.java +++ b/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/util/NpmVersionUtils.java @@ -5,7 +5,7 @@ /** * Created by ruhan on 10/17/18. */ -public class VersionUtils +public class NpmVersionUtils { public static Version valueOf( String ver ) { diff --git a/npm-identities/src/test/java/org/commonjava/atlas/npm/ident/ref/ArtifactRefTest.java b/npm-identities/src/test/java/org/commonjava/atlas/npm/ident/ref/ArtifactRefTest.java deleted file mode 100644 index be78cd90..00000000 --- a/npm-identities/src/test/java/org/commonjava/atlas/npm/ident/ref/ArtifactRefTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.commonjava.atlas.npm.ident.ref; - -import com.github.zafarkhaja.semver.Version; -import org.commonjava.atlas.npm.ident.util.VersionUtils; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -/** - * Created by ruhan on 10/17/18. - */ -public class ArtifactRefTest -{ - @Test - public void versionTest() - { - Version v = VersionUtils.valueOf( "1.0.0-rc.1+build.1" ); - - int major = v.getMajorVersion(); // 1 - int minor = v.getMinorVersion(); // 0 - int patch = v.getPatchVersion(); // 0 - - assertTrue( major == 1 ); - assertTrue( minor == 0 ); - assertTrue( patch == 0 ); - - String normal = v.getNormalVersion(); // "1.0.0" - String preRelease = v.getPreReleaseVersion(); // "rc.1" - String build = v.getBuildMetadata(); // "build.1" - - assertTrue( normal.equals( "1.0.0" ) ); - assertTrue( preRelease.equals( "rc.1" ) ); - assertTrue( build.equals( "build.1" ) ); - - String str = v.toString(); // "1.0.0-rc.1+build.1" - assertTrue( str.equals( "1.0.0-rc.1+build.1" ) ); - } -} diff --git a/npm-identities/src/test/java/org/commonjava/atlas/npm/ident/ref/NpmArtifactRefTest.java b/npm-identities/src/test/java/org/commonjava/atlas/npm/ident/ref/NpmArtifactRefTest.java new file mode 100644 index 00000000..aea8260e --- /dev/null +++ b/npm-identities/src/test/java/org/commonjava/atlas/npm/ident/ref/NpmArtifactRefTest.java @@ -0,0 +1,65 @@ +package org.commonjava.atlas.npm.ident.ref; + +import com.github.zafarkhaja.semver.Version; +import org.commonjava.atlas.npm.ident.util.NpmVersionUtils; +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * Created by ruhan on 10/17/18. + */ +public class NpmArtifactRefTest +{ + @Test + public void versionTest() + { + Version v = NpmVersionUtils.valueOf( "1.0.0-rc.1+build.1" ); + + int major = v.getMajorVersion(); // 1 + int minor = v.getMinorVersion(); // 0 + int patch = v.getPatchVersion(); // 0 + + assertTrue( major == 1 ); + assertTrue( minor == 0 ); + assertTrue( patch == 0 ); + + String normal = v.getNormalVersion(); // "1.0.0" + String preRelease = v.getPreReleaseVersion(); // "rc.1" + String build = v.getBuildMetadata(); // "build.1" + + assertTrue( normal.equals( "1.0.0" ) ); + assertTrue( preRelease.equals( "rc.1" ) ); + assertTrue( build.equals( "build.1" ) ); + + String str = v.toString(); // "1.0.0-rc.1+build.1" + assertTrue( str.equals( "1.0.0-rc.1+build.1" ) ); + } + + @Test + public void serializeTest() throws IOException, ClassNotFoundException + { + Version v = NpmVersionUtils.valueOf( "1.0.0-rc.1+build.1" ); + NpmArtifactRef ref = new NpmArtifactRef( "test", v ); + + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream( bos ); + oos.writeObject( ref ); + oos.close(); + + byte[] bytes = bos.toByteArray(); + + ObjectInputStream ois = new ObjectInputStream( new ByteArrayInputStream( bytes ) ); + NpmArtifactRef ref2 = (NpmArtifactRef) ois.readObject(); + ois.close(); + + assertEquals( ref, ref2 ); + } +} From a85a4243d4fa0cb0d6c636cdb8cac9ea700dd60a Mon Sep 17 00:00:00 2001 From: John Casey Date: Thu, 1 Nov 2018 11:23:31 -0500 Subject: [PATCH 160/240] Switch version to 1.0.0-SNAPSHOT to support refactored packages --- bindings/jackson-identities/pom.xml | 4 ++-- bindings/pom.xml | 4 ++-- identities/pom.xml | 4 ++-- npm-identities/pom.xml | 19 ++++++++++++++++++- pom.xml | 21 ++++++++++++++------- relationships-api/pom.xml | 4 ++-- 6 files changed, 40 insertions(+), 16 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index f7506a30..99642680 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -1,7 +1,7 @@ @@ -7,7 +24,7 @@ org.commonjava.atlas atlas-parent - 0.17.3-SNAPSHOT + 1.0.0-SNAPSHOT atlas-npm-identities diff --git a/pom.xml b/pom.xml index f99dd453..9dde0b37 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 org.commonjava.atlas atlas-parent - 1.0.0-SNAPSHOT + 1.0.0 atlas-npm-identities diff --git a/pom.xml b/pom.xml index 9dde0b37..da6c0940 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.atlas atlas-parent - 1.0.0-SNAPSHOT + 1.0.0 pom Atlas :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - HEAD + atlas-parent-1.0.0 @@ -51,17 +51,17 @@ org.commonjava.atlas atlas-identities - 1.0.0-SNAPSHOT + 1.0.0 org.commonjava.atlas atlas-relationships-api - 1.0.0-SNAPSHOT + 1.0.0 org.commonjava.atlas atlas-bindings-jackson-identities - 1.0.0-SNAPSHOT + 1.0.0 org.commonjava.atlas @@ -71,7 +71,7 @@ org.commonjava.atlas atlas-npm-identities - 1.0.0-SNAPSHOT + 1.0.0 com.github.zafarkhaja diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 30b4237e..36e5d9cd 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.0.0-SNAPSHOT + 1.0.0 atlas-relationships-api From 7a3089963aa367e8472732c6f09ec9224537a31f Mon Sep 17 00:00:00 2001 From: John Casey Date: Tue, 20 Nov 2018 09:37:25 -0600 Subject: [PATCH 167/240] [maven-release-plugin] prepare for next development iteration --- bindings/jackson-identities/pom.xml | 2 +- bindings/pom.xml | 2 +- identities/pom.xml | 2 +- npm-identities/pom.xml | 2 +- pom.xml | 12 ++++++------ relationships-api/pom.xml | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 329ae97b..4e5d3a15 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-bindings-parent - 1.0.0 + 1.1.0-SNAPSHOT atlas-bindings-jackson-identities diff --git a/bindings/pom.xml b/bindings/pom.xml index f618afc9..73b3fa1e 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.0.0 + 1.1.0-SNAPSHOT atlas-bindings-parent diff --git a/identities/pom.xml b/identities/pom.xml index 77d1451d..8d9409a8 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.0.0 + 1.1.0-SNAPSHOT atlas-identities diff --git a/npm-identities/pom.xml b/npm-identities/pom.xml index db530669..16478fd2 100644 --- a/npm-identities/pom.xml +++ b/npm-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.0.0 + 1.1.0-SNAPSHOT atlas-npm-identities diff --git a/pom.xml b/pom.xml index da6c0940..8dbf328e 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.atlas atlas-parent - 1.0.0 + 1.1.0-SNAPSHOT pom Atlas :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - atlas-parent-1.0.0 + HEAD @@ -51,17 +51,17 @@ org.commonjava.atlas atlas-identities - 1.0.0 + 1.1.0-SNAPSHOT org.commonjava.atlas atlas-relationships-api - 1.0.0 + 1.1.0-SNAPSHOT org.commonjava.atlas atlas-bindings-jackson-identities - 1.0.0 + 1.1.0-SNAPSHOT org.commonjava.atlas @@ -71,7 +71,7 @@ org.commonjava.atlas atlas-npm-identities - 1.0.0 + 1.1.0-SNAPSHOT com.github.zafarkhaja diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 36e5d9cd..9e4c19e1 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.0.0 + 1.1.0-SNAPSHOT atlas-relationships-api From 1a2f4d9ba086372de4ae4b03f20c3aefe1181225 Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Tue, 4 Dec 2018 12:02:03 +0100 Subject: [PATCH 168/240] Add convenience methods into NPM identities --- .../npm/ident/ref/InvalidNpmRefException.java | 66 +++++++++ .../atlas/npm/ident/ref/NpmPackageRef.java | 127 ++++++++++++++++-- .../atlas/npm/ident/ref/NpmProjectRef.java | 15 ++- 3 files changed, 197 insertions(+), 11 deletions(-) create mode 100644 npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/InvalidNpmRefException.java diff --git a/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/InvalidNpmRefException.java b/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/InvalidNpmRefException.java new file mode 100644 index 00000000..e673f0e8 --- /dev/null +++ b/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/InvalidNpmRefException.java @@ -0,0 +1,66 @@ +/** + * Copyright (C) 2012 Red Hat, Inc. (nos-devel@redhat.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.commonjava.atlas.npm.ident.ref; + +import java.util.IllegalFormatException; + +/** + * Thrown to signal an invalid reference to another project. This happens most commonly when a name or version string is + * left blank or null. + */ +public class InvalidNpmRefException + extends RuntimeException +{ + private static final long serialVersionUID = 1L; + + private final Object[] params; + + public InvalidNpmRefException( final String message, final Throwable cause, final Object... params ) + { + super( message, cause ); + this.params = params; + } + + public InvalidNpmRefException( final String message, final Object... params ) + { + super( message ); + this.params = params; + } + + @Override + public String getLocalizedMessage() + { + return getMessage(); + } + + @Override + public String getMessage() + { + String format = super.getMessage(); + if ( params != null && params.length > 0 ) + { + try + { + format = String.format( format, params ); + } + catch ( final IllegalFormatException e ) + { + } + } + + return format; + } +} diff --git a/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/NpmPackageRef.java b/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/NpmPackageRef.java index 2bfb4de9..41eecef8 100644 --- a/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/NpmPackageRef.java +++ b/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/NpmPackageRef.java @@ -15,6 +15,7 @@ */ package org.commonjava.atlas.npm.ident.ref; +import com.github.zafarkhaja.semver.ParseException; import com.github.zafarkhaja.semver.Version; import org.commonjava.atlas.npm.ident.util.NpmVersionUtils; @@ -23,6 +24,8 @@ import java.io.ObjectInput; import java.io.ObjectOutput; +import static org.apache.commons.lang.StringUtils.isEmpty; + /** * NpmPackageRef use jsemver Version object. Ref https://github.com/zafarkhaja/jsemver * @@ -33,21 +36,93 @@ public class NpmPackageRef extends NpmProjectRef { private Version version; + private String versionString; + public NpmPackageRef() { } - public NpmPackageRef( String name, Version version ) + public NpmPackageRef( final String name, final Version version ) + { + this( name, version, null ); + } + + public NpmPackageRef( final String name, final String versionString ) + { + this( name, null, versionString ); + } + + NpmPackageRef( final String name, final Version version, final String versionString ) { super( name ); this.version = version; + this.versionString = versionString; + } + + /** + * Parses new instance from a string. The expected format is "[name]:[version]". + * + * @param nv the string to be parsed + * @return parsed package ref + * @throws InvalidNpmRefException when the given string doesn't match the expected format + */ + public static NpmPackageRef parse( final String nv ) + { + final String[] parts = nv.split( ":" ); + if ( ( parts.length < 2 ) || isEmpty( parts[0] ) || isEmpty( parts[1] ) ) + { + throw new InvalidNpmRefException( "NpmPackageRef must contain non-empty name AND version. (Given: '" + nv + + "')" ); + } + + return new NpmPackageRef( parts[0], parts[1] ); + } + + public Version getVersionRaw() + { + return version; } public Version getVersion() { + if ( ( version == null ) && ( versionString != null ) ) + { + version = NpmVersionUtils.valueOf( versionString ); + } return version; } + public String getVersionString() + { + if ( ( versionString == null ) && ( version != null ) ) + { + versionString = version.toString(); + } + return versionString; + } + + public String getVersionStringRaw() + { + return versionString; + } + + public NpmPackageRef selectVersion( final String versionString ) + { + Version version = NpmVersionUtils.valueOf( versionString ); + return selectVersion( version ); + } + + public NpmPackageRef selectVersion( final Version newVersion ) + { + final Version version = getVersion(); + if ( version.equals( newVersion ) ) + { + return this; + } + return new NpmPackageRef( name, newVersion ); + } + + @Override public String toString() { @@ -55,38 +130,72 @@ public String toString() } @Override - public boolean equals( Object o ) + public boolean equals( final Object o ) { if ( this == o ) + { return true; - if ( o == null || getClass() != o.getClass() ) + } + if ( ( o == null ) || ( getClass() != o.getClass() ) ) + { return false; + } if ( !super.equals( o ) ) + { return false; + } - NpmPackageRef that = (NpmPackageRef) o; - - return version.equals( that.version ); + boolean result = true; + NpmPackageRef other = (NpmPackageRef) o; + try + { + if ( getVersion() == null ) + { + if ( other.getVersion() != null ) + { + result = false; + } + } + else if ( !getVersion().equals( other.getVersion() ) ) + { + result = false; + } + } + catch ( final ParseException e ) + { + if ( getVersionString() == null ) + { + if ( other.getVersionString() != null ) + { + result = false; + } + } + else if ( !getVersionString().equals( other.getVersionString() ) ) + { + result = false; + } + } + return result; } @Override public int hashCode() { int result = super.hashCode(); - result = 31 * result + version.hashCode(); + result = ( 31 * result ) + ( ( getVersionString() == null ) ? 0 : getVersionString().hashCode() ); return result; } @Override - public void writeExternal( ObjectOutput objectOutput ) throws IOException + public void writeExternal( final ObjectOutput objectOutput ) throws IOException { objectOutput.writeObject( getName() ); objectOutput.writeObject( version.toString() ); } @Override - public void readExternal( ObjectInput objectInput ) throws IOException, ClassNotFoundException + public void readExternal( final ObjectInput objectInput ) throws IOException, ClassNotFoundException { this.name = (String) objectInput.readObject(); this.version = NpmVersionUtils.valueOf( (String) objectInput.readObject() ); diff --git a/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/NpmProjectRef.java b/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/NpmProjectRef.java index b7cee5f8..c1889811 100644 --- a/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/NpmProjectRef.java +++ b/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/NpmProjectRef.java @@ -22,13 +22,15 @@ */ public class NpmProjectRef implements Serializable { + private static final long serialVersionUID = -1799733486053972932L; + protected String name; public NpmProjectRef() { } - public NpmProjectRef( String name ) + public NpmProjectRef( final String name ) { this.name = name; } @@ -38,13 +40,22 @@ public String getName() return name; } + public NpmProjectRef asNpmProjectRef() + { + return NpmProjectRef.class.equals( getClass() ) ? this : new NpmProjectRef( getName() ); + } + @Override - public boolean equals( Object o ) + public boolean equals( final Object o ) { if ( this == o ) + { return true; + } if ( o == null || getClass() != o.getClass() ) + { return false; + } NpmProjectRef that = (NpmProjectRef) o; From 16874685350326166b40a69ab2c4534a443989ed Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 7 Dec 2018 10:33:32 -0600 Subject: [PATCH 169/240] [maven-release-plugin] prepare release atlas-parent-1.0.1 --- bindings/jackson-identities/pom.xml | 2 +- bindings/pom.xml | 2 +- identities/pom.xml | 2 +- npm-identities/pom.xml | 2 +- pom.xml | 12 ++++++------ relationships-api/pom.xml | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 4e5d3a15..bc96096c 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-bindings-parent - 1.1.0-SNAPSHOT + 1.0.1 atlas-bindings-jackson-identities diff --git a/bindings/pom.xml b/bindings/pom.xml index 73b3fa1e..541f0722 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.0-SNAPSHOT + 1.0.1 atlas-bindings-parent diff --git a/identities/pom.xml b/identities/pom.xml index 8d9409a8..596ca568 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.0-SNAPSHOT + 1.0.1 atlas-identities diff --git a/npm-identities/pom.xml b/npm-identities/pom.xml index 16478fd2..bdb5cadb 100644 --- a/npm-identities/pom.xml +++ b/npm-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.0-SNAPSHOT + 1.0.1 atlas-npm-identities diff --git a/pom.xml b/pom.xml index 8dbf328e..5e7d8bfe 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.atlas atlas-parent - 1.1.0-SNAPSHOT + 1.0.1 pom Atlas :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - HEAD + atlas-parent-1.0.1 @@ -51,17 +51,17 @@ org.commonjava.atlas atlas-identities - 1.1.0-SNAPSHOT + 1.0.1 org.commonjava.atlas atlas-relationships-api - 1.1.0-SNAPSHOT + 1.0.1 org.commonjava.atlas atlas-bindings-jackson-identities - 1.1.0-SNAPSHOT + 1.0.1 org.commonjava.atlas @@ -71,7 +71,7 @@ org.commonjava.atlas atlas-npm-identities - 1.1.0-SNAPSHOT + 1.0.1 com.github.zafarkhaja diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 9e4c19e1..0fab316a 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.0-SNAPSHOT + 1.0.1 atlas-relationships-api From 2b18f4b6a5da66cc745f6f24db5e70f403ed0109 Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 7 Dec 2018 10:33:39 -0600 Subject: [PATCH 170/240] [maven-release-plugin] prepare for next development iteration --- bindings/jackson-identities/pom.xml | 2 +- bindings/pom.xml | 2 +- identities/pom.xml | 2 +- npm-identities/pom.xml | 2 +- pom.xml | 12 ++++++------ relationships-api/pom.xml | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index bc96096c..9158e0f6 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-bindings-parent - 1.0.1 + 1.0.2-SNAPSHOT atlas-bindings-jackson-identities diff --git a/bindings/pom.xml b/bindings/pom.xml index 541f0722..ac210f18 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.0.1 + 1.0.2-SNAPSHOT atlas-bindings-parent diff --git a/identities/pom.xml b/identities/pom.xml index 596ca568..d18ee567 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.0.1 + 1.0.2-SNAPSHOT atlas-identities diff --git a/npm-identities/pom.xml b/npm-identities/pom.xml index bdb5cadb..4fca6c26 100644 --- a/npm-identities/pom.xml +++ b/npm-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.0.1 + 1.0.2-SNAPSHOT atlas-npm-identities diff --git a/pom.xml b/pom.xml index 5e7d8bfe..9d73e3d9 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.atlas atlas-parent - 1.0.1 + 1.0.2-SNAPSHOT pom Atlas :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - atlas-parent-1.0.1 + HEAD @@ -51,17 +51,17 @@ org.commonjava.atlas atlas-identities - 1.0.1 + 1.0.2-SNAPSHOT org.commonjava.atlas atlas-relationships-api - 1.0.1 + 1.0.2-SNAPSHOT org.commonjava.atlas atlas-bindings-jackson-identities - 1.0.1 + 1.0.2-SNAPSHOT org.commonjava.atlas @@ -71,7 +71,7 @@ org.commonjava.atlas atlas-npm-identities - 1.0.1 + 1.0.2-SNAPSHOT com.github.zafarkhaja diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 0fab316a..5d873519 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.0.1 + 1.0.2-SNAPSHOT atlas-relationships-api From 54a2450b4950a965284fec573a53a6ef00a91154 Mon Sep 17 00:00:00 2001 From: Rui Han Date: Tue, 13 Aug 2019 12:59:02 +0800 Subject: [PATCH 171/240] Add Jenkinsfile --- Jenkinsfile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..d72cdaee --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,25 @@ +pipeline { + agent { label 'maven' } + stages { + stage('Prepare') { + steps { + sh 'printenv' + } + } + stage('Build') { + when { + expression { env.CHANGE_ID != null } // Pull request + } + steps { + sh 'mvn -B -V clean verify -Prun-its -Pci' + } + } + stage('Deploy') { + when { branch 'master' } + steps { + echo "Deploy" + sh 'mvn help:effective-settings -B -V clean deploy -e -s ~/sonatype/settings.xml' + } + } + } +} From 768e2971766f65779eb0655ccf49f6dcf34915da Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Fri, 6 Sep 2019 15:33:36 +0200 Subject: [PATCH 172/240] Cleanup dependencyManagement --- pom.xml | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index 9d73e3d9..5d9e3821 100644 --- a/pom.xml +++ b/pom.xml @@ -31,47 +31,42 @@ pom Atlas :: Parent - + scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas HEAD - + Red Hat, Inc. nos-devel@redhat.com true false - + org.commonjava.atlas atlas-identities - 1.0.2-SNAPSHOT + ${project.version} org.commonjava.atlas atlas-relationships-api - 1.0.2-SNAPSHOT + ${project.version} org.commonjava.atlas atlas-bindings-jackson-identities - 1.0.2-SNAPSHOT - - - org.commonjava.atlas - atlas-bindings-jackson-relationships - 0.17.3-SNAPSHOT + ${project.version} org.commonjava.atlas atlas-npm-identities - 1.0.2-SNAPSHOT + ${project.version} com.github.zafarkhaja @@ -106,7 +101,7 @@ logback-classic - + @@ -133,7 +128,7 @@ - + identities npm-identities From cce9d35ff4744b86904c70beea98203bca5b5a81 Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Fri, 6 Sep 2019 15:38:58 +0200 Subject: [PATCH 173/240] Add test reproducing NOS-2039 --- .../atlas/npm/ident/ref/NpmPackageRefTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/npm-identities/src/test/java/org/commonjava/atlas/npm/ident/ref/NpmPackageRefTest.java b/npm-identities/src/test/java/org/commonjava/atlas/npm/ident/ref/NpmPackageRefTest.java index 266a4131..6ce90a71 100644 --- a/npm-identities/src/test/java/org/commonjava/atlas/npm/ident/ref/NpmPackageRefTest.java +++ b/npm-identities/src/test/java/org/commonjava/atlas/npm/ident/ref/NpmPackageRefTest.java @@ -46,6 +46,18 @@ public void pathParseTest() assertTrue( info.getFullPath().equals( path ) ); } + @Test + public void scopedPathParseTest() + { + String path = "/@hawtio/core-dts/-/core-dts-3.3.2.tgz"; + + NpmPackagePathInfo info = NpmPackagePathInfo.parse( path ); + assertTrue( info.getName().equals( "@hawtio/core-dts" ) ); + assertTrue( info.getVersion().toString().equals( "3.3.2" ) ); + assertTrue( info.getFile().equals( "core-dts-3.3.2.tgz" ) ); + assertTrue( info.getFullPath().equals( path ) ); + } + @Test public void versionTest() { From 9929eda3f3225b7d483968d131572b0f26fc9ed8 Mon Sep 17 00:00:00 2001 From: Petr Kocandrle Date: Fri, 6 Sep 2019 15:39:28 +0200 Subject: [PATCH 174/240] NOS-2039 Fix parsing paths of scoped packages --- .../npm/ident/util/NpmPackagePathInfo.java | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/util/NpmPackagePathInfo.java b/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/util/NpmPackagePathInfo.java index 40b698ac..f934674b 100644 --- a/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/util/NpmPackagePathInfo.java +++ b/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/util/NpmPackagePathInfo.java @@ -30,13 +30,26 @@ public class NpmPackagePathInfo implements PathInfo { private static final String EXT_TGZ = ".tgz"; - private static final String PACKAGE_PATH_REGEX = "/(.+)/-/(.+)\\" + EXT_TGZ; + private static final String PACKAGE_PATH_REGEX = "/((?:(.+)/)?(.+))/-/(.+)\\" + EXT_TGZ; - private static final int PACKAGE_NAME_GROUP = 1; + private static final int SCOPED_PACKAGE_NAME_GROUP = 1; - private static final int PACKAGE_NAME_AND_VERSION_GROUP = 2; + private static final int PACKAGE_SCOPE_GROUP = 2; - // e.g., /keycloak-connect/-/keycloak-connect-3.4.1.tgz + private static final int PACKAGE_NAME_GROUP = 3; + + private static final int PACKAGE_NAME_AND_VERSION_GROUP = 4; + + + /** + * Parses an npm package path into fields. The path might be scoped or not. A package metadata path, e.g. + * "/keycloak-connect", cannot be parsed by this method. + * + * @param path + * parsed path starting with '/', e.g. /keycloak-connect/-/keycloak-connect-3.4.1.tgz or + * /@hawtio/core-dts/-/core-dts-3.3.2.tgz + * @return parsed path into an NpmPackagePathInfo instance + */ public static NpmPackagePathInfo parse( final String path ) { final Matcher matcher = Pattern.compile( PACKAGE_PATH_REGEX ).matcher( path.replace( '\\', '/' ) ); @@ -45,14 +58,16 @@ public static NpmPackagePathInfo parse( final String path ) return null; } + final String scopedName = matcher.group( SCOPED_PACKAGE_NAME_GROUP ); final String name = matcher.group( PACKAGE_NAME_GROUP ); final String nameAndVersion = matcher.group( PACKAGE_NAME_AND_VERSION_GROUP ); final String version = nameAndVersion.substring( name.length() + 1 ); - return new NpmPackagePathInfo( name, valueOf( version ), nameAndVersion + EXT_TGZ, path ); + return new NpmPackagePathInfo( scopedName, valueOf( version ), nameAndVersion + EXT_TGZ, path ); } + private String name; private Version version; @@ -61,6 +76,7 @@ public static NpmPackagePathInfo parse( final String path ) private String fullPath; + public NpmPackagePathInfo( String name, Version version, String file, String fullPath ) { this.name = name; @@ -81,6 +97,9 @@ public String getFullPath() return fullPath; } + /** + * @return package name, can be scoped, e.g. @hawtio/core-dts + */ public String getName() { return name; From 5cdd4c9a05e110b8634af2a774fc38e0a62e24b0 Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 6 Sep 2019 09:54:18 -0500 Subject: [PATCH 175/240] upgrade parent pom to remove javadoc linting --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5d9e3821..9451a181 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.commonjava commonjava - 12 + 15 org.commonjava.atlas From 64b31b6c0305b145fc6e4f2cf8c7d860856a4327 Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 6 Sep 2019 09:55:48 -0500 Subject: [PATCH 176/240] [maven-release-plugin] prepare release atlas-parent-1.1.0 --- bindings/jackson-identities/pom.xml | 2 +- bindings/pom.xml | 2 +- identities/pom.xml | 2 +- npm-identities/pom.xml | 2 +- pom.xml | 4 ++-- relationships-api/pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 9158e0f6..a15fd468 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-bindings-parent - 1.0.2-SNAPSHOT + 1.1.0 atlas-bindings-jackson-identities diff --git a/bindings/pom.xml b/bindings/pom.xml index ac210f18..b8c65826 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.0.2-SNAPSHOT + 1.1.0 atlas-bindings-parent diff --git a/identities/pom.xml b/identities/pom.xml index d18ee567..c789b5e1 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.0.2-SNAPSHOT + 1.1.0 atlas-identities diff --git a/npm-identities/pom.xml b/npm-identities/pom.xml index 4fca6c26..8dc220c8 100644 --- a/npm-identities/pom.xml +++ b/npm-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.0.2-SNAPSHOT + 1.1.0 atlas-npm-identities diff --git a/pom.xml b/pom.xml index 9451a181..37a9a495 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.atlas atlas-parent - 1.0.2-SNAPSHOT + 1.1.0 pom Atlas :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - HEAD + atlas-parent-1.1.0 diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 5d873519..b827c848 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.0.2-SNAPSHOT + 1.1.0 atlas-relationships-api From c2a577ed3becf5ca5d7c073f613bcc6d4d7ff287 Mon Sep 17 00:00:00 2001 From: John Casey Date: Fri, 6 Sep 2019 09:55:55 -0500 Subject: [PATCH 177/240] [maven-release-plugin] prepare for next development iteration --- bindings/jackson-identities/pom.xml | 2 +- bindings/pom.xml | 2 +- identities/pom.xml | 2 +- npm-identities/pom.xml | 2 +- pom.xml | 4 ++-- relationships-api/pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index a15fd468..2eaf9e06 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-bindings-parent - 1.1.0 + 1.1.1-SNAPSHOT atlas-bindings-jackson-identities diff --git a/bindings/pom.xml b/bindings/pom.xml index b8c65826..d9db8d22 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.0 + 1.1.1-SNAPSHOT atlas-bindings-parent diff --git a/identities/pom.xml b/identities/pom.xml index c789b5e1..4049fa95 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.0 + 1.1.1-SNAPSHOT atlas-identities diff --git a/npm-identities/pom.xml b/npm-identities/pom.xml index 8dc220c8..0dd578b0 100644 --- a/npm-identities/pom.xml +++ b/npm-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.0 + 1.1.1-SNAPSHOT atlas-npm-identities diff --git a/pom.xml b/pom.xml index 37a9a495..6e65d460 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.atlas atlas-parent - 1.1.0 + 1.1.1-SNAPSHOT pom Atlas :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - atlas-parent-1.1.0 + HEAD diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index b827c848..fceb3fd1 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.0 + 1.1.1-SNAPSHOT atlas-relationships-api From c3d30913ace45fb777edc0af2f349088a659f5d3 Mon Sep 17 00:00:00 2001 From: John Casey Date: Wed, 2 Oct 2019 17:10:25 -0500 Subject: [PATCH 178/240] remove settings specification to use default settings instead --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d72cdaee..d7dcc28b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,7 +18,7 @@ pipeline { when { branch 'master' } steps { echo "Deploy" - sh 'mvn help:effective-settings -B -V clean deploy -e -s ~/sonatype/settings.xml' + sh 'mvn help:effective-settings -B -V clean deploy -e' } } } From 9c7c342b81c9c24a525ded4166553a5a2eb2daad Mon Sep 17 00:00:00 2001 From: John Casey Date: Mon, 14 Oct 2019 16:52:58 -0500 Subject: [PATCH 179/240] update parent pom --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6e65d460..da6e2b56 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.commonjava commonjava - 15 + 16 org.commonjava.atlas From 288d5dcd32323d337ce3921b568ca080f285d377 Mon Sep 17 00:00:00 2001 From: Gang Li Date: Thu, 11 Jun 2020 15:44:02 +0800 Subject: [PATCH 180/240] Fix classifier get error which contains dot Some maven artifact classifier contains dot, for example: showcase-distribution-wars-7.33.0.Final-redhat-00003-wildfly8.1.war. But currently ArtifactInfoPath.parse has error to parse this type of classifier. This commit will fix the problem. --- .../maven/ident/util/ArtifactPathInfo.java | 28 +++++++--- .../ident/util/ArtifactPathInfoTest.java | 55 ++++++++++++++++++- 2 files changed, 74 insertions(+), 9 deletions(-) diff --git a/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java index 1768d687..edc64b34 100644 --- a/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java @@ -26,16 +26,31 @@ public class ArtifactPathInfo implements PathInfo { + private static final String GROUP_REGEX = "(([^/]+/)*[^/]+)"; // group 1~2 + + private static final String ARTIFACT_REGEX = "([^/]+)"; // group 3 + + private static final String VERSION_RAW_REGEX = "(([^/]+)(-SNAPSHOT)?)"; // group 4~6 + + // For classifier, if it contains dot, that means we cannot use a simple pattern which just defined by dot/non-dot way to + // tell, so we must define this strict way like: 1. Starts with several alphabet. 2. Following with several or non dot plus digits + // Here is one example: wildfly8.1.3 + private static final String CLASSIFIER_REGEX = "(-([a-zA-Z]+\\d*(\\.\\d*)*))?"; // group 13~15 + + private static final String TYPE_REGEX = "(\\.(.+))"; // group 16~17 // regex developed at: http://fiddle.re/tvk5 private static final String ARTIFACT_PATH_REGEX = - "\\/?(([^\\/]+\\/)*[^\\/]+)\\/([^\\/]+)\\/(([^\\/]+)(-SNAPSHOT)?)\\/(\\3-((\\4)|(\\5-" - + SnapshotUtils.RAW_REMOTE_SNAPSHOT_PART_PATTERN + "))(-([^.]+))?(\\.(.+)))"; + "/?" + GROUP_REGEX + "/" + ARTIFACT_REGEX + "/" + VERSION_RAW_REGEX + "/(\\3-((\\4)|(\\5-" + + SnapshotUtils.RAW_REMOTE_SNAPSHOT_PART_PATTERN + "))" + CLASSIFIER_REGEX + TYPE_REGEX + ")"; + // RAW_REMOTE_SNAPSHOT_PART_PATTERN contains group 11 & 12 private static final int GROUP_ID_GROUP = 1; private static final int ARTIFACT_ID_GROUP = 3; + private static final int VERSION_RAW_GROUP = 4; + private static final int FILE_GROUP = 7; private static final int VERSION_GROUP = 8; @@ -46,9 +61,9 @@ public class ArtifactPathInfo implements PathInfo private static final int NON_REMOTE_SNAP_TYPE_GROUP = 14; - private static final int REMOTE_SNAP_TYPE_GROUP = 16; + private static final int REMOTE_SNAP_TYPE_GROUP = 17; - private static final int REMOTE_SNAPSHOT_GROUP_COUNT = 16; + private static final int REMOTE_SNAPSHOT_GROUP_COUNT = 17; public static ArtifactPathInfo parse( final String path ) { @@ -129,12 +144,9 @@ public boolean isSnapshot() return isSnapshot; } - private SnapshotPart snapshotInfo; - public synchronized SnapshotPart getSnapshotInfo() { - snapshotInfo = SnapshotUtils.extractSnapshotVersionPart( version ); - return snapshotInfo; + return SnapshotUtils.extractSnapshotVersionPart(version); } public String getGroupId() diff --git a/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java b/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java index bee263ff..ca0ef69c 100644 --- a/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java +++ b/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java @@ -18,7 +18,6 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; -import org.commonjava.atlas.maven.ident.util.ArtifactPathInfo; import org.junit.Test; public class ArtifactPathInfoTest @@ -49,4 +48,58 @@ public void dontMatchNonSnapshotVersion() .isSnapshot(), equalTo( false ) ); } + @Test + public void matchNormalClassifier() + { + String path = "/org/apache/commons/commons-lang3/3.0.0/commons-lang3-3.0.0-test.jar"; + ArtifactPathInfo pathInfo = ArtifactPathInfo.parse( path ); + assertThat( pathInfo.getVersion(), equalTo( "3.0.0" ) ); + assertThat( pathInfo.getClassifier(), equalTo( "test" ) ); + assertThat( pathInfo.getType(), equalTo( "jar" ) ); + + path = "/org/apache/commons/commons-lang3/3.0.0/commons-lang3-3.0.0-test.tar.gz"; + pathInfo = ArtifactPathInfo.parse( path ); + assertThat( pathInfo.getVersion(), equalTo( "3.0.0" ) ); + assertThat( pathInfo.getClassifier(), equalTo( "test" ) ); + assertThat( pathInfo.getType(), equalTo( "tar.gz" ) ); + } + + @Test + public void matchGAWithClassifier() + { + String path = "/org/apache/commons/commons-lang3/3.0.0.GA/commons-lang3-3.0.0.GA-test.jar"; + ArtifactPathInfo pathInfo = ArtifactPathInfo.parse( path ); + assertThat( pathInfo.getVersion(), equalTo( "3.0.0.GA" ) ); + assertThat( pathInfo.getClassifier(), equalTo( "test" ) ); + assertThat( pathInfo.getType(), equalTo( "jar" ) ); + + path = "/org/apache/commons/commons-lang3/3.0.0.GA/commons-lang3-3.0.0.GA-test.tar.gz"; + pathInfo = ArtifactPathInfo.parse( path ); + assertThat( pathInfo.getVersion(), equalTo( "3.0.0.GA" ) ); + assertThat( pathInfo.getClassifier(), equalTo( "test" ) ); + assertThat( pathInfo.getType(), equalTo( "tar.gz" ) ); + } + + @Test + public void matchClassifierWithDot() + { + String path = + "/org/uberfire/showcase-distribution-wars/7.33.0.Final-redhat-00003/showcase-distribution-wars-7.33.0.Final-redhat-00003-wildfly8.1.war"; + ArtifactPathInfo pathInfo = ArtifactPathInfo.parse( path ); + assertThat( pathInfo.getClassifier(), equalTo( "wildfly8.1" ) ); + assertThat( pathInfo.getType(), equalTo( "war" ) ); + + path = + "/org/uberfire/showcase-distribution-wars/7.33.0.Final-redhat-00003/showcase-distribution-wars-7.33.0.Final-redhat-00003-wildfly8.2.3.0.tar.gz"; + pathInfo = ArtifactPathInfo.parse( path ); + assertThat( pathInfo.getClassifier(), equalTo( "wildfly8.2.3.0" ) ); + assertThat( pathInfo.getType(), equalTo( "tar.gz" ) ); + + path = + "/org/uberfire/showcase-distribution-wars/7.33.0.Final-redhat-00003/showcase-distribution-wars-7.33.0.Final-redhat-00003-wildfly.8.2.3.0.tar.gz"; + pathInfo = ArtifactPathInfo.parse( path ); + assertThat( pathInfo.getClassifier(), equalTo( "wildfly.8.2.3.0" ) ); + assertThat( pathInfo.getType(), equalTo( "tar.gz" ) ); + } + } From 238c54e5ab8bcfbd97fc28781a6f10a4b7998c77 Mon Sep 17 00:00:00 2001 From: Rui Han Date: Fri, 28 Aug 2020 13:23:29 +0800 Subject: [PATCH 181/240] Get major version from snapshot --- .../atlas/maven/ident/util/SnapshotUtils.java | 2 +- .../ident/version/part/SnapshotPart.java | 22 +++++++++++++++++++ .../ident/util/ArtifactPathInfoTest.java | 18 +++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/identities/src/main/java/org/commonjava/atlas/maven/ident/util/SnapshotUtils.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/SnapshotUtils.java index 874c7b72..94f16b7c 100644 --- a/identities/src/main/java/org/commonjava/atlas/maven/ident/util/SnapshotUtils.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/SnapshotUtils.java @@ -125,7 +125,7 @@ public static SnapshotPart extractSnapshotVersionPart( final String version ) } else if ( version.endsWith( LOCAL_SNAPSHOT_VERSION_PART ) ) { - part = new SnapshotPart( LOCAL_SNAPSHOT_VERSION_PART ); + part = new SnapshotPart( version ); } return part; diff --git a/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/SnapshotPart.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/SnapshotPart.java index f628af9b..a4f8688e 100644 --- a/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/SnapshotPart.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/SnapshotPart.java @@ -33,11 +33,14 @@ public class SnapshotPart private final String literal; + private final String majorVersion; + public SnapshotPart( final Date timestamp, final int buildNumber, final String literal ) { this.timestamp = timestamp; this.buildNumber = buildNumber; this.literal = literal; + this.majorVersion = calcMajorVersion( literal ); } public SnapshotPart( final String literal ) @@ -55,6 +58,25 @@ public SnapshotPart( final String literal ) } this.literal = literal; + this.majorVersion = calcMajorVersion( literal ); + } + + private String calcMajorVersion( String literal ) + { + if ( literal != null ) + { + int index = literal.indexOf( "-" ); + if ( index > 0 ) + { + return literal.substring( 0, index ); + } + } + return null; + } + + public String getMajorVersion() + { + return majorVersion; } public String getLiteral() diff --git a/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java b/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java index ca0ef69c..a9a2b13e 100644 --- a/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java +++ b/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java @@ -17,9 +17,13 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import org.commonjava.atlas.maven.ident.version.part.SnapshotPart; import org.junit.Test; +import java.text.SimpleDateFormat; + public class ArtifactPathInfoTest { @@ -102,4 +106,18 @@ public void matchClassifierWithDot() assertThat( pathInfo.getType(), equalTo( "tar.gz" ) ); } + @Test + public void testSnapshotPath() + { + final String path = "/org/commonjava/maven/galley/galley-transport-httpclient/0.10.4-SNAPSHOT/galley-transport-httpclient-0.10.4-20160229.212037-2.pom"; + ArtifactPathInfo info = ArtifactPathInfo.parse( path ); + SnapshotPart snap = info.getSnapshotInfo(); + assertTrue( "0.10.4".equals( snap.getMajorVersion() ) ); + assertTrue( snap.isRemoteSnapshot() ); + assertTrue( "0.10.4-20160229.212037-2".equals( snap.getValue() ) ); + assertTrue( "0.10.4-20160229.212037-2".equals( snap.getLiteral() ) ); + assertTrue( snap.getBuildNumber() == 2 ); + assertTrue( "20160229".equals( new SimpleDateFormat( "yyyyMMdd" ).format( snap.getTimestamp() ) ) ); + } + } From 1d0190da14dc844f4be1b97bbe6c609108da9248 Mon Sep 17 00:00:00 2001 From: Rui Han Date: Fri, 28 Aug 2020 13:54:37 +0800 Subject: [PATCH 182/240] Fix the wrong code change --- .../maven/ident/util/ArtifactPathInfo.java | 20 ++++++++++++++++- .../atlas/maven/ident/util/SnapshotUtils.java | 2 +- .../ident/version/part/SnapshotPart.java | 22 ------------------- .../ident/util/ArtifactPathInfoTest.java | 2 +- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java index edc64b34..6bda8d65 100644 --- a/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java @@ -120,6 +120,8 @@ public static ArtifactPathInfo parse( final String path ) private final boolean isSnapshot; + private final String majorVersion; // snapshot major version + public ArtifactPathInfo( final String groupId, final String artifactId, final String version, final String file, final String fullPath ) { @@ -136,7 +138,23 @@ public ArtifactPathInfo( final String groupId, final String artifactId, final St this.type = type; this.file = file; this.fullPath = fullPath; - isSnapshot = SnapshotUtils.isSnapshotVersion( version ); + this.isSnapshot = SnapshotUtils.isSnapshotVersion( version ); + this.majorVersion = calcMajorVersion( version ); + } + + private String calcMajorVersion( String version ) + { + int index = version.indexOf( "-" ); + if ( index > 0 ) + { + return version.substring( 0, index ); + } + return version; + } + + public String getMajorVersion() + { + return majorVersion; } public boolean isSnapshot() diff --git a/identities/src/main/java/org/commonjava/atlas/maven/ident/util/SnapshotUtils.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/SnapshotUtils.java index 94f16b7c..874c7b72 100644 --- a/identities/src/main/java/org/commonjava/atlas/maven/ident/util/SnapshotUtils.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/SnapshotUtils.java @@ -125,7 +125,7 @@ public static SnapshotPart extractSnapshotVersionPart( final String version ) } else if ( version.endsWith( LOCAL_SNAPSHOT_VERSION_PART ) ) { - part = new SnapshotPart( version ); + part = new SnapshotPart( LOCAL_SNAPSHOT_VERSION_PART ); } return part; diff --git a/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/SnapshotPart.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/SnapshotPart.java index a4f8688e..f628af9b 100644 --- a/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/SnapshotPart.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/SnapshotPart.java @@ -33,14 +33,11 @@ public class SnapshotPart private final String literal; - private final String majorVersion; - public SnapshotPart( final Date timestamp, final int buildNumber, final String literal ) { this.timestamp = timestamp; this.buildNumber = buildNumber; this.literal = literal; - this.majorVersion = calcMajorVersion( literal ); } public SnapshotPart( final String literal ) @@ -58,25 +55,6 @@ public SnapshotPart( final String literal ) } this.literal = literal; - this.majorVersion = calcMajorVersion( literal ); - } - - private String calcMajorVersion( String literal ) - { - if ( literal != null ) - { - int index = literal.indexOf( "-" ); - if ( index > 0 ) - { - return literal.substring( 0, index ); - } - } - return null; - } - - public String getMajorVersion() - { - return majorVersion; } public String getLiteral() diff --git a/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java b/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java index a9a2b13e..e5fc0402 100644 --- a/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java +++ b/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java @@ -112,7 +112,7 @@ public void testSnapshotPath() final String path = "/org/commonjava/maven/galley/galley-transport-httpclient/0.10.4-SNAPSHOT/galley-transport-httpclient-0.10.4-20160229.212037-2.pom"; ArtifactPathInfo info = ArtifactPathInfo.parse( path ); SnapshotPart snap = info.getSnapshotInfo(); - assertTrue( "0.10.4".equals( snap.getMajorVersion() ) ); + assertTrue( "0.10.4".equals( info.getMajorVersion() ) ); assertTrue( snap.isRemoteSnapshot() ); assertTrue( "0.10.4-20160229.212037-2".equals( snap.getValue() ) ); assertTrue( "0.10.4-20160229.212037-2".equals( snap.getLiteral() ) ); From 7203a266a9366cc751cb9a75654487714fe2571e Mon Sep 17 00:00:00 2001 From: Rui Han Date: Fri, 28 Aug 2020 17:59:01 +0800 Subject: [PATCH 183/240] Use proper version part name --- .../atlas/maven/ident/util/ArtifactPathInfo.java | 10 +++++----- .../atlas/maven/ident/util/ArtifactPathInfoTest.java | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java index 6bda8d65..eff4192d 100644 --- a/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java @@ -120,7 +120,7 @@ public static ArtifactPathInfo parse( final String path ) private final boolean isSnapshot; - private final String majorVersion; // snapshot major version + private final String releaseVersion; // snapshot major version public ArtifactPathInfo( final String groupId, final String artifactId, final String version, final String file, final String fullPath ) @@ -139,10 +139,10 @@ public ArtifactPathInfo( final String groupId, final String artifactId, final St this.file = file; this.fullPath = fullPath; this.isSnapshot = SnapshotUtils.isSnapshotVersion( version ); - this.majorVersion = calcMajorVersion( version ); + this.releaseVersion = calcReleaseVersion( version ); } - private String calcMajorVersion( String version ) + private String calcReleaseVersion( String version ) { int index = version.indexOf( "-" ); if ( index > 0 ) @@ -152,9 +152,9 @@ private String calcMajorVersion( String version ) return version; } - public String getMajorVersion() + public String getReleaseVersion() { - return majorVersion; + return releaseVersion; } public boolean isSnapshot() diff --git a/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java b/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java index e5fc0402..4bad7bf3 100644 --- a/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java +++ b/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java @@ -112,7 +112,7 @@ public void testSnapshotPath() final String path = "/org/commonjava/maven/galley/galley-transport-httpclient/0.10.4-SNAPSHOT/galley-transport-httpclient-0.10.4-20160229.212037-2.pom"; ArtifactPathInfo info = ArtifactPathInfo.parse( path ); SnapshotPart snap = info.getSnapshotInfo(); - assertTrue( "0.10.4".equals( info.getMajorVersion() ) ); + assertTrue( "0.10.4".equals( info.getReleaseVersion() ) ); assertTrue( snap.isRemoteSnapshot() ); assertTrue( "0.10.4-20160229.212037-2".equals( snap.getValue() ) ); assertTrue( "0.10.4-20160229.212037-2".equals( snap.getLiteral() ) ); From c3d569c3e20cc166c45cf85c35c511ced097a922 Mon Sep 17 00:00:00 2001 From: Rui Han Date: Fri, 28 Aug 2020 18:01:46 +0800 Subject: [PATCH 184/240] delete inproper comment --- .../org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java index eff4192d..c3d73c61 100644 --- a/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java @@ -120,7 +120,7 @@ public static ArtifactPathInfo parse( final String path ) private final boolean isSnapshot; - private final String releaseVersion; // snapshot major version + private final String releaseVersion; public ArtifactPathInfo( final String groupId, final String artifactId, final String version, final String file, final String fullPath ) From 73768e5f986ce0aa31e6811e0c7325a2affea82c Mon Sep 17 00:00:00 2001 From: Jeremy Whiting Date: Wed, 7 Oct 2020 17:34:02 +0100 Subject: [PATCH 185/240] Version bump commons-lang to 3.7. --- identities/pom.xml | 9 ++++++++- .../atlas/maven/ident/ref/SimpleArtifactRef.java | 2 +- .../atlas/maven/ident/ref/SimpleProjectRef.java | 2 +- .../maven/ident/ref/SimpleProjectVersionRef.java | 4 ++-- .../maven/ident/ref/SimpleTypeAndClassifier.java | 2 +- .../maven/ident/ref/SimpleVersionlessArtifactRef.java | 2 +- .../commonjava/atlas/maven/ident/util/JoinString.java | 2 +- .../atlas/maven/ident/version/SingleVersion.java | 2 +- .../ident/version/SingleVersionComparisonsTest.java | 2 +- .../commonjava/atlas/npm/ident/ref/NpmPackageRef.java | 2 +- pom.xml | 11 +++++++---- .../atlas/maven/graph/model/EProjectCycle.java | 2 +- 12 files changed, 26 insertions(+), 16 deletions(-) diff --git a/identities/pom.xml b/identities/pom.xml index 4049fa95..f4239cbb 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -28,7 +28,14 @@ atlas-identities Atlas :: Maven Project-Graph :: Identities Model - + + + + org.apache.commons + commons-lang3 + + + diff --git a/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleArtifactRef.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleArtifactRef.java index 278f6a71..2c73b191 100644 --- a/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleArtifactRef.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleArtifactRef.java @@ -15,7 +15,7 @@ */ package org.commonjava.atlas.maven.ident.ref; -import static org.apache.commons.lang.StringUtils.isEmpty; +import static org.apache.commons.lang3.StringUtils.isEmpty; import java.io.Serializable; diff --git a/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleProjectRef.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleProjectRef.java index 8a04818b..9e70c388 100644 --- a/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleProjectRef.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleProjectRef.java @@ -15,7 +15,7 @@ */ package org.commonjava.atlas.maven.ident.ref; -import static org.apache.commons.lang.StringUtils.isEmpty; +import static org.apache.commons.lang3.StringUtils.isEmpty; /** * Reference to a whole project (or module, in terms of Maven builds). This reference is not specific to a release of the project (see {@link SimpleProjectVersionRef}). diff --git a/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleProjectVersionRef.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleProjectVersionRef.java index c450a5da..620eb0cf 100644 --- a/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleProjectVersionRef.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleProjectVersionRef.java @@ -15,13 +15,13 @@ */ package org.commonjava.atlas.maven.ident.ref; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.commonjava.atlas.maven.ident.util.VersionUtils; import org.commonjava.atlas.maven.ident.version.InvalidVersionSpecificationException; import org.commonjava.atlas.maven.ident.version.SingleVersion; import org.commonjava.atlas.maven.ident.version.VersionSpec; -import static org.apache.commons.lang.StringUtils.isEmpty; +import static org.apache.commons.lang3.StringUtils.isEmpty; /** * Reference to a particular release of a project (or module, in terms of Maven builds). A release may contain many artifacts (see {@link SimpleArtifactRef}). diff --git a/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleTypeAndClassifier.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleTypeAndClassifier.java index 79558be4..0c70ce82 100644 --- a/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleTypeAndClassifier.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleTypeAndClassifier.java @@ -15,7 +15,7 @@ */ package org.commonjava.atlas.maven.ident.ref; -import static org.apache.commons.lang.StringUtils.isEmpty; +import static org.apache.commons.lang3.StringUtils.isEmpty; public class SimpleTypeAndClassifier implements TypeAndClassifier diff --git a/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleVersionlessArtifactRef.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleVersionlessArtifactRef.java index 172f05b4..7a4ecab0 100644 --- a/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleVersionlessArtifactRef.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/ref/SimpleVersionlessArtifactRef.java @@ -15,7 +15,7 @@ */ package org.commonjava.atlas.maven.ident.ref; -import static org.apache.commons.lang.StringUtils.isEmpty; +import static org.apache.commons.lang3.StringUtils.isEmpty; import org.commonjava.atlas.maven.ident.version.InvalidVersionSpecificationException; diff --git a/identities/src/main/java/org/commonjava/atlas/maven/ident/util/JoinString.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/JoinString.java index 5ecfdd1a..37826166 100644 --- a/identities/src/main/java/org/commonjava/atlas/maven/ident/util/JoinString.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/JoinString.java @@ -15,7 +15,7 @@ */ package org.commonjava.atlas.maven.ident.util; -import static org.apache.commons.lang.StringUtils.join; +import static org.apache.commons.lang3.StringUtils.join; import java.util.Arrays; import java.util.Collection; diff --git a/identities/src/main/java/org/commonjava/atlas/maven/ident/version/SingleVersion.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/SingleVersion.java index a9e0d123..974f419b 100644 --- a/identities/src/main/java/org/commonjava/atlas/maven/ident/version/SingleVersion.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/SingleVersion.java @@ -15,7 +15,7 @@ */ package org.commonjava.atlas.maven.ident.version; -import static org.apache.commons.lang.StringUtils.join; +import static org.apache.commons.lang3.StringUtils.join; import java.io.Serializable; import java.util.ArrayList; diff --git a/identities/src/test/java/org/commonjava/atlas/maven/ident/version/SingleVersionComparisonsTest.java b/identities/src/test/java/org/commonjava/atlas/maven/ident/version/SingleVersionComparisonsTest.java index 8ec90473..1c4d47db 100644 --- a/identities/src/test/java/org/commonjava/atlas/maven/ident/version/SingleVersionComparisonsTest.java +++ b/identities/src/test/java/org/commonjava/atlas/maven/ident/version/SingleVersionComparisonsTest.java @@ -34,7 +34,7 @@ * under the License. */ -import static org.apache.commons.lang.StringUtils.join; +import static org.apache.commons.lang3.StringUtils.join; import static org.junit.Assert.fail; import java.text.NumberFormat; diff --git a/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/NpmPackageRef.java b/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/NpmPackageRef.java index 41eecef8..ffbecd81 100644 --- a/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/NpmPackageRef.java +++ b/npm-identities/src/main/java/org/commonjava/atlas/npm/ident/ref/NpmPackageRef.java @@ -24,7 +24,7 @@ import java.io.ObjectInput; import java.io.ObjectOutput; -import static org.apache.commons.lang.StringUtils.isEmpty; +import static org.apache.commons.lang3.StringUtils.isEmpty; /** * NpmPackageRef use jsemver Version object. Ref https://github.com/zafarkhaja/jsemver diff --git a/pom.xml b/pom.xml index da6e2b56..91fe959e 100644 --- a/pom.xml +++ b/pom.xml @@ -44,6 +44,7 @@ nos-devel@redhat.com true false + 3.7 @@ -80,6 +81,11 @@ import pom + + org.apache.commons + commons-lang3 + ${commonslangVersion} + @@ -88,10 +94,7 @@ org.slf4j slf4j-api - - commons-lang - commons-lang - + junit junit diff --git a/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/model/EProjectCycle.java b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/model/EProjectCycle.java index 268ec14d..8273b31f 100644 --- a/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/model/EProjectCycle.java +++ b/relationships-api/src/main/java/org/commonjava/atlas/maven/graph/model/EProjectCycle.java @@ -15,7 +15,7 @@ */ package org.commonjava.atlas.maven.graph.model; -import static org.apache.commons.lang.StringUtils.join; +import static org.apache.commons.lang3.StringUtils.join; import java.util.ArrayList; import java.util.Arrays; From 6e880610d5e905f3ad8bf84cecdc32bec205a1f2 Mon Sep 17 00:00:00 2001 From: Gang Li Date: Wed, 14 Oct 2020 03:56:05 +0000 Subject: [PATCH 186/240] [maven-release-plugin] prepare release atlas-parent-1.1.1 --- bindings/jackson-identities/pom.xml | 2 +- bindings/pom.xml | 2 +- identities/pom.xml | 2 +- npm-identities/pom.xml | 2 +- pom.xml | 4 ++-- relationships-api/pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 2eaf9e06..209e1108 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-bindings-parent - 1.1.1-SNAPSHOT + 1.1.1 atlas-bindings-jackson-identities diff --git a/bindings/pom.xml b/bindings/pom.xml index d9db8d22..10c6c3ab 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.1-SNAPSHOT + 1.1.1 atlas-bindings-parent diff --git a/identities/pom.xml b/identities/pom.xml index f4239cbb..df4b0a12 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.1-SNAPSHOT + 1.1.1 atlas-identities diff --git a/npm-identities/pom.xml b/npm-identities/pom.xml index 0dd578b0..72a4bdab 100644 --- a/npm-identities/pom.xml +++ b/npm-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.1-SNAPSHOT + 1.1.1 atlas-npm-identities diff --git a/pom.xml b/pom.xml index 91fe959e..6845a549 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.atlas atlas-parent - 1.1.1-SNAPSHOT + 1.1.1 pom Atlas :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - HEAD + atlas-parent-1.1.1 diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index fceb3fd1..dffd6040 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.1-SNAPSHOT + 1.1.1 atlas-relationships-api From 06ead641017eae3453fc1ad3b4c16ff4f72f914e Mon Sep 17 00:00:00 2001 From: Gang Li Date: Wed, 14 Oct 2020 03:56:11 +0000 Subject: [PATCH 187/240] [maven-release-plugin] prepare for next development iteration --- bindings/jackson-identities/pom.xml | 2 +- bindings/pom.xml | 2 +- identities/pom.xml | 2 +- npm-identities/pom.xml | 2 +- pom.xml | 4 ++-- relationships-api/pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 209e1108..179a2dad 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-bindings-parent - 1.1.1 + 1.1.2-SNAPSHOT atlas-bindings-jackson-identities diff --git a/bindings/pom.xml b/bindings/pom.xml index 10c6c3ab..30f4c731 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.1 + 1.1.2-SNAPSHOT atlas-bindings-parent diff --git a/identities/pom.xml b/identities/pom.xml index df4b0a12..5d978126 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.1 + 1.1.2-SNAPSHOT atlas-identities diff --git a/npm-identities/pom.xml b/npm-identities/pom.xml index 72a4bdab..bbab6748 100644 --- a/npm-identities/pom.xml +++ b/npm-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.1 + 1.1.2-SNAPSHOT atlas-npm-identities diff --git a/pom.xml b/pom.xml index 6845a549..325f05d6 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.atlas atlas-parent - 1.1.1 + 1.1.2-SNAPSHOT pom Atlas :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/Commonjava/atlas.git scm:git:git@github.com:Commonjava/atlas.git http://github.com/Commonjava/atlas - atlas-parent-1.1.1 + HEAD diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index dffd6040..71b21016 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.1 + 1.1.2-SNAPSHOT atlas-relationships-api From 5d1bea11bce82ab4cd4085894b87a79414aa15da Mon Sep 17 00:00:00 2001 From: Gang Li Date: Sun, 26 Dec 2021 10:34:26 +0800 Subject: [PATCH 188/240] Fix: upgrade web-commons due to logback CVE fix --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 325f05d6..5a7702fa 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,7 @@ org.commonjava.boms web-commons-bom - 24 + 27-SNAPSHOT import pom From 4945a75bf79b66d7cd5885f9f8bbb791b6d338bb Mon Sep 17 00:00:00 2001 From: Ying Ma Date: Thu, 24 Mar 2022 14:01:50 +0800 Subject: [PATCH 189/240] Support + separator in version parser --- .../maven/ident/version/part/VersionPartSeparator.java | 2 +- identities/src/main/javacc/version.jj | 3 +++ .../atlas/maven/ident/version/VersionParserTest.java | 9 +++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/VersionPartSeparator.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/VersionPartSeparator.java index 1a37b827..d200ea32 100644 --- a/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/VersionPartSeparator.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/version/part/VersionPartSeparator.java @@ -18,7 +18,7 @@ public enum VersionPartSeparator { - BLANK( "" ), DASH( "-" ), UNDERSCORE( "_" ), DOT( "." ); + BLANK( "" ), DASH( "-" ), UNDERSCORE( "_" ), DOT( "." ), PLUS("+"); private String rendered; diff --git a/identities/src/main/javacc/version.jj b/identities/src/main/javacc/version.jj index a0ae0b14..d97598fb 100644 --- a/identities/src/main/javacc/version.jj +++ b/identities/src/main/javacc/version.jj @@ -112,6 +112,7 @@ TOKEN: | | | +| | | ) > | @@ -381,6 +382,8 @@ VersionPartSeparator sep = null; {sep = VersionPartSeparator.DOT;} | {sep = VersionPartSeparator.DASH;} +| + {sep = VersionPartSeparator.PLUS;} | {sep = VersionPartSeparator.UNDERSCORE;} ) diff --git a/identities/src/test/java/org/commonjava/atlas/maven/ident/version/VersionParserTest.java b/identities/src/test/java/org/commonjava/atlas/maven/ident/version/VersionParserTest.java index e62c3d79..15f551c5 100644 --- a/identities/src/test/java/org/commonjava/atlas/maven/ident/version/VersionParserTest.java +++ b/identities/src/test/java/org/commonjava/atlas/maven/ident/version/VersionParserTest.java @@ -72,4 +72,13 @@ public void parseSingleVersionWithExtendedDateTimeFormat() System.out.println( parsed ); } + @Test + public void parseSingleVersionWithPlusSeparator() + throws Exception + { + final String version = "9+181-r4173-1"; + final VersionSpec parsed = new VersionParser( version ).parse(); + + System.out.println( parsed ); + } } From 9a26e54a2fb277d8485bce4a5a3ecda494d2ea8a Mon Sep 17 00:00:00 2001 From: shokakucarrier Date: Mon, 28 Mar 2022 07:20:02 +0000 Subject: [PATCH 190/240] Update license header --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 5a7702fa..2bef0478 100644 --- a/pom.xml +++ b/pom.xml @@ -33,8 +33,8 @@ Atlas :: Parent - scm:git:https://github.com/Commonjava/atlas.git - scm:git:git@github.com:Commonjava/atlas.git + scm:git:https://github.com/commonjava/atlas + scm:git:https://github.com/commonjava/atlas http://github.com/Commonjava/atlas HEAD From 9ba58440096a6810590caa8f77d1786689792599 Mon Sep 17 00:00:00 2001 From: shokakucarrier Date: Thu, 14 Apr 2022 10:19:46 +0000 Subject: [PATCH 191/240] [maven-release-plugin] prepare release atlas-1.1.2 --- bindings/jackson-identities/pom.xml | 2 +- bindings/pom.xml | 2 +- identities/pom.xml | 2 +- npm-identities/pom.xml | 2 +- pom.xml | 4 ++-- relationships-api/pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 179a2dad..0971fccc 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-bindings-parent - 1.1.2-SNAPSHOT + 1.1.2 atlas-bindings-jackson-identities diff --git a/bindings/pom.xml b/bindings/pom.xml index 30f4c731..4da04c6b 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.2-SNAPSHOT + 1.1.2 atlas-bindings-parent diff --git a/identities/pom.xml b/identities/pom.xml index 5d978126..1381672b 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.2-SNAPSHOT + 1.1.2 atlas-identities diff --git a/npm-identities/pom.xml b/npm-identities/pom.xml index bbab6748..cb1f5ef0 100644 --- a/npm-identities/pom.xml +++ b/npm-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.2-SNAPSHOT + 1.1.2 atlas-npm-identities diff --git a/pom.xml b/pom.xml index 2bef0478..fac1e2f2 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.atlas atlas-parent - 1.1.2-SNAPSHOT + 1.1.2 pom Atlas :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/commonjava/atlas scm:git:https://github.com/commonjava/atlas http://github.com/Commonjava/atlas - HEAD + atlas-1.1.2 diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 71b21016..8715b017 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.2-SNAPSHOT + 1.1.2 atlas-relationships-api From 01081f67b8d02204b108145c77c5814e07cacbee Mon Sep 17 00:00:00 2001 From: shokakucarrier Date: Thu, 14 Apr 2022 10:19:48 +0000 Subject: [PATCH 192/240] [maven-release-plugin] prepare for next development iteration --- bindings/jackson-identities/pom.xml | 2 +- bindings/pom.xml | 2 +- identities/pom.xml | 2 +- npm-identities/pom.xml | 2 +- pom.xml | 4 ++-- relationships-api/pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 0971fccc..913501a8 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-bindings-parent - 1.1.2 + 1.1.3-SNAPSHOT atlas-bindings-jackson-identities diff --git a/bindings/pom.xml b/bindings/pom.xml index 4da04c6b..d5a03fa7 100644 --- a/bindings/pom.xml +++ b/bindings/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.2 + 1.1.3-SNAPSHOT atlas-bindings-parent diff --git a/identities/pom.xml b/identities/pom.xml index 1381672b..5c54bd49 100644 --- a/identities/pom.xml +++ b/identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.2 + 1.1.3-SNAPSHOT atlas-identities diff --git a/npm-identities/pom.xml b/npm-identities/pom.xml index cb1f5ef0..ee6298db 100644 --- a/npm-identities/pom.xml +++ b/npm-identities/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.2 + 1.1.3-SNAPSHOT atlas-npm-identities diff --git a/pom.xml b/pom.xml index fac1e2f2..ab577894 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.commonjava.atlas atlas-parent - 1.1.2 + 1.1.3-SNAPSHOT pom Atlas :: Parent @@ -36,7 +36,7 @@ scm:git:https://github.com/commonjava/atlas scm:git:https://github.com/commonjava/atlas http://github.com/Commonjava/atlas - atlas-1.1.2 + HEAD diff --git a/relationships-api/pom.xml b/relationships-api/pom.xml index 8715b017..a9ed7d8a 100644 --- a/relationships-api/pom.xml +++ b/relationships-api/pom.xml @@ -22,7 +22,7 @@ org.commonjava.atlas atlas-parent - 1.1.2 + 1.1.3-SNAPSHOT atlas-relationships-api From 4e0daa5cc6822161fdb272d2f57adab87f12e146 Mon Sep 17 00:00:00 2001 From: ruhan Date: Thu, 1 Sep 2022 14:16:36 +0800 Subject: [PATCH 193/240] Fix ArtifactPathInfo parse issue for project-sources.tar.gz --- .../maven/ident/util/ArtifactPathInfo.java | 45 +++++++++---------- .../ident/util/ArtifactPathInfoTest.java | 10 +++++ 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java index c3d73c61..c601d810 100644 --- a/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java +++ b/identities/src/main/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java @@ -32,18 +32,12 @@ public class ArtifactPathInfo implements PathInfo private static final String VERSION_RAW_REGEX = "(([^/]+)(-SNAPSHOT)?)"; // group 4~6 - // For classifier, if it contains dot, that means we cannot use a simple pattern which just defined by dot/non-dot way to - // tell, so we must define this strict way like: 1. Starts with several alphabet. 2. Following with several or non dot plus digits - // Here is one example: wildfly8.1.3 - private static final String CLASSIFIER_REGEX = "(-([a-zA-Z]+\\d*(\\.\\d*)*))?"; // group 13~15 - - private static final String TYPE_REGEX = "(\\.(.+))"; // group 16~17 + private static final String CLASSIFIER_AND_TYPE = "-?(.+)"; // regex developed at: http://fiddle.re/tvk5 private static final String ARTIFACT_PATH_REGEX = "/?" + GROUP_REGEX + "/" + ARTIFACT_REGEX + "/" + VERSION_RAW_REGEX + "/(\\3-((\\4)|(\\5-" - + SnapshotUtils.RAW_REMOTE_SNAPSHOT_PART_PATTERN + "))" + CLASSIFIER_REGEX + TYPE_REGEX + ")"; - // RAW_REMOTE_SNAPSHOT_PART_PATTERN contains group 11 & 12 + + SnapshotUtils.RAW_REMOTE_SNAPSHOT_PART_PATTERN + "))" + CLASSIFIER_AND_TYPE + ")"; private static final int GROUP_ID_GROUP = 1; @@ -55,15 +49,7 @@ public class ArtifactPathInfo implements PathInfo private static final int VERSION_GROUP = 8; - private static final int NON_REMOTE_SNAP_CLASSIFIER_GROUP = 12; - - private static final int REMOTE_SNAP_CLASSIFIER_GROUP = 14; - - private static final int NON_REMOTE_SNAP_TYPE_GROUP = 14; - - private static final int REMOTE_SNAP_TYPE_GROUP = 17; - - private static final int REMOTE_SNAPSHOT_GROUP_COUNT = 17; + private static final String TAR_GZ = "tar.gz"; public static ArtifactPathInfo parse( final String path ) { @@ -80,23 +66,32 @@ public static ArtifactPathInfo parse( final String path ) } final int groupCount = matcher.groupCount(); - final String g = matcher.group( GROUP_ID_GROUP ) .replace( '/', '.' ); final String a = matcher.group( ARTIFACT_ID_GROUP ); final String v = matcher.group( VERSION_GROUP ); - final String c; - final String t; - if ( groupCount == REMOTE_SNAPSHOT_GROUP_COUNT ) + String c = ""; + String t; + + String left = matcher.group( groupCount ); + + // The classifier can contain dots or hyphens, it is hard to separate it from type. e.g, + // wildfly8.1.3.jar, project-sources.tar.gz, etc. We don't have a very solid pattern to match the classifier. + // Here we use the best guess. + if ( left.endsWith( TAR_GZ ) ) { - c = matcher.group( REMOTE_SNAP_CLASSIFIER_GROUP ); - t = matcher.group( REMOTE_SNAP_TYPE_GROUP ); + t = TAR_GZ; } else { - c = matcher.group( NON_REMOTE_SNAP_CLASSIFIER_GROUP ); - t = matcher.group( NON_REMOTE_SNAP_TYPE_GROUP ); + t = left.substring( left.lastIndexOf( "." ) + 1 ); // Otherwise, use the simple file ext as type + } + int extLen = t.length() + 1; // plus len of "." + int leftLen = left.length(); + if ( leftLen > extLen ) + { + c = left.substring( 0, leftLen - extLen ); } final String f = matcher.group( FILE_GROUP ); diff --git a/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java b/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java index 4bad7bf3..5a5cf14d 100644 --- a/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java +++ b/identities/src/test/java/org/commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java @@ -68,6 +68,16 @@ public void matchNormalClassifier() assertThat( pathInfo.getType(), equalTo( "tar.gz" ) ); } + @Test + public void matchNormalClassifier2() + { + String path = "/org/jboss/modules/jboss-modules/1.5.0.Final-temporary-redhat-00033/jboss-modules-1.5.0.Final-temporary-redhat-00033-project-sources.tar.gz"; + ArtifactPathInfo pathInfo = ArtifactPathInfo.parse( path ); + assertThat( pathInfo.getVersion(), equalTo( "1.5.0.Final-temporary-redhat-00033" ) ); + assertThat( pathInfo.getClassifier(), equalTo( "project-sources" ) ); + assertThat( pathInfo.getType(), equalTo( "tar.gz" ) ); + } + @Test public void matchGAWithClassifier() { From 0a8ce0c8201384688f550ed2a360a258f593c160 Mon Sep 17 00:00:00 2001 From: Gang Li Date: Thu, 27 Oct 2022 15:24:43 +0800 Subject: [PATCH 194/240] Update parent to commonjava-17 and web-commons-bom to 27 --- pom.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index ab577894..85feb350 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.commonjava commonjava - 16 + 17 org.commonjava.atlas @@ -49,6 +49,13 @@ + + org.commonjava.boms + web-commons-bom + 27 + import + pom + org.commonjava.atlas atlas-identities @@ -74,13 +81,6 @@ java-semver 0.9.0 - - org.commonjava.boms - web-commons-bom - 27-SNAPSHOT - import - pom - org.apache.commons commons-lang3 From 74c6fd0ed4b84b2c7579810832b23a35675c3659 Mon Sep 17 00:00:00 2001 From: Gang Li Date: Wed, 23 Nov 2022 12:42:18 +0800 Subject: [PATCH 195/240] Update jenkins builder label --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d7dcc28b..61c4af3d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,5 @@ pipeline { - agent { label 'maven' } + agent { label 'maven-36-jdk11' } stages { stage('Prepare') { steps { From 6905836662de35f80d5b311fe29520b8741c401f Mon Sep 17 00:00:00 2001 From: shokakucarrier Date: Wed, 7 Dec 2022 06:59:06 +0000 Subject: [PATCH 196/240] Update license header --- bindings/jackson-identities/pom.xml | 2 +- .../atlas/maven/ident/jackson/ProjectRefDeserializer.java | 2 +- .../atlas/maven/ident/jackson/ProjectRefKeyDeserializer.java | 2 +- .../atlas/maven/ident/jackson/ProjectRefSerializer.java | 2 +- .../maven/ident/jackson/ProjectVersionRefSerializerModule.java | 2 +- .../atlas/maven/ident/jackson/SerializerIdentityUtils.java | 2 +- .../ident/jackson/ProjectVersionRefSerializerModuleTest.java | 2 +- bindings/pom.xml | 2 +- build-order-improvements.txt | 2 +- codestyle.xml | 2 +- identities/pom.xml | 2 +- .../java/org/commonjava/atlas/maven/ident/DependencyScope.java | 2 +- .../org/commonjava/atlas/maven/ident/ScopeTransitivity.java | 2 +- .../java/org/commonjava/atlas/maven/ident/ref/ArtifactRef.java | 2 +- .../commonjava/atlas/maven/ident/ref/InvalidRefException.java | 2 +- .../java/org/commonjava/atlas/maven/ident/ref/ProjectRef.java | 2 +- .../org/commonjava/atlas/maven/ident/ref/ProjectVersionRef.java | 2 +- .../org/commonjava/atlas/maven/ident/ref/SimpleArtifactRef.java | 2 +- .../org/commonjava/atlas/maven/ident/ref/SimpleProjectRef.java | 2 +- .../atlas/maven/ident/ref/SimpleProjectVersionRef.java | 2 +- .../atlas/maven/ident/ref/SimpleTypeAndClassifier.java | 2 +- .../atlas/maven/ident/ref/SimpleVersionlessArtifactRef.java | 2 +- .../org/commonjava/atlas/maven/ident/ref/TypeAndClassifier.java | 2 +- .../java/org/commonjava/atlas/maven/ident/ref/VersionedRef.java | 2 +- .../atlas/maven/ident/ref/VersionlessArtifactRef.java | 2 +- .../org/commonjava/atlas/maven/ident/util/ArtifactPathInfo.java | 2 +- .../atlas/maven/ident/util/ArtifactRefComparator.java | 2 +- .../org/commonjava/atlas/maven/ident/util/IdentityUtils.java | 2 +- .../java/org/commonjava/atlas/maven/ident/util/JoinString.java | 2 +- .../java/org/commonjava/atlas/maven/ident/util/PathInfo.java | 2 +- .../atlas/maven/ident/util/ProjectVersionRefComparator.java | 2 +- .../org/commonjava/atlas/maven/ident/util/SnapshotUtils.java | 2 +- .../org/commonjava/atlas/maven/ident/util/VersionUtils.java | 2 +- .../maven/ident/util/VersionlessArtifactRefComparator.java | 2 +- .../atlas/maven/ident/version/CompoundVersionSpec.java | 2 +- .../ident/version/InvalidVersionSpecificationException.java | 2 +- .../commonjava/atlas/maven/ident/version/MultiVersionSpec.java | 2 +- .../commonjava/atlas/maven/ident/version/RangeVersionSpec.java | 2 +- .../org/commonjava/atlas/maven/ident/version/SingleVersion.java | 2 +- .../org/commonjava/atlas/maven/ident/version/VersionSpec.java | 2 +- .../atlas/maven/ident/version/VersionSpecComparisons.java | 2 +- .../commonjava/atlas/maven/ident/version/part/NumericPart.java | 2 +- .../atlas/maven/ident/version/part/SeparatorPart.java | 2 +- .../commonjava/atlas/maven/ident/version/part/SnapshotPart.java | 2 +- .../commonjava/atlas/maven/ident/version/part/StringPart.java | 2 +- .../commonjava/atlas/maven/ident/version/part/VersionPart.java | 2 +- .../atlas/maven/ident/version/part/VersionPartSeparator.java | 2 +- .../atlas/maven/ident/version/part/VersionPhrase.java | 2 +- identities/src/site/site.xml | 2 +- .../org/commonjava/atlas/maven/ident/ref/ProjectRefTest.java | 2 +- .../commonjava/atlas/maven/ident/ref/ProjectVersionRefTest.java | 2 +- .../commonjava/atlas/maven/ident/ref/SimpleArtifactRefTest.java | 2 +- .../atlas/maven/ident/ref/VersionlessArtifactRefTest.java | 2 +- .../commonjava/atlas/maven/ident/util/ArtifactPathInfoTest.java | 2 +- .../commonjava/atlas/maven/ident/util/SnapshotUtilsTest.java | 2 +- .../atlas/maven/ident/version/SingleVersionComparisonsTest.java | 2 +- .../commonjava/atlas/maven/ident/version/VersionParserTest.java | 2 +- .../commonjava/atlas/maven/ident/version/VersionRangeTest.java | 2 +- .../commonjava/atlas/maven/ident/version/VersionUtilsTest.java | 2 +- .../atlas/maven/ident/version/part/NumericPartTest.java | 2 +- .../atlas/maven/ident/version/part/SnapshotPartTest.java | 2 +- npm-identities/pom.xml | 2 +- .../commonjava/atlas/npm/ident/ref/InvalidNpmRefException.java | 2 +- .../java/org/commonjava/atlas/npm/ident/ref/NpmPackageRef.java | 2 +- .../java/org/commonjava/atlas/npm/ident/ref/NpmProjectRef.java | 2 +- .../org/commonjava/atlas/npm/ident/util/NpmPackagePathInfo.java | 2 +- .../org/commonjava/atlas/npm/ident/util/NpmVersionUtils.java | 2 +- .../org/commonjava/atlas/npm/ident/ref/NpmPackageRefTest.java | 2 +- pom.xml | 2 +- relationships-api/pom.xml | 2 +- .../atlas/maven/graph/jackson/PluginKeyDeserializer.java | 2 +- .../atlas/maven/graph/jackson/PluginKeySerializer.java | 2 +- .../maven/graph/jackson/ProjectRelationshipDeserializer.java | 2 +- .../maven/graph/jackson/ProjectRelationshipSerializer.java | 2 +- .../graph/jackson/ProjectRelationshipSerializerModule.java | 2 +- .../atlas/maven/graph/jackson/SerializationConstants.java | 2 +- .../org/commonjava/atlas/maven/graph/model/EProjectCycle.java | 2 +- .../atlas/maven/graph/model/EProjectDirectRelationships.java | 2 +- .../atlas/maven/graph/model/EProjectRelationshipCollection.java | 2 +- .../java/org/commonjava/atlas/maven/graph/model/PluginKey.java | 2 +- .../maven/graph/rel/AbstractSimpleProjectRelationship.java | 2 +- .../org/commonjava/atlas/maven/graph/rel/BomRelationship.java | 2 +- .../atlas/maven/graph/rel/DependencyRelationship.java | 2 +- .../commonjava/atlas/maven/graph/rel/ExtensionRelationship.java | 2 +- .../commonjava/atlas/maven/graph/rel/ParentRelationship.java | 2 +- .../atlas/maven/graph/rel/PluginDependencyRelationship.java | 2 +- .../commonjava/atlas/maven/graph/rel/PluginRelationship.java | 2 +- .../commonjava/atlas/maven/graph/rel/ProjectRelationship.java | 2 +- .../atlas/maven/graph/rel/RelationshipComparator.java | 2 +- .../commonjava/atlas/maven/graph/rel/RelationshipConstants.java | 2 +- .../atlas/maven/graph/rel/RelationshipPathComparator.java | 2 +- .../org/commonjava/atlas/maven/graph/rel/RelationshipType.java | 2 +- .../commonjava/atlas/maven/graph/rel/SimpleBomRelationship.java | 2 +- .../atlas/maven/graph/rel/SimpleDependencyRelationship.java | 2 +- .../atlas/maven/graph/rel/SimpleExtensionRelationship.java | 2 +- .../atlas/maven/graph/rel/SimpleParentRelationship.java | 2 +- .../maven/graph/rel/SimplePluginDependencyRelationship.java | 2 +- .../atlas/maven/graph/rel/SimplePluginRelationship.java | 2 +- .../commonjava/atlas/maven/graph/util/RelationshipUtils.java | 2 +- relationships-api/src/site/site.xml | 2 +- .../graph/jackson/EProjectRelationshipsSerializerTest.java | 2 +- .../graph/jackson/ProjectRelationshipSerializerModuleTest.java | 2 +- .../atlas/maven/graph/rel/ParentRelationshipTest.java | 2 +- .../atlas/maven/graph/rel/RelationshipComparatorTest.java | 2 +- .../atlas/maven/graph/rel/RelationshipPathComparatorTest.java | 2 +- travis-settings.xml | 2 +- 106 files changed, 106 insertions(+), 106 deletions(-) diff --git a/bindings/jackson-identities/pom.xml b/bindings/jackson-identities/pom.xml index 913501a8..2d56cac9 100644 --- a/bindings/jackson-identities/pom.xml +++ b/bindings/jackson-identities/pom.xml @@ -1,7 +1,7 @@