LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  March 2015

HPS-SVN March 2015

Subject:

r2280 - /java/trunk/conditions/src/main/java/org/hps/conditions/cli/PrintCommand.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Fri, 6 Mar 2015 01:47:01 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (158 lines)

Author: [log in to unmask]
Date: Thu Mar  5 17:46:57 2015
New Revision: 2280

Log:
Minor modifications to print of conditions info.

Modified:
    java/trunk/conditions/src/main/java/org/hps/conditions/cli/PrintCommand.java

Modified: java/trunk/conditions/src/main/java/org/hps/conditions/cli/PrintCommand.java
 =============================================================================
--- java/trunk/conditions/src/main/java/org/hps/conditions/cli/PrintCommand.java	(original)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/cli/PrintCommand.java	Thu Mar  5 17:46:57 2015
@@ -8,7 +8,6 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
-import java.util.logging.Level;
 
 import org.apache.commons.cli.Option;
 import org.hps.conditions.api.ConditionsObject;
@@ -36,6 +35,8 @@
 
     // Field delimited for print out.
     char fieldDelimiter = ' ';
+    
+    DatabaseConditionsManager conditionsManager;
     
     PrintCommand() {
         super("print", "Print the table data for a conditions set");
@@ -50,11 +51,10 @@
     /**
      * Print out the conditions sets selected by the user's command line arguments.
      */
-    @SuppressWarnings("rawtypes")
     void execute(String[] arguments) {
         super.execute(arguments);
         
-        DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance();
+        conditionsManager = DatabaseConditionsManager.getInstance();
         
         // User specified tag of conditions records.
         if (this.commandLine.hasOption("T")) {
@@ -97,27 +97,42 @@
             fieldDelimiter = '\t';
         }
                          
-        // Get a list of conditions records from the key.
+        // List of conditions records to print. 
         ConditionsRecordCollection conditionsRecords = new ConditionsRecordCollection();
-        // Did user specify a key to use?
+        
+        // Did the user specify a table to use?
         if (userConditionsKey == null) {
-            // Use all key names if there was not one specified.
+            // Use all table names if there was not one specified.
             conditionsRecords.addAll(conditionsManager.getConditionsRecords());
         } else {            
-            // Get records for the user specified key.
+            // Get records only for the user specified table name.
             conditionsRecords.addAll(conditionsManager.findConditionsRecords(userConditionsKey));
         }
         
+        // Sort the records by key (table name).
         conditionsRecords.sortByKey();
         
         // Get a unique list of keys from the returned conditions records.
         Set<String> conditionsKeys = conditionsRecords.getConditionsKeys();
             
+        // Print the records and the data.
+        printConditionsRecords(conditionsKeys);   
+        ps.flush();           
+        ps.close();
+    }
+
+    private void printConditionsRecords(Set<String> conditionsKeys) {
+        ps.print("printing conditions sets: ");
+        for (String conditionsKey : conditionsKeys) {
+            ps.print(conditionsKey + " ");
+        }
+        ps.println();
+        ps.println();
         // Loop over the conditions keys from the conditions records.
         for (String conditionsKey : conditionsKeys) {
-                       
+                                   
             // The list of collections to print.
-            List<ConditionsObjectCollection> collectionList = new ArrayList<ConditionsObjectCollection>();
+            List<ConditionsObjectCollection<?>> collectionList = new ArrayList<ConditionsObjectCollection<?>>();
         
             // Get the table meta data for the conditions key.
             TableMetaData tableMetaData = conditionsManager.findTableMetaData(conditionsKey);
@@ -126,21 +141,19 @@
             if (tableMetaData == null) {            
                 throw new RuntimeException("The table meta data for " + conditionsKey + " does not exist.  The key might be invalid.");
             }
-        
+                               
             // Use only the single collection which would be seen by a user job for this run number and key.
-            ConditionsObjectCollection collection = conditionsManager.getCollection(tableMetaData.getCollectionClass());
+            ConditionsObjectCollection<?> collection = conditionsManager.getCollection(tableMetaData.getCollectionClass());  
             collectionList.add(collection);
         
             // Print out all the collection data to console or file.
             printCollections(collectionList);
-        }   
-        ps.flush();           
-        ps.close();
-    }
-
-    private void printCollections(List<ConditionsObjectCollection> collectionList) {
+        }
+    }
+
+    private void printCollections(List<ConditionsObjectCollection<?>> collectionList) {
         // Loop over all the collections and print them.
-        for (ConditionsObjectCollection collection : collectionList) {
+        for (ConditionsObjectCollection<?> collection : collectionList) {
             if (printHeaders) {
                 printCollectionHeader(collection);
             }
@@ -148,9 +161,10 @@
             printCollection(collection);
             ps.println();
         }
-    }
-
-    private void printCollection(ConditionsObjectCollection collection) {
+        ps.flush();
+    }
+
+    private void printCollection(ConditionsObjectCollection<?> collection) {
         StringBuffer buffer = new StringBuffer();
         for (Object object : collection) {
             for (String columnName : collection.getTableMetaData().getFieldNames()) {
@@ -161,12 +175,15 @@
             buffer.append('\n');
         }
         ps.print(buffer.toString());
-    }
-
-    private void printCollectionHeader(ConditionsObjectCollection collection) {
+        ps.flush();
+    }
+
+    private void printCollectionHeader(ConditionsObjectCollection<?> collection) {        
         ps.println("--------------------------------------");
-        ps.println();
-        ps.println(collection.getConditionsRecord());
+        ps.print(collection.getConditionsRecord());
+        ps.println("--------------------------------------");
+        ps.println();
+        ps.flush();
     }
 
     private void printColumnNames(TableMetaData tableMetaData) {

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use