private void addDependencyToGraph ( final DbDependency dependency , final AbstractGraph graph , final int depth , final String parentId ) { // In that case of Axway artifact we will add a module to the graph if ( filters . getCorporateFilter ( ) . filter ( dependency ) ) { final DbModule dbTarget = repoHandler . getModuleOf ( dependency . getTarget ( ) ) ; // if there is no module, add the artifact to the graph if ( dbTarget == null ) { LOG . error ( "Got missing reference: " + dependency . getTarget ( ) ) ; final DbArtifact dbArtifact = DataUtils . createDbArtifact ( dependency . getTarget ( ) ) ; final String targetElementId = graph . getId ( dbArtifact ) ; graph . addElement ( targetElementId , dbArtifact . getVersion ( ) , false ) ; graph . addDependency ( parentId , targetElementId , dependency . getScope ( ) ) ; return ; } // Add the element to the graph addModuleToGraph ( dbTarget , graph , depth + 1 ) ; //Add the dependency to the graph final String moduleElementId = graph . getId ( dbTarget ) ; graph . addDependency ( parentId , moduleElementId , dependency . getScope ( ) ) ; } // In case a third-party we will add an artifact else { final DbArtifact dbTarget = repoHandler . getArtifact ( dependency . getTarget ( ) ) ; if ( dbTarget == null ) { LOG . error ( "Got missing artifact: " + dependency . getTarget ( ) ) ; return ; } if ( ! graph . isTreated ( graph . getId ( dbTarget ) ) ) { final ModelMapper modelMapper = new ModelMapper ( repoHandler ) ; final Artifact target = modelMapper . getArtifact ( dbTarget ) ; final String targetElementId = graph . getId ( target ) ; graph . addElement ( targetElementId , target . getVersion ( ) , false ) ; graph . addDependency ( parentId , targetElementId , dependency . getScope ( ) ) ; } } }
Add a dependency to the graph