software/test/performance/src/org/LexGrid/LexBIG/example/ProfileScheme.java
/**
	 * Initiates profiling of different code system attributes and displays
	 * a report for the caller.
	 */
Initiates profiling of different code system attributes and displays
a report for the caller.
Initiates profiling of different code system attributes and displays a report for the caller .
protected void runReport(LexBIGService lbs, CodingSchemeSummary css) throws LBException {
        LexBIGServiceConvenienceMethods lbscm =
            (LexBIGServiceConvenienceMethods) lbs.getGenericExtension("LexBIGServiceConvenienceMethods");
        Util.displayMessage("==============================================================================");
        Util.displayMessage("==============================================================================");
		Util.displayMessage("NOTE: This may take some time depending on the vocabulary size.");
        Util.displayMessage("");
		String schemeName = css.getLocalName(); 
		CodingSchemeVersionOrTag csVorT =
			Constructors.createCodingSchemeVersionOrTagFromVersion(css.getRepresentsVersion()); 
		long begin = System.currentTimeMillis();
        Util.displayMessage("==============================================================================");
		Util.displayMessage("Profiling Concepts ...");
	    Util.displayMessage("==============================================================================");
	    int conceptCount = profileConcepts(lbs, schemeName, csVorT);
        Util.displayMessage("");
		Util.displayMessage("Number of concepts: " + conceptCount);
		Set<String> sortedNames = new TreeSet<String>(prop2Freq.keySet());
        if (sortedNames.size() > 0) {
            Util.displayMessage("Number of concepts assigned the following properties:");
    		for (Iterator<String> propNames = sortedNames.iterator(); propNames.hasNext(); ) {
    		    String propName = propNames.next();
    		    Util.displayMessage("  " + propName + ": " + prop2Freq.get(propName));
    		}
        }
        sortedNames = new TreeSet<String>(propQual2Freq.keySet());
        if (sortedNames.size() > 0) {
            Util.displayMessage("Number of concepts assigned the following property qualifiers:");
            for (Iterator<String> qualNames = sortedNames.iterator(); qualNames.hasNext(); ) {
                String qualName = qualNames.next();
                Util.displayMessage("  " + qualName + ": " + propQual2Freq.get(qualName));
            }
        }
		Util.displayMessage("Time elapsed (ms): " + (System.currentTimeMillis() - begin) + "\n");
        begin = System.currentTimeMillis();
        Util.displayMessage("==============================================================================");
        Util.displayMessage("Profiling Associations ...");
        Util.displayMessage("==============================================================================");
        profileAssociations(lbs, lbscm, schemeName, csVorT);
        sortedNames = new TreeSet<String>(assoc2srcFreq.keySet());
        if (sortedNames.size() > 0) {
            Util.displayMessage("");
            for (Iterator<String> assocNames = sortedNames.iterator(); assocNames.hasNext(); ) {
                String assocName = assocNames.next();
                Util.displayMessage("Name: '" + assocName +
                    "' fwd: '" + lbscm.getAssociationForwardName(assocName, schemeName, csVorT) +
                    "' rev: '" + lbscm.getAssociationReverseName(assocName, schemeName, csVorT) + '\'');
                int srcFreq = assoc2srcFreq.get(assocName);
                int tgtFreq = assoc2tgtFreq.get(assocName);
                if (srcFreq >= 0 && tgtFreq >= 0) {
                    Util.displayMessage("  # sources: " + srcFreq + "  targets: " + tgtFreq);
                }
            }
        }
        Util.displayMessage("Time elapsed (ms): " + (System.currentTimeMillis() - begin) + "\n");
		String[] hIDs = lbscm.getHierarchyIDs(schemeName, csVorT);
		for (String hID:hIDs) {
		    combinedDepth = 0;
		    numBranches = 0;
		    numBranchPoints = 0;
		    List<ResolvedConceptReference> deepestPath = new ArrayList<ResolvedConceptReference>();
	        Util.displayMessage("==============================================================================");
			Util.displayMessage("Profiling Hierarchy: " + hID);
	        Util.displayMessage("==============================================================================");
			ResolvedConceptReferenceList refList =
				lbscm.getHierarchyRoots(schemeName, csVorT, hID);
			ResolvedConceptReference[] rcref = refList
					.getResolvedConceptReference();
			begin = System.currentTimeMillis();
			for (ResolvedConceptReference rcr : rcref) {
                Util.displayMessage("Checking Root: " + rcr.getConceptCode() + ':' + rcr.getEntityDescription().getContent());
                List<ResolvedConceptReference> currentPath = profileHierarchy(lbs, lbscm, schemeName, csVorT, hID, rcr, 0);
                if (currentPath.size() > 0) {
                    Util.displayMessage("");
                    Util.displayMessage("Example of Deepest Branch: ");
                    printPath(currentPath);
                }
				if (currentPath.size() > deepestPath.size())
				    deepestPath = currentPath;
				Util.displayMessage("");
			}
            Util.displayMessage("Number of Leaf Nodes ......................... : " + numBranches);
            Util.displayMessage("Number of Intermediate Nodes ................. : " + numBranchPoints);
			Util.displayMessage("Average Branch Depth for Hierarchy (all roots) : " +(combinedDepth / numBranches));
			Util.displayMessage("Deepest Branch Level for Hierarchy (all roots) : " + deepestPath.size());
			Util.displayMessage("Time elapsed (ms): " +(System.currentTimeMillis() - begin));
			Util.displayMessage("");
		}
	}
