@SuppressWarnings("unchecked") public static synchronized void copyDataBase(IDataBase sourceDataBase, IDataBase targetDataBase) { Collector.initialize(targetDataBase); List<Package> sourcePackages = sourceDataBase.find(Package.class); for (Package sourcePackage : sourcePackages) { List<Class> sourceClasses = sourcePackage.getChildren(); for (Class sourceClass : sourceClasses) { Collector.collectAccess(sourceClass.getName(), sourceClass.getAccess()); collectEfferentAndAfferent(sourceClass, sourcePackages); List<Class> sourceInnerClasses = sourceClass.getInnerClasses(); for (Class sourceInnerClass : sourceInnerClasses) { Collector.collectInnerClass(sourceInnerClass.getName(), sourceClass.getName()); Method sourceOuterMethod = sourceClass.getOuterMethod(); if (sourceOuterMethod != null) { Collector.collectOuterClass( sourceInnerClass.getName(), sourceClass.getName(), sourceOuterMethod.getName(), sourceOuterMethod.getDescription()); } } // Collector.collectSource(sourceClass.getName(), "source"); List<Method> sourceMethods = sourceClass.getChildren(); for (Method sourceMethod : sourceMethods) { Collector.collectComplexity( sourceClass.getName(), sourceMethod.getName(), sourceMethod.getDescription(), sourceMethod.getComplexity()); Collector.collectAccess( sourceClass.getName(), sourceMethod.getName(), sourceMethod.getDescription(), sourceMethod.getAccess()); List<Line> sourceLines = sourceMethod.getChildren(); for (Line sourceLine : sourceLines) { Collector.collectLine( sourceClass.getName(), sourceMethod.getName(), sourceMethod.getDescription(), Integer.valueOf((int) sourceLine.getNumber())); for (int i = 0; i < sourceLine.getCounter(); i++) { Collector.collectCoverage( sourceClass.getName(), sourceMethod.getName(), sourceMethod.getDescription(), (int) sourceLine.getNumber()); } } } } } }
@SuppressWarnings("unchecked") private static synchronized void collectEfferentAndAfferent(Class klass, List<Package> packages) { List<Efferent> efferents = klass.getEfferent(); for (Efferent efferent : efferents) { String efferentPackage = Toolkit.replaceAll(efferent.getName(), "<e:", ""); efferentPackage = Toolkit.replaceAll(efferent.getName(), ">", ""); for (Package pakkage : packages) { List<Class> children = pakkage.getChildren(); for (Class child : children) { List<Afferent> afferents = child.getAfferent(); for (Afferent afferent : afferents) { String afferentPackage = Toolkit.replaceAll(afferent.getName(), "<a:", ""); afferentPackage = Toolkit.replaceAll(afferent.getName(), ">", ""); if (efferentPackage.equals(afferentPackage)) { Collector.collectEfferentAndAfferent(klass.getName(), child.getName()); } } } } } }