@Override public boolean containsProject( final ViewParams params, final ProjectVersionRef ref ) { return graph.containsVertex( ref.asProjectVersionRef() ) && !incompleteSubgraphs.contains( ref.asProjectVersionRef() ); }
private synchronized void addMetadataOwner( final String key, final ProjectVersionRef ref ) { Set<ProjectVersionRef> owners = this.metadataOwners.get( key ); if ( owners == null ) { owners = new HashSet<ProjectVersionRef>(); metadataOwners.put( key, owners ); } owners.add( ref.asProjectVersionRef() ); }
@Override public boolean isMissing( final ViewParams params, final ProjectVersionRef project ) { return !graph.containsVertex( project.asProjectVersionRef() ); }
@Override public void addDisconnectedProject( final ProjectVersionRef ref ) { if ( !graph.containsVertex( ref.asProjectVersionRef() ) ) { graph.addVertex( ref.asProjectVersionRef() ); } }
@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 addMetadata( final ProjectVersionRef ref, final String key, final String value ) { if ( StringUtils.isEmpty( key ) || StringUtils.isEmpty( value ) ) { return; } final Map<String, String> md = getMetadata( ref.asProjectVersionRef() ); md.put( key, value ); addMetadataOwner( key, ref.asProjectVersionRef() ); }
@Override public void setMetadata( final ProjectVersionRef ref, final Map<String, String> metadata ) { if ( metadata == null || metadata.isEmpty() ) { return; } final Map<String, String> md = getMetadata( ref.asProjectVersionRef() ); md.putAll( metadata ); }
public ProjectVersionRef getTargetGAV() { if ( root != null ) { return root; } else if ( rels.length > 0 ) { return rels[rels.length - 1].getTarget() .asProjectVersionRef(); } return null; }
@Override public synchronized void reindex() throws RelationshipGraphConnectionException { for ( final Map.Entry<ProjectVersionRef, Map<String, String>> refEntry : metadata.entrySet() ) { for ( final Map.Entry<String, String> mdEntry : refEntry.getValue() .entrySet() ) { addMetadataOwner( mdEntry.getKey(), refEntry.getKey() .asProjectVersionRef() ); } } }
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 void restrictProjectMembership( final Collection<ProjectVersionRef> refs ) { final Set<ProjectRelationship<?, ?>> rels = new HashSet<ProjectRelationship<?, ?>>(); for ( final ProjectVersionRef ref : refs ) { final Collection<ProjectRelationship<?, ?>> edges = graph.getOutEdges( ref.asProjectVersionRef() ); if ( edges != null ) { rels.addAll( edges ); } } restrictRelationshipMembership( rels ); }
@Override public void deleteRelationshipsDeclaredBy( final ProjectVersionRef ref ) throws RelationshipGraphConnectionException { final Collection<ProjectRelationship<?, ?>> edges = graph.getOutEdges( ref.asProjectVersionRef() ); if ( edges != null ) { for ( final ProjectRelationship<?, ?> rel : edges ) { graph.removeEdge( rel ); } } incompleteSubgraphs.add( ref ); }
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 Collection<? extends ProjectRelationship<?, ?>> getRelationshipsTargeting( final ViewParams params, final ProjectVersionRef ref ) { return imposeSelections( params, graph.getInEdges( ref.asProjectVersionRef() ) ); }
@Override public Collection<? extends ProjectRelationship<?, ?>> getRelationshipsDeclaredBy( final ViewParams params, final ProjectVersionRef ref ) { return imposeSelections( params, graph.getOutEdges( ref.asProjectVersionRef() ) ); }
private List<ProjectRelationship<?, ?>> getSortedOutEdges( final ViewParams params, final ProjectVersionRef node ) { Collection<ProjectRelationship<?, ?>> unsorted = graph.getOutEdges( node.asProjectVersionRef() ); if ( unsorted == null ) { return null; } unsorted = new ArrayList<ProjectRelationship<?, ?>>( unsorted ); RelationshipUtils.filterTerminalParents( unsorted ); final List<ProjectRelationship<?, ?>> sorted = new ArrayList<ProjectRelationship<?, ?>>( imposeSelections( params, unsorted ) ); Collections.sort( sorted, RelationshipComparator.INSTANCE ); return sorted; }
@Override public Set<ProjectRelationship<?, ?>> 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 ); }
@Override public Set<ProjectRelationship<?, ?>> 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 boolean introducesCycle( final ViewParams params, final ProjectRelationship<?, ?> rel ) { final CycleDetectionTraversal traversal = new CycleDetectionTraversal( rel ); dfsTraverse( params, traversal, rel.getTarget() .asProjectVersionRef() ); return !traversal.getCycles() .isEmpty(); }
protected Node getNode( final ProjectVersionRef ref ) { checkClosed(); final Index<Node> idx = graph.index() .forNodes( BY_GAV_IDX ); final IndexHits<Node> hits = idx.get( GAV, ref.asProjectVersionRef() .toString() ); if ( hits.size() < 1 ) { return null; } final Node node = hits.next(); return node; }