| 1 | 
    
            
    
     | 
    
      package org.apache.torque.util;     | 
  
            
  
    | 2 | 
    
            
    
     | 
    
           | 
  
            
  
    | 3 | 
    
            
    
     | 
    
      import java.util.Comparator;     | 
  
            
  
    | 4 | 
    
            
    
     | 
    
           | 
  
            
  
    | 5 | 
    
            
    
     | 
    
      import static org.apache.commons.lang.StringUtils.*;     | 
  
            
  
    | 6 | 
    
            
    
     | 
    
           | 
  
            
  
    | 7 | 
    
            
    
     | 
    
      import org.kuali.db.Transaction;     | 
  
            
  
    | 8 | 
    
            
    
     | 
    
           | 
  
            
  
    | 9 | 
    
            
    
     | 
    
           | 
  
            
  
    | 10 | 
    
            
    
     | 
    
           | 
  
            
  
    | 11 | 
    
            
    
     | 
    
           | 
  
            
  
    | 12 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 57 (57) | 
           Complexity: 22 | 
           Complexity Density: 0.73 | 
                        
            
        | 
    
  
  
    | 13 | 
    
            
    
     | 
    
      public class TransactionComparator<T> implements Comparator<Transaction> {     | 
  
            
  
    | 14 | 
    
            
    
     | 
    
           | 
  
            
  
    | 15 | 
    
            
    
     | 
    
          String suffix = ".sql";     | 
  
            
  
    | 16 | 
    
            
    
     | 
    
          String constraints = "-constraints";     | 
  
            
  
    | 17 | 
    
            
    
     | 
    
          String artifactId;     | 
  
            
  
    | 18 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 19 | 
    
           0
    
     | 
    
           public TransactionComparator() {...     | 
  
            
  
    | 20 | 
    
           0
    
     | 
    
              this(null);     | 
  
            
  
    | 21 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 22 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 2 (2) | 
           Complexity: 1 | 
           Complexity Density: 0.5 | 
                        
            
        | 
    
  
  
    | 23 | 
    
           0
    
     | 
    
           public TransactionComparator(String artifactId) {...     | 
  
            
  
    | 24 | 
    
           0
    
     | 
    
              super();     | 
  
            
  
    | 25 | 
    
           0
    
     | 
    
              this.artifactId = artifactId;     | 
  
            
  
    | 26 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 27 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 31 (31) | 
           Complexity: 11 | 
           Complexity Density: 0.65 | 
                        
            
        | 
    
  
  
    | 28 | 
    
           0
    
     | 
    
           @Override...     | 
  
            
  
    | 29 | 
    
            
    
     | 
    
          public int compare(Transaction one, Transaction two) {     | 
  
            
  
    | 30 | 
    
           0
    
     | 
    
              String loc1 = one.getResourceLocation();     | 
  
            
  
    | 31 | 
    
           0
    
     | 
    
              String loc2 = two.getResourceLocation();     | 
  
            
  
    | 32 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 33 | 
    
           0
    
     | 
    
              if (isSchemaSQL(loc1)) {     | 
  
            
  
    | 34 | 
    
           0
    
     | 
    
                  return -1;     | 
  
            
  
    | 35 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 36 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 37 | 
    
           0
    
     | 
    
              if (isSchemaSQL(loc2)) {     | 
  
            
  
    | 38 | 
    
           0
    
     | 
    
                  return 1;     | 
  
            
  
    | 39 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 40 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 41 | 
    
           0
    
     | 
    
              if (isSchemaConstraintsSQL(loc1)) {     | 
  
            
  
    | 42 | 
    
           0
    
     | 
    
                  return 1;     | 
  
            
  
    | 43 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 44 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 45 | 
    
           0
    
     | 
    
              if (isSchemaConstraintsSQL(loc2)) {     | 
  
            
  
    | 46 | 
    
           0
    
     | 
    
                  return -1;     | 
  
            
  
    | 47 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 48 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 49 | 
    
           0
    
     | 
    
              if (isEmpty(loc1) && isEmpty(loc2)) {     | 
  
            
  
    | 50 | 
    
           0
    
     | 
    
                  return 0;     | 
  
            
  
    | 51 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 52 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 53 | 
    
           0
    
     | 
    
              if (isEmpty(loc1) && !isEmpty(loc2)) {     | 
  
            
  
    | 54 | 
    
           0
    
     | 
    
                  return 1;     | 
  
            
  
    | 55 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 56 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 57 | 
    
           0
    
     | 
    
              if (!isEmpty(loc1) && isEmpty(loc2)) {     | 
  
            
  
    | 58 | 
    
           0
    
     | 
    
                  return -1;     | 
  
            
  
    | 59 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 60 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 61 | 
    
           0
    
     | 
    
              return loc1.compareTo(loc2);     | 
  
            
  
    | 62 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 63 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 5 (5) | 
           Complexity: 2 | 
           Complexity Density: 0.67 | 
                        
            
        | 
    
  
  
    | 64 | 
    
           0
    
     | 
    
           protected boolean isSchemaSQL(String location) {...     | 
  
            
  
    | 65 | 
    
           0
    
     | 
    
              if (isEmpty(location)) {     | 
  
            
  
    | 66 | 
    
           0
    
     | 
    
                  return false;     | 
  
            
  
    | 67 | 
    
            
    
     | 
    
              } else {     | 
  
            
  
    | 68 | 
    
           0
    
     | 
    
                  return location.endsWith(getArtifactId() + getSuffix());     | 
  
            
  
    | 69 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 70 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 71 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 72 | 
    
           0
    
     | 
    
           protected boolean isSchemaConstraintsSQL(String location) {...     | 
  
            
  
    | 73 | 
    
           0
    
     | 
    
              return location.endsWith(getArtifactId() + getConstraints() + getSuffix());     | 
  
            
  
    | 74 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 75 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 76 | 
    
           0
    
     | 
    
           public String getArtifactId() {...     | 
  
            
  
    | 77 | 
    
           0
    
     | 
    
              return artifactId;     | 
  
            
  
    | 78 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 79 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 80 | 
    
           0
    
     | 
    
           public void setArtifactId(String schema) {...     | 
  
            
  
    | 81 | 
    
           0
    
     | 
    
              this.artifactId = schema;     | 
  
            
  
    | 82 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 83 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 84 | 
    
           0
    
     | 
    
           public String getSuffix() {...     | 
  
            
  
    | 85 | 
    
           0
    
     | 
    
              return suffix;     | 
  
            
  
    | 86 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 87 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 88 | 
    
           0
    
     | 
    
           public void setSuffix(String suffix) {...     | 
  
            
  
    | 89 | 
    
           0
    
     | 
    
              this.suffix = suffix;     | 
  
            
  
    | 90 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 91 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 92 | 
    
           0
    
     | 
    
           public String getConstraints() {...     | 
  
            
  
    | 93 | 
    
           0
    
     | 
    
              return constraints;     | 
  
            
  
    | 94 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 95 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 96 | 
    
           0
    
     | 
    
           public void setConstraints(String constraints) {...     | 
  
            
  
    | 97 | 
    
           0
    
     | 
    
              this.constraints = constraints;     | 
  
            
  
    | 98 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 99 | 
    
            
    
     | 
    
           | 
  
            
  
    | 100 | 
    
            
    
     | 
    
      }     |