protected void runReport ( LexBIGService lbs , CodingSchemeSummary css ) throws LBException { LexBIGServiceConvenienceMethods lbscm = ( LexBIGServiceConvenienceMethods ) lbs . getGenericExtension ( "LexBIGServiceConvenienceMethods" ) ; Util . displayMessage ( "==============================================================================" ) ; Util . displayMessage ( "==============================================================================" ) ; Util . displayMessage ( "NOTE: This may take some time depending on the vocabulary size." ) ; Util . displayMessage ( "" ) ; String schemeName = css . getLocalName ( ) ; CodingSchemeVersionOrTag csVorT = Constructors . createCodingSchemeVersionOrTagFromVersion ( css . getRepresentsVersion ( ) ) ; long begin = System . currentTimeMillis ( ) ; Util . displayMessage ( "==============================================================================" ) ; Util . displayMessage ( "Profiling Concepts ..." ) ; Util . displayMessage ( "==============================================================================" ) ; int conceptCount = profileConcepts ( lbs , schemeName , csVorT ) ; Util . displayMessage ( "" ) ; Util . displayMessage ( "Number of concepts: " + conceptCount ) ; Set < String > sortedNames = new TreeSet < String > ( prop2Freq . keySet ( ) ) ; if ( sortedNames . size ( ) > 0 ) { Util . displayMessage ( "Number of concepts assigned the following properties:" ) ; for ( Iterator < String > propNames = sortedNames . iterator ( ) ; propNames . hasNext ( ) ; ) { String propName = propNames . next ( ) ; Util . displayMessage ( "  " + propName + ": " + prop2Freq . get ( propName ) ) ; } } sortedNames = new TreeSet < String > ( propQual2Freq . keySet ( ) ) ; if ( sortedNames . size ( ) > 0 ) { Util . displayMessage ( "Number of concepts assigned the following property qualifiers:" ) ; for ( Iterator < String > qualNames = sortedNames . iterator ( ) ; qualNames . hasNext ( ) ; ) { String qualName = qualNames . next ( ) ; Util . displayMessage ( "  " + qualName + ": " + propQual2Freq . get ( qualName ) ) ; } } Util . displayMessage ( "Time elapsed (ms): " + ( System . currentTimeMillis ( ) - begin ) + "\n" ) ; begin = System . currentTimeMillis ( ) ; Util . displayMessage ( "==============================================================================" ) ; Util . displayMessage ( "Profiling Associations ..." ) ; Util . displayMessage ( "==============================================================================" ) ; profileAssociations ( lbs , lbscm , schemeName , csVorT ) ; sortedNames = new TreeSet < String > ( assoc2srcFreq . keySet ( ) ) ; if ( sortedNames . size ( ) > 0 ) { Util . displayMessage ( "" ) ; for ( Iterator < String > assocNames = sortedNames . iterator ( ) ; assocNames . hasNext ( ) ; ) { String assocName = assocNames . next ( ) ; Util . displayMessage ( "Name: '" + assocName + "' fwd: '" + lbscm . getAssociationForwardName ( assocName , schemeName , csVorT ) + "' rev: '" + lbscm . getAssociationReverseName ( assocName , schemeName , csVorT ) + '\'' ) ; int srcFreq = assoc2srcFreq . get ( assocName ) ; int tgtFreq = assoc2tgtFreq . get ( assocName ) ; if ( srcFreq >= 0 && tgtFreq >= 0 ) { Util . displayMessage ( "  # sources: " + srcFreq + "  targets: " + tgtFreq ) ; } } } Util . displayMessage ( "Time elapsed (ms): " + ( System . currentTimeMillis ( ) - begin ) + "\n" ) ; String [ ] hIDs = lbscm . getHierarchyIDs ( schemeName , csVorT ) ; for ( String hID : hIDs ) { combinedDepth = 0 ; numBranches = 0 ; numBranchPoints = 0 ; List < ResolvedConceptReference > deepestPath = new ArrayList < ResolvedConceptReference > ( ) ; Util . displayMessage ( "==============================================================================" ) ; Util . displayMessage ( "Profiling Hierarchy: " + hID ) ; Util . displayMessage ( "==============================================================================" ) ; ResolvedConceptReferenceList refList = lbscm . getHierarchyRoots ( schemeName , csVorT , hID ) ; ResolvedConceptReference [ ] rcref = refList . getResolvedConceptReference ( ) ; begin = System . currentTimeMillis ( ) ; for ( ResolvedConceptReference rcr : rcref ) { Util . displayMessage ( "Checking Root: " + rcr . getConceptCode ( ) + ':' + rcr . getEntityDescription ( ) . getContent ( ) ) ; List < ResolvedConceptReference > currentPath = profileHierarchy ( lbs , lbscm , schemeName , csVorT , hID , rcr , 0 ) ; if ( currentPath . size ( ) > 0 ) { Util . displayMessage ( "" ) ; Util . displayMessage ( "Example of Deepest Branch: " ) ; printPath ( currentPath ) ; } if ( currentPath . size ( ) > deepestPath . size ( ) ) deepestPath = currentPath ; Util . displayMessage ( "" ) ; } Util . displayMessage ( "Number of Leaf Nodes ......................... : " + numBranches ) ; Util . displayMessage ( "Number of Intermediate Nodes ................. : " + numBranchPoints ) ; Util . displayMessage ( "Average Branch Depth for Hierarchy (all roots) : " + ( combinedDepth / numBranches ) ) ; Util . displayMessage ( "Deepest Branch Level for Hierarchy (all roots) : " + deepestPath . size ( ) ) ; Util . displayMessage ( "Time elapsed (ms): " + ( System . currentTimeMillis ( ) - begin ) ) ; Util . displayMessage ( "" ) ; } }
Initiates profiling of different code system attributes and displays
 a report for the caller.
Initiates profiling of different code system attributes and displays a report for the caller .
// Get the name and version of the coding scheme ...
 // local scheme name
 // Coding Scheme version
 // Output Number of concepts and the time in milliseconds required to enumerate...
 // Get the top nodes for each supported hierarchy and recurse through branches ...
 // Initialize processing for hierarchy and print header ...
 // Starting from root nodes, evaluate each hierarchy ...
