diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/adopters/CombineClass2Reference.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/adopters/CombineClass2Reference.java index fbbbfcb6f7bd7077b7a04ba0be6dcc0e2af7dd32..a26b84d72eee4aa6cb99cf21e3946f729364b7db 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/adopters/CombineClass2Reference.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/adopters/CombineClass2Reference.java @@ -18,6 +18,7 @@ import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.Writer; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; @@ -52,11 +53,15 @@ public class CombineClass2Reference extends ComponentTeamScanner implements IOut public static final String ARG_SOURCE = "src"; //$NON-NLS-1$ public static final String ARG_OUTPUT = "output"; //$NON-NLS-1$ public static final String ARG_API = "api"; //$NON-NLS-1$ + public static final String ARG_SHOW_ADOPTER_NUMBERS = "showAdopterNumbers"; //$NON-NLS-1$ // Instance variables for command line arguments private Collection src; private String output; private Collection api; + private boolean shouldShowIndividualAdopters = false; + + private List contactNames; // Class variables for String values private static final String CLASS_CVS_FILE_EXTENSION = ".class.csv"; //$NON-NLS-1$ @@ -86,6 +91,23 @@ public class CombineClass2Reference extends ComponentTeamScanner implements IOut * Internal or other non API usages outside API contract */ public int nonAPIUse = 0; + + private HashMap nestedUsageCounts; + + public HashMap getNestedUsageCounts() { + if (nestedUsageCounts==null) + nestedUsageCounts = new HashMap(); + return nestedUsageCounts; + } + + public UsageCount getNestedUsageCount(String contactInfo) { + UsageCount usageCount = (UsageCount) getNestedUsageCounts().get(contactInfo); + if (usageCount == null) { + usageCount = new UsageCount(); + getNestedUsageCounts().put(contactInfo, usageCount); + } + return usageCount; + } } /** @@ -188,6 +210,9 @@ public class CombineClass2Reference extends ComponentTeamScanner implements IOut // Create a references object to parse the usage.xml file and cache the references References refs = new References(); refs.load(fis); + String currentContactName = refs.getContactInfo(); + if (isShouldShowIndividualAdopters()) + cacheContactName(currentContactName); // Iterate through the list of plugins referenced in usage.xml file for (Iterator it2 = refs.getPluginRefs().iterator(); it2.hasNext();) { PluginRef pluginRef = (PluginRef)it2.next(); @@ -200,7 +225,7 @@ public class CombineClass2Reference extends ComponentTeamScanner implements IOut for (Iterator it3 = pluginRef.getClassRefs().iterator(); it3.hasNext();) { ClassRef classRef = (ClassRef)it3.next(); // Update the component team's cached reference counts with the current class reference - updateComponentTeamUsageCounts(compTeam,compXML,classRef,pluginId); + updateComponentTeamUsageCounts(compTeam,compXML,classRef,pluginId,currentContactName); } } } catch (Throwable t) { @@ -216,6 +241,17 @@ public class CombineClass2Reference extends ComponentTeamScanner implements IOut } } + private void cacheContactName(String aContactName) { + if (!getContactNames().contains(aContactName)) + getContactNames().add(aContactName); + } + + private List getContactNames() { + if (contactNames == null) + contactNames = new ArrayList(); + return contactNames; + } + /** * The execute method drives the combination operation by collecting component.xml files * from the "api" command line arugment, processing references in usage.xml files from the @@ -256,7 +292,7 @@ public class CombineClass2Reference extends ComponentTeamScanner implements IOut * @param classRef * @param pluginId */ - private void updateComponentTeamUsageCounts(ComponentTeam compTeam, ComponentXML compXML, ClassRef classRef, String pluginId) { + private void updateComponentTeamUsageCounts(ComponentTeam compTeam, ComponentXML compXML, ClassRef classRef, String pluginId, String contactInfo) { String name = classRef.getName(); String pkgName = getPackageName(name); // Get the usage count object for the current referenced class @@ -265,27 +301,42 @@ public class CombineClass2Reference extends ComponentTeamScanner implements IOut UsageCount classUsageCount = (UsageCount)compTeam.getClassReferenceCounts().get(name); if (classUsageCount == null) classUsageCount = new UsageCount(); + UsageCount nestedClassUsageCount = classUsageCount.getNestedUsageCount(contactInfo); // Update the component team's cached class usage count with the current usage count classUsageCount.apiUse += usageCount.apiUse; classUsageCount.nonAPIUse += usageCount.nonAPIUse; + nestedClassUsageCount.apiUse += usageCount.apiUse; + nestedClassUsageCount.nonAPIUse += usageCount.nonAPIUse; + // Put the updated nested class Usage count back into the cache + classUsageCount.getNestedUsageCounts().put(contactInfo, nestedClassUsageCount); // Put the updated class Usage count back into the cache on the component team compTeam.getClassReferenceCounts().put(name, classUsageCount); // Get the component team's cached package reference usage count UsageCount pkgUsageCount = (UsageCount)compTeam.getPackageReferenceCounts().get(pkgName); if (pkgUsageCount == null) pkgUsageCount = new UsageCount(); + UsageCount nestedPkgUsageCount = pkgUsageCount.getNestedUsageCount(contactInfo); // Update the component team's cached package reference count with current usage count pkgUsageCount.apiUse += usageCount.apiUse; pkgUsageCount.nonAPIUse += usageCount.nonAPIUse; + nestedPkgUsageCount.apiUse += usageCount.apiUse; + nestedPkgUsageCount.nonAPIUse += usageCount.nonAPIUse; + // Put the updated nested package usage count back into the cache + pkgUsageCount.getNestedUsageCounts().put(contactInfo, nestedPkgUsageCount); // Put the updated package usage count back into the cache on the component team compTeam.getPackageReferenceCounts().put(pkgName, pkgUsageCount); // Get the component team's cached plugin reference usage count UsageCount pluginUsageCount = (UsageCount)compTeam.getPluginReferenceCounts().get(pluginId); if (pluginUsageCount == null) pluginUsageCount = new UsageCount(); + UsageCount nestedPluginUsageCount = pluginUsageCount.getNestedUsageCount(contactInfo); // Update the component team's cached plugin reference count with current usage count pluginUsageCount.apiUse += usageCount.apiUse; pluginUsageCount.nonAPIUse += usageCount.nonAPIUse; + nestedPluginUsageCount.apiUse += usageCount.apiUse; + nestedPluginUsageCount.nonAPIUse += usageCount.nonAPIUse; + // Put the update nested plugin usage count back into the cache + pluginUsageCount.getNestedUsageCounts().put(contactInfo, nestedPluginUsageCount); // Put the update plugin usage count back into the cache on the component team compTeam.getPluginReferenceCounts().put(pluginId, pluginUsageCount); } @@ -522,6 +573,12 @@ public class CombineClass2Reference extends ComponentTeamScanner implements IOut baos.write("<team lead=\"".getBytes()); //$NON-NLS-1$ baos.write(compTeam.getTeamName().getBytes()); baos.write("\">".getBytes()); //$NON-NLS-1$ + for (Iterator nestedKeys = getContactNames().iterator(); nestedKeys.hasNext();) { + String currentKey = (String) nestedKeys.next(); + baos.write("<source name=\"".getBytes()); //$NON-NLS-1$ + baos.write(currentKey.getBytes()); + baos.write("\"/>".getBytes()); //$NON-NLS-1$ + } writeCompTeamXML(baos,CLASS_USAGE,compTeam.getClassReferenceCounts()); writeCompTeamXML(baos,PACKAGE_USAGE,compTeam.getPackageReferenceCounts()); writeCompTeamXML(baos,PLUGIN_USAGE,compTeam.getPluginReferenceCounts()); @@ -566,7 +623,34 @@ public class CombineClass2Reference extends ComponentTeamScanner implements IOut baos.write(String.valueOf(usageCount.apiUse).getBytes()); baos.write("\" internal=\"".getBytes()); //$NON-NLS-1$ baos.write(String.valueOf(usageCount.nonAPIUse).getBytes()); - baos.write("\"/>".getBytes()); //$NON-NLS-1$ + baos.write("\">".getBytes()); //$NON-NLS-1$ + for (Iterator nestedKeys = getContactNames().iterator(); nestedKeys.hasNext();) { + String currentKey = (String) nestedKeys.next(); + UsageCount nestedCount = usageCount.getNestedUsageCount(currentKey); + // Add nested usages for each source + baos.write("<source name=\"".getBytes()); //$NON-NLS-1$ + baos.write(currentKey.getBytes()); + baos.write("\" api=\"".getBytes()); //$NON-NLS-1$ + baos.write(String.valueOf(nestedCount.apiUse).getBytes()); + baos.write("\" internal=\"".getBytes()); //$NON-NLS-1$ + baos.write(String.valueOf(nestedCount.nonAPIUse).getBytes()); + baos.write("\"/>".getBytes()); //$NON-NLS-1$ + } + // Close out current entry type + switch (usage) { + // Class reference + case 0: + baos.write("</class>".getBytes()); //$NON-NLS-1$ + break; + // Package reference + case 1: + baos.write("</package>".getBytes()); //$NON-NLS-1$ + break; + // Plugin reference + case 2: + baos.write("</plugin>".getBytes()); //$NON-NLS-1$ + break; + } } } @@ -584,6 +668,7 @@ public class CombineClass2Reference extends ComponentTeamScanner implements IOut Collection src = (Collection)options.get(ARG_SOURCE); Collection output = (Collection)options.get(ARG_OUTPUT); Collection api = (Collection)options.get(ARG_API); + Collection showAdopterNumbers = (Collection)options.get(ARG_SHOW_ADOPTER_NUMBERS); // If the usage is improper or arguments are not valid, prompt for proper usage if (src == null || output == null || src.isEmpty() || output.isEmpty()) { printUsage(); @@ -594,6 +679,8 @@ public class CombineClass2Reference extends ComponentTeamScanner implements IOut class2Ref.setSrc(src); class2Ref.setOutput((String)output.iterator().next()); class2Ref.setApi(api); + if (showAdopterNumbers!=null) + class2Ref.setShouldShowIndividualAdopters(Boolean.parseBoolean((String)showAdopterNumbers.iterator().next())); // Execute the combination method class2Ref.execute(); } @@ -610,4 +697,19 @@ public class CombineClass2Reference extends ComponentTeamScanner implements IOut System.out.println(PRINT_OUTPUT_LOCATION); System.out.println(PRINT_COMPONENT_XML_API_LOCATION); } + + /** + * @return boolean should show individual adopter numbers + */ + public boolean isShouldShowIndividualAdopters() { + return shouldShowIndividualAdopters; + } + + /** + * Set whether or not to show individual adopter numbers in combined report + * @param shouldShowIndividualAdopters + */ + public void setShouldShowIndividualAdopters(boolean shouldShowIndividualAdopters) { + this.shouldShowIndividualAdopters = shouldShowIndividualAdopters; + } } \ No newline at end of file diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/combine-class2ref.xsl b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/combine-class2ref.xsl index 84647c467c2082c6094c16003827c0fc3c9a55c1..36a61c26a1b82a3ab7fd8bc7c00ab371f89c7078 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/combine-class2ref.xsl +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/combine-class2ref.xsl @@ -34,6 +34,9 @@ <th width="95%">Class name</th> <th>Internal code usage count</th> <th>API usage count</th> + <xsl:for-each select="source"> + <th><xsl:value-of select="@name"/> Internal Count</th> + </xsl:for-each> </tr> <xsl:for-each select="class"> <xsl:apply-templates select="."/> @@ -49,7 +52,15 @@ <td><xsl:value-of select="@name"/></td> <td><xsl:value-of select="@internal"/></td> <td><xsl:value-of select="@api"/></td> + <xsl:for-each select="source"> + <xsl:sort select="@name"/> + <xsl:apply-templates select="."/> + </xsl:for-each> </tr> </xsl:template> + + <xsl:template match="source"> + <td><xsl:value-of select="@internal"/></td> + </xsl:template> </xsl:stylesheet> \ No newline at end of file diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/combine-pkg2ref.xsl b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/combine-pkg2ref.xsl index 6a3d5f49b1f743b9ca2f14bdc6833d3298a29ca2..a806cd8af23c3cca7681b76ab9aa7a2bce588b73 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/combine-pkg2ref.xsl +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/combine-pkg2ref.xsl @@ -34,6 +34,9 @@ <th width="95%">Package name</th> <th>Internal code usage count</th> <th>API usage count</th> + <xsl:for-each select="source"> + <th><xsl:value-of select="@name"/> Internal Count</th> + </xsl:for-each> </tr> <xsl:for-each select="package"> <xsl:apply-templates select="."/> @@ -49,7 +52,15 @@ <td><xsl:value-of select="@name"/></td> <td><xsl:value-of select="@internal"/></td> <td><xsl:value-of select="@api"/></td> + <xsl:for-each select="source"> + <xsl:sort select="@name"/> + <xsl:apply-templates select="."/> + </xsl:for-each> </tr> </xsl:template> + + <xsl:template match="source"> + <td><xsl:value-of select="@internal"/></td> + </xsl:template> </xsl:stylesheet> \ No newline at end of file diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/combine-plugin2ref.xsl b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/combine-plugin2ref.xsl index 47f72c259861c693ef4a71da7ca3f051ac2153dc..1c4e376b15124c498820b818dfb286d005714d9f 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/combine-plugin2ref.xsl +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/xsl/combine-plugin2ref.xsl @@ -34,6 +34,9 @@ <th width="95%">Plug-in</th> <th>Internal code usage count</th> <th>API usage count</th> + <xsl:for-each select="source"> + <th><xsl:value-of select="@name"/> Internal Count</th> + </xsl:for-each> </tr> <xsl:for-each select="plugin"> <xsl:apply-templates select="."/> @@ -49,7 +52,15 @@ <td><xsl:value-of select="@id"/></td> <td><xsl:value-of select="@internal"/></td> <td><xsl:value-of select="@api"/></td> + <xsl:for-each select="source"> + <xsl:sort select="@name"/> + <xsl:apply-templates select="."/> + </xsl:for-each> </tr> </xsl:template> + + <xsl:template match="source"> + <td><xsl:value-of select="@internal"/></td> + </xsl:template> </xsl:stylesheet> \ No newline at end of file