public void addEdge( final String from, final String to ) throws CycleDetectedException { final Vertex v1 = addVertex( from ); final Vertex v2 = addVertex( to ); addEdge( v1, v2 ); }
private void addEdgeWithParentCheck( Map projectMap, String projectRefId, MavenProject project, String id ) throws CycleDetectedException { MavenProject extProject = (MavenProject) projectMap.get( projectRefId ); if ( extProject == null ) { return; } project.addProjectReference( extProject ); MavenProject extParent = extProject.getParent(); if ( extParent != null ) { String parentId = ArtifactUtils.versionlessKey( extParent.getGroupId(), extParent.getArtifactId() ); // Don't add edge from parent to extension if a reverse edge already exists if ( !dag.hasEdge( projectRefId, id ) || !parentId.equals( id ) ) { dag.addEdge( id, projectRefId ); } } }
private void addEdge( Vertex fromVertex, Vertex toVertex, MavenProject fromProject, Map<String, MavenProject> projectMap, boolean force, boolean safe ) throws CycleDetectedException { if ( fromVertex.equals( toVertex ) ) { return; } if ( fromProject != null ) { MavenProject toProject = projectMap.get( toVertex.getLabel() ); fromProject.addProjectReference( toProject ); } if ( force && toVertex.getChildren().contains( fromVertex ) ) { dag.removeEdge( toVertex, fromVertex ); } try { dag.addEdge( fromVertex, toVertex ); } catch ( CycleDetectedException e ) { if ( !safe ) { throw e; } } }
public void addComponentDescriptor( ComponentDescriptor<?> componentDescriptor ) throws CycleDetectedInComponentGraphException { String key = getDAGKey( componentDescriptor.getRole(), componentDescriptor.getRoleHint() ); List<ComponentRequirement> requirements = componentDescriptor.getRequirements(); for ( ComponentRequirement requirement : requirements ) { try { if ( requirement instanceof ComponentRequirementList ) { for ( String hint : ( (ComponentRequirementList) requirement ).getRoleHints() ) { dag.addEdge( key, getDAGKey( requirement.getRole(), hint ) ); } } else { dag.addEdge( key, getDAGKey( requirement.getRole(), requirement.getRoleHint() ) ); } } catch ( CycleDetectedException e ) { throw new CycleDetectedInComponentGraphException( "Cyclic requirement detected", e ); } } }
protected Map<String, Resource> getSubResources(DAG graph, Resource r, String type) { Map<String, Resource> res = new HashMap<>(); List<String> deps = r.getDependencies(); if (deps != null) { for (String dn : deps) { Resource d = getResource(dn); if (d == null) { log.error("Unknown resource dependency named '" + dn + "'"); continue; } if (!ResourceType.matches(type, d)) { continue; } res.put(dn, d); try { graph.addEdge(r.getName(), dn); } catch (CycleDetectedException e) { log.error("Cycle detected in resource dependencies: ", e); break; } res.putAll(getSubResources(graph, d, type)); } } return res; }
dag.addEdge( creator.getId(), depId );
dag.addEdge( creator.getId(), depId );
dag.addEdge( creator.getId(), depId );
public void addComponentDescriptor( ComponentDescriptor componentDescriptor ) throws CompositionException { String key = getDAGKey( componentDescriptor.getRole(), componentDescriptor.getRoleHint() ); List requirements = componentDescriptor.getRequirements(); for ( Iterator iterator = requirements.iterator(); iterator.hasNext(); ) { ComponentRequirement requirement = (ComponentRequirement) iterator.next(); try { if ( requirement instanceof ComponentRequirementList ) { Iterator iter = ( (ComponentRequirementList) requirement ).getRoleHints().iterator(); while (iter.hasNext()) { String hint = (String) iter.next(); dag.addEdge( key, getDAGKey( requirement.getRole(), hint ) ); } } else { dag.addEdge( key, getDAGKey( requirement.getRole(), requirement.getRoleHint() ) ); } } catch ( CycleDetectedException e ) { throw new CompositionException( "Cyclic requirement detected", e ); } } }
name = dep.getName(); graph.addEdge(def.getName(), name);
@SuppressWarnings( "unchecked" ) public static DAG generateRoleGraph( RedbackRoleModel model ) throws CycleDetectedException { DAG roleGraph = new DAG(); for ( ModelApplication application : model.getApplications() ) { for ( ModelRole role : application.getRoles() ) { roleGraph.addVertex( role.getId() ); if ( role.getChildRoles() != null ) { for ( String childRole : role.getChildRoles() ) { roleGraph.addVertex( childRole ); roleGraph.addEdge( role.getId(), childRole ); } } if ( role.getParentRoles() != null ) { for ( String parentRole : role.getParentRoles() ) { roleGraph.addVertex( parentRole ); roleGraph.addEdge( parentRole, role.getId() ); } } } } return roleGraph; }
@SuppressWarnings( "unchecked" ) public static DAG generateRoleGraph( RedbackRoleModel model ) throws CycleDetectedException { DAG roleGraph = new DAG(); for ( ModelApplication application : (List<ModelApplication>) model.getApplications() ) { for ( ModelRole role : (List<ModelRole>) application.getRoles() ) { roleGraph.addVertex( role.getId() ); if ( role.getChildRoles() != null ) { for ( String childRole : (List<String>) role.getChildRoles() ) { roleGraph.addVertex( childRole ); roleGraph.addEdge( role.getId(), childRole ); } } if ( role.getParentRoles() != null ) { for ( String parentRole : (List<String>) role.getParentRoles() ) { roleGraph.addVertex( parentRole ); roleGraph.addEdge( parentRole, role.getId() ); } } } } return roleGraph; }