public boolean contains( final ProjectVersionRef ref ) { for ( final ProjectRelationship<?, ?> rel : relationships ) { if ( rel.getDeclaring() .equals( ref ) ) { return true; } } return false; }
@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; }
@SuppressWarnings( "unchecked" ) private <C extends ProjectRelationship<?, ?>> C adjustDeclaring( final C rel ) { if ( !ref .equals( rel.getDeclaring() ) ) { return (C) rel.cloneFor( ref ); } return rel; }
public static Set<ProjectVersionRef> getKnownChildren( final ProjectVersionRef parent, final RelationshipGraph graph ) throws CartoDataException { final Set<ProjectRelationship<?, ?>> matches = graph.findDirectRelationshipsTo( parent, false, RelationshipType.PARENT ); final Set<ProjectVersionRef> refs = new HashSet<ProjectVersionRef>(); for ( final ProjectRelationship<?, ?> rel : matches ) { refs.add( rel.getDeclaring() ); } return refs; }
public static Set<ProjectVersionRef> getKnownChildren( final ProjectVersionRef parent, final RelationshipGraph graph ) throws CartoDataException { final Set<ProjectRelationship<?, ?>> matches = graph.findDirectRelationshipsTo( parent, false, RelationshipType.PARENT ); final Set<ProjectVersionRef> refs = new HashSet<ProjectVersionRef>(); for ( final ProjectRelationship<?, ?> rel : matches ) { refs.add( rel.getDeclaring() ); } return refs; }
public Set<ProjectVersionRef> getAllParticipatingProjects() { final Set<ProjectVersionRef> refs = new HashSet<ProjectVersionRef>(); for ( final ProjectRelationship<?, ?> rel : relationships ) { refs.add( rel.getDeclaring() ); refs.add( rel.getTarget() .asProjectVersionRef() ); } return refs; }
public boolean hasCycle() { if ( rels.length < 1 ) { return false; } final Set<ProjectVersionRef> declared = new HashSet<ProjectVersionRef>( 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 List<ProjectVersionRef> 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<ProjectVersionRef> refs = new ArrayList<ProjectVersionRef>(); for ( final ProjectRelationship<?, ?> rel : gp ) { if ( refs.isEmpty() ) { refs.add( rel.getDeclaring() ); } refs.add( rel.getTarget() .asProjectVersionRef() ); } return refs; }
public int indexOf( final ProjectVersionRef ref ) { int targetIdx = -1; for ( int i = 0; i < relationships.size(); i++ ) { final ProjectRelationship<?, ?> rel = relationships.get( i ); if ( rel.getDeclaring() .equals( ref ) ) { return i; } // if we find the ref we're after as a TARGET, log it. // if, at the end, we haven't found it as a DECLARING ref, return // the index of the relationship that lists it as a target. if ( targetIdx < 0 && rel.getTarget() .asProjectVersionRef() .equals( ref ) ) { targetIdx = i; } } return targetIdx; }
@Override public boolean preCheck( final ProjectRelationship<?, ?> relationship, final List<ProjectRelationship<?, ?>> 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<ProjectRelationship<?, ?>> cycle = new ArrayList<ProjectRelationship<?, ?>>( path ); cycle.add( rel ); cycles.add( new EProjectCycle( cycle ) ); logger.warn( "CYCLE: {}", join( cycle, ", " ) ); return false; } return true; } }
@Override public void fireStorageEvent( final RelationshipStorageEvent evt ) { final Set<ProjectVersionRef> refs = new HashSet<ProjectVersionRef>(); final Collection<? extends ProjectRelationship<?, ?>> stored = evt.getStored(); if ( stored != null ) { for ( final ProjectRelationship<?, ?> rel : stored ) { refs.add( rel.getDeclaring().asProjectVersionRef() ); } } final Collection<ProjectRelationship<?, ?>> rejected = evt.getRejected(); if ( rejected != null ) { for ( final ProjectRelationship<?, ?> rel : rejected ) { refs.add( rel.getDeclaring().asProjectVersionRef() ); } } for ( final ProjectVersionRef ref : refs ) { logger.debug( "Unlocking {} due to new relationships available.", ref ); notifyOfGraph( ref ); } }
public static Set<ArtifactRef> collectArtifactReferences( final Collection<ProjectRelationship<?, ?>> rels, final boolean includePomArtifacts ) { final Set<ArtifactRef> artifacts = new HashSet<ArtifactRef>(); for ( final ProjectRelationship<?, ?> rel : rels ) { // if ( !( rel instanceof DependencyRelationship ) ) // { // continue; // } if ( includePomArtifacts ) { final ProjectVersionRef pvr = rel.getDeclaring() .asProjectVersionRef(); artifacts.add( pvr.asPomArtifact() ); } final ArtifactRef tar = rel.getTargetArtifact(); artifacts.add( tar ); if ( includePomArtifacts ) { artifacts.add( tar.asPomArtifact() ); } } return artifacts; }
public static Set<ArtifactRef> collectArtifactReferences( final Collection<ProjectRelationship<?, ?>> rels, final boolean includePomArtifacts ) { final Set<ArtifactRef> artifacts = new HashSet<ArtifactRef>(); for ( final ProjectRelationship<?, ?> rel : rels ) { // if ( !( rel instanceof DependencyRelationship ) ) // { // continue; // } if ( includePomArtifacts ) { final ProjectVersionRef pvr = rel.getDeclaring() .asProjectVersionRef(); artifacts.add( pvr.asPomArtifact() ); } final ArtifactRef tar = rel.getTargetArtifact(); artifacts.add( tar ); if ( includePomArtifacts ) { artifacts.add( tar.asPomArtifact() ); } } return artifacts; }
refs.add( rel.getDeclaring() );
final ProjectVersionRef pvr = rel.getDeclaring() .asProjectVersionRef();
@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(); }
int res = one.getDeclaring().compareTo( two.getDeclaring() ); if ( res == 0 )
@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<ProjectRelationship<?, ?>> 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; }
public AbstractSimpleProjectRelationship( final ProjectRelationship<R, T> 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() ); }
private GAVDependencyTree generateGAVDependencyTree(GraphExport export, GAV rootGAV) { // keep a map of gav -> GAVDependencyTree object Map<GAV, GAVDependencyTree> gavMapper = new HashMap<>(); // create the root GAVDependencyTree and return it GAVDependencyTree root = new GAVDependencyTree(rootGAV); gavMapper.put(rootGAV, root); for (ProjectRelationship<?, ?> rel : export.getRelationships()) { if (rel.getType().equals(RelationshipType.DEPENDENCY)) { ProjectVersionRef declaring = rel.getDeclaring(); ProjectVersionRef dependencyArtifact = rel.getTargetArtifact(); GAV declaringGAV = generateGAV(declaring); GAV dependencyGAV = generateGAV(dependencyArtifact); GAVDependencyTree declaringDT = addGAVDependencyTreeToGAVMapper(gavMapper, declaringGAV); GAVDependencyTree dependencyDT = addGAVDependencyTreeToGAVMapper(gavMapper, dependencyGAV); // set the dependency relationship between GAVDependencyTree here declaringDT.addDependency(dependencyDT); } } return root; }