| 1 | 
    
            
    
     | 
    
      package org.apache.torque.mojo;     | 
  
            
  
    | 2 | 
    
            
    
     | 
    
           | 
  
            
  
    | 3 | 
    
            
    
     | 
    
      import java.io.File;     | 
  
            
  
    | 4 | 
    
            
    
     | 
    
      import java.io.IOException;     | 
  
            
  
    | 5 | 
    
            
    
     | 
    
           | 
  
            
  
    | 6 | 
    
            
    
     | 
    
      import org.apache.commons.configuration.PropertiesConfiguration;     | 
  
            
  
    | 7 | 
    
            
    
     | 
    
      import org.apache.commons.io.FileUtils;     | 
  
            
  
    | 8 | 
    
            
    
     | 
    
      import org.apache.maven.plugin.MojoExecutionException;     | 
  
            
  
    | 9 | 
    
            
    
     | 
    
      import org.apache.torque.task.TorqueDataModelTask;     | 
  
            
  
    | 10 | 
    
            
    
     | 
    
      import org.kuali.core.db.torque.Utils;     | 
  
            
  
    | 11 | 
    
            
    
     | 
    
           | 
  
            
  
    | 12 | 
    
            
    
     | 
    
           | 
  
            
  
    | 13 | 
    
            
    
     | 
    
           | 
  
            
  
    | 14 | 
    
            
    
     | 
    
           | 
  
            
  
    | 15 | 
    
            
    
     | 
    
           | 
  
            
  
    | 16 | 
    
            
    
     | 
    
           | 
  
            
  
    | 17 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 56 (56) | 
           Complexity: 18 | 
           Complexity Density: 0.49 | 
                        
            
        | 
    
  
  
    | 18 | 
    
            
    
     | 
    
      public class DataDtdMojo extends DataModelTaskMojo {     | 
  
            
  
    | 19 | 
    
            
    
     | 
    
               | 
  
            
  
    | 20 | 
    
            
    
     | 
    
          public static final String PROJECT_CONTEXT_PROPERTY = "project";     | 
  
            
  
    | 21 | 
    
            
    
     | 
    
           | 
  
            
  
    | 22 | 
    
            
    
     | 
    
               | 
  
            
  
    | 23 | 
    
            
    
     | 
    
           | 
  
            
  
    | 24 | 
    
            
    
     | 
    
           | 
  
            
  
    | 25 | 
    
            
    
     | 
    
          boolean antCompatibilityMode;     | 
  
            
  
    | 26 | 
    
            
    
     | 
    
           | 
  
            
  
    | 27 | 
    
            
    
     | 
    
               | 
  
            
  
    | 28 | 
    
            
    
     | 
    
           | 
  
            
  
    | 29 | 
    
            
    
     | 
    
           | 
  
            
  
    | 30 | 
    
            
    
     | 
    
           | 
  
            
  
    | 31 | 
    
            
    
     | 
    
           | 
  
            
  
    | 32 | 
    
            
    
     | 
    
          String copyToFile;     | 
  
            
  
    | 33 | 
    
            
    
     | 
    
           | 
  
            
  
    | 34 | 
    
            
    
     | 
    
               | 
  
            
  
    | 35 | 
    
            
    
     | 
    
           | 
  
            
  
    | 36 | 
    
            
    
     | 
    
           | 
  
            
  
    | 37 | 
    
            
    
     | 
    
           | 
  
            
  
    | 38 | 
    
            
    
     | 
    
           | 
  
            
  
    | 39 | 
    
            
    
     | 
    
          String artifactId;     | 
  
            
  
    | 40 | 
    
            
    
     | 
    
           | 
  
            
  
    | 41 | 
    
            
    
     | 
    
               | 
  
            
  
    | 42 | 
    
            
    
     | 
    
           | 
  
            
  
    | 43 | 
    
            
    
     | 
    
           | 
  
            
  
    | 44 | 
    
            
    
     | 
    
           | 
  
            
  
    | 45 | 
    
            
    
     | 
    
           | 
  
            
  
    | 46 | 
    
            
    
     | 
    
           | 
  
            
  
    | 47 | 
    
            
    
     | 
    
          @SuppressWarnings("unused")     | 
  
            
  
    | 48 | 
    
            
    
     | 
    
          private String dummy1;     | 
  
            
  
    | 49 | 
    
            
    
     | 
    
           | 
  
            
  
    | 50 | 
    
            
    
     | 
    
               | 
  
            
  
    | 51 | 
    
            
    
     | 
    
           | 
  
            
  
    | 52 | 
    
            
    
     | 
    
           | 
  
            
  
    | 53 | 
    
            
    
     | 
    
           | 
  
            
  
    | 54 | 
    
            
    
     | 
    
           | 
  
            
  
    | 55 | 
    
            
    
     | 
    
           | 
  
            
  
    | 56 | 
    
            
    
     | 
    
          @SuppressWarnings("unused")     | 
  
            
  
    | 57 | 
    
            
    
     | 
    
          private String dummy2;     | 
  
            
  
    | 58 | 
    
            
    
     | 
    
           | 
  
            
  
    | 59 | 
    
            
    
     | 
    
               | 
  
            
  
    | 60 | 
    
            
    
     | 
    
           | 
  
            
  
    | 61 | 
    
            
    
     | 
    
           | 
  
            
  
    | 62 | 
    
            
    
     | 
    
           | 
  
            
  
    | 63 | 
    
            
    
     | 
    
           | 
  
            
  
    | 64 | 
    
            
    
     | 
    
           | 
  
            
  
    | 65 | 
    
            
    
     | 
    
          @SuppressWarnings("unused")     | 
  
            
  
    | 66 | 
    
            
    
     | 
    
          private String dummy3;     | 
  
            
  
    | 67 | 
    
            
    
     | 
    
           | 
  
            
  
    | 68 | 
    
            
    
     | 
    
               | 
  
            
  
    | 69 | 
    
            
    
     | 
    
           | 
  
            
  
    | 70 | 
    
            
    
     | 
    
           | 
  
            
  
    | 71 | 
    
            
    
     | 
    
           | 
  
            
  
    | 72 | 
    
            
    
     | 
    
           | 
  
            
  
    | 73 | 
    
            
    
     | 
    
          private String projectName;     | 
  
            
  
    | 74 | 
    
            
    
     | 
    
           | 
  
            
  
    | 75 | 
    
            
    
     | 
    
               | 
  
            
  
    | 76 | 
    
            
    
     | 
    
           | 
  
            
  
    | 77 | 
    
            
    
     | 
    
           | 
  
            
  
    | 78 | 
    
            
    
     | 
    
           | 
  
            
  
    | 79 | 
    
            
    
     | 
    
           | 
  
            
  
    | 80 | 
    
            
    
     | 
    
           | 
  
            
  
    | 81 | 
    
            
    
     | 
    
           | 
  
            
  
    | 82 | 
    
            
    
     | 
    
          private String schemaXMLFile;     | 
  
            
  
    | 83 | 
    
            
    
     | 
    
           | 
  
            
  
    | 84 | 
    
            
    
     | 
    
               | 
  
            
  
    | 85 | 
    
            
    
     | 
    
           | 
  
            
  
    | 86 | 
    
            
    
     | 
    
           | 
  
            
  
    | 87 | 
    
            
    
     | 
    
      @return     | 
  
            
  
    | 88 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 4 (4) | 
           Complexity: 1 | 
           Complexity Density: 0.25 | 
                        
            
        | 
    
  
  
    | 89 | 
    
           0
    
     | 
    
           @Override...     | 
  
            
  
    | 90 | 
    
            
    
     | 
    
          protected PropertiesConfiguration getMojoContextProperties() {     | 
  
            
  
    | 91 | 
    
           0
    
     | 
    
              PropertiesConfiguration configuration = new PropertiesConfiguration();     | 
  
            
  
    | 92 | 
    
           0
    
     | 
    
              configuration.addProperty(PROJECT_CONTEXT_PROPERTY, getProjectName());     | 
  
            
  
    | 93 | 
    
           0
    
     | 
    
              configuration.addProperty("version", getProject().getVersion());     | 
  
            
  
    | 94 | 
    
           0
    
     | 
    
              return configuration;     | 
  
            
  
    | 95 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 96 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 3 (3) | 
           Complexity: 1 | 
           Complexity Density: 0.33 | 
                        
            
        | 
    
  
  
    | 97 | 
    
           0
    
     | 
    
           protected void showConfig() {...     | 
  
            
  
    | 98 | 
    
           0
    
     | 
    
              getLog().info("Schema XML File: " + schemaXMLFile);     | 
  
            
  
    | 99 | 
    
           0
    
     | 
    
              getLog().info("Ant Compatibility Mode: " + antCompatibilityMode);     | 
  
            
  
    | 100 | 
    
           0
    
     | 
    
              getLog().info("Output Directory: " + getOutputDir());     | 
  
            
  
    | 101 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 102 | 
    
            
    
     | 
    
           | 
  
            
  
    | 103 | 
    
            
    
     | 
    
               | 
  
            
  
    | 104 | 
    
            
    
     | 
    
           | 
  
            
  
    | 105 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 9 (9) | 
           Complexity: 2 | 
           Complexity Density: 0.29 | 
                        
            
        | 
    
  
  
    | 106 | 
    
           0
    
     | 
    
           @Override...     | 
  
            
  
    | 107 | 
    
            
    
     | 
    
          protected void configureTask() throws MojoExecutionException {     | 
  
            
  
    | 108 | 
    
           0
    
     | 
    
              TorqueDataModelTask task = new TorqueDataModelTask();     | 
  
            
  
    | 109 | 
    
           0
    
     | 
    
              setAntTask(task);     | 
  
            
  
    | 110 | 
    
           0
    
     | 
    
              super.configureTask();     | 
  
            
  
    | 111 | 
    
           0
    
     | 
    
              boolean exists = new Utils().isFileOrResource(getSchemaXMLFile());     | 
  
            
  
    | 112 | 
    
           0
    
     | 
    
              if (!exists) {     | 
  
            
  
    | 113 | 
    
           0
    
     | 
    
                  throw new MojoExecutionException("Unable to locate: " + getSchemaXMLFile());     | 
  
            
  
    | 114 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 115 | 
    
           0
    
     | 
    
              task.setXmlFile(getSchemaXMLFile());     | 
  
            
  
    | 116 | 
    
            
    
     | 
    
           | 
  
            
  
    | 117 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 118 | 
    
            
    
     | 
    
           | 
  
            
  
    | 119 | 
    
            
    
     | 
    
               | 
  
            
  
    | 120 | 
    
            
    
     | 
    
           | 
  
            
  
    | 121 | 
    
            
    
     | 
    
           | 
  
            
  
    | 122 | 
    
            
    
     | 
    
      @return     | 
  
            
  
    | 123 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 124 | 
    
           0
    
     | 
    
           @Override...     | 
  
            
  
    | 125 | 
    
            
    
     | 
    
          protected String getControlTemplate() {     | 
  
            
  
    | 126 | 
    
           0
    
     | 
    
              return "data/Control.vm";     | 
  
            
  
    | 127 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 128 | 
    
            
    
     | 
    
           | 
  
            
  
    | 129 | 
    
            
    
     | 
    
               | 
  
            
  
    | 130 | 
    
            
    
     | 
    
           | 
  
            
  
    | 131 | 
    
            
    
     | 
    
           | 
  
            
  
    | 132 | 
    
            
    
     | 
    
      @return     | 
  
            
  
    | 133 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 134 | 
    
           0
    
     | 
    
           public String getProjectName() {...     | 
  
            
  
    | 135 | 
    
           0
    
     | 
    
              return projectName;     | 
  
            
  
    | 136 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 137 | 
    
            
    
     | 
    
           | 
  
            
  
    | 138 | 
    
            
    
     | 
    
               | 
  
            
  
    | 139 | 
    
            
    
     | 
    
           | 
  
            
  
    | 140 | 
    
            
    
     | 
    
           | 
  
            
  
    | 141 | 
    
            
    
     | 
    
      @param     | 
  
            
  
    | 142 | 
    
            
    
     | 
    
           | 
  
            
  
    | 143 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 144 | 
    
           0
    
     | 
    
           public void setProjectName(final String projectName) {...     | 
  
            
  
    | 145 | 
    
           0
    
     | 
    
              this.projectName = projectName;     | 
  
            
  
    | 146 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 147 | 
    
            
    
     | 
    
           | 
  
            
  
    | 148 | 
    
            
    
     | 
    
               | 
  
            
  
    | 149 | 
    
            
    
     | 
    
           | 
  
            
  
    | 150 | 
    
            
    
     | 
    
           | 
  
            
  
    | 151 | 
    
            
    
     | 
    
      @return     | 
  
            
  
    | 152 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 153 | 
    
           0
    
     | 
    
           public String getSchemaXMLFile() {...     | 
  
            
  
    | 154 | 
    
           0
    
     | 
    
              return schemaXMLFile;     | 
  
            
  
    | 155 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 156 | 
    
            
    
     | 
    
           | 
  
            
  
    | 157 | 
    
            
    
     | 
    
               | 
  
            
  
    | 158 | 
    
            
    
     | 
    
           | 
  
            
  
    | 159 | 
    
            
    
     | 
    
           | 
  
            
  
    | 160 | 
    
            
    
     | 
    
      @param     | 
  
            
  
    | 161 | 
    
            
    
     | 
    
           | 
  
            
  
    | 162 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 163 | 
    
           0
    
     | 
    
           public void setSchemaXMLFile(final String xmlFile) {...     | 
  
            
  
    | 164 | 
    
           0
    
     | 
    
              this.schemaXMLFile = xmlFile;     | 
  
            
  
    | 165 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 166 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 14 (14) | 
           Complexity: 3 | 
           Complexity Density: 0.25 | 
                        
            
        | 
    
  
  
    | 167 | 
    
           0
    
     | 
    
           @Override...     | 
  
            
  
    | 168 | 
    
            
    
     | 
    
          public void executeMojo() throws MojoExecutionException {     | 
  
            
  
    | 169 | 
    
           0
    
     | 
    
              getLog().info("------------------------------------------------------------------------");     | 
  
            
  
    | 170 | 
    
           0
    
     | 
    
              getLog().info("Generating database DTD");     | 
  
            
  
    | 171 | 
    
           0
    
     | 
    
              getLog().info("------------------------------------------------------------------------");     | 
  
            
  
    | 172 | 
    
           0
    
     | 
    
              showConfig();     | 
  
            
  
    | 173 | 
    
           0
    
     | 
    
              super.executeMojo();     | 
  
            
  
    | 174 | 
    
           0
    
     | 
    
              if (antCompatibilityMode) {     | 
  
            
  
    | 175 | 
    
           0
    
     | 
    
                  File srcFile = new File(getOutputDir() + FS + getArtifactId() + ".dtd");     | 
  
            
  
    | 176 | 
    
           0
    
     | 
    
                  File dstFile = new File(copyToFile);     | 
  
            
  
    | 177 | 
    
           0
    
     | 
    
                  getLog().info("Creating " + dstFile.getAbsolutePath() + " for Ant compatibility mode");     | 
  
            
  
    | 178 | 
    
           0
    
     | 
    
                  try {     | 
  
            
  
    | 179 | 
    
           0
    
     | 
    
                      FileUtils.copyFile(srcFile, dstFile);     | 
  
            
  
    | 180 | 
    
            
    
     | 
    
                  } catch (IOException e) {     | 
  
            
  
    | 181 | 
    
           0
    
     | 
    
                      throw new MojoExecutionException("Error copying file", e);     | 
  
            
  
    | 182 | 
    
            
    
     | 
    
                  }     | 
  
            
  
    | 183 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 184 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 185 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 186 | 
    
           0
    
     | 
    
           public boolean isAntCompatibilityMode() {...     | 
  
            
  
    | 187 | 
    
           0
    
     | 
    
              return antCompatibilityMode;     | 
  
            
  
    | 188 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 189 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 190 | 
    
           0
    
     | 
    
           public void setAntCompatibilityMode(final boolean antCompatibilityMode) {...     | 
  
            
  
    | 191 | 
    
           0
    
     | 
    
              this.antCompatibilityMode = antCompatibilityMode;     | 
  
            
  
    | 192 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 193 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 194 | 
    
           0
    
     | 
    
           public String getCopyToFile() {...     | 
  
            
  
    | 195 | 
    
           0
    
     | 
    
              return copyToFile;     | 
  
            
  
    | 196 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 197 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 198 | 
    
           0
    
     | 
    
           public void setCopyToFile(final String copyToFile) {...     | 
  
            
  
    | 199 | 
    
           0
    
     | 
    
              this.copyToFile = copyToFile;     | 
  
            
  
    | 200 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 201 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 202 | 
    
           0
    
     | 
    
           public String getArtifactId() {...     | 
  
            
  
    | 203 | 
    
           0
    
     | 
    
              return artifactId;     | 
  
            
  
    | 204 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 205 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 206 | 
    
           0
    
     | 
    
           public void setArtifactId(final String artifactId) {...     | 
  
            
  
    | 207 | 
    
           0
    
     | 
    
              this.artifactId = artifactId;     | 
  
            
  
    | 208 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 209 | 
    
            
    
     | 
    
      }     |