Coverage Report - org.apache.maven.archiva.database.constraints.ArchivaAuditLogsConstraint
 
Classes in this File Line Coverage Branch Coverage Complexity
ArchivaAuditLogsConstraint
0%
0/36
0%
0/14
0
 
 1  
 package org.apache.maven.archiva.database.constraints;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *  http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import java.util.ArrayList;
 23  
 import java.util.Date;
 24  
 import java.util.List;
 25  
 
 26  
 /**
 27  
  * ArchivaAuditLogsConstraint
 28  
  */
 29  
 public class ArchivaAuditLogsConstraint
 30  
     extends RangeConstraint
 31  
 {
 32  
     private String whereClause;
 33  
     
 34  
     private void createWhereClause( String desiredArtifact, String desiredRepositoryId, String desiredEvent,
 35  
                                     Date startDate, Date endDate )
 36  
     {
 37  0
         whereClause = "eventDate >= desiredStartDate && eventDate <= desiredEndDate";        
 38  0
         declImports = new String[] { "import java.util.Date" };
 39  
                 
 40  0
         List<String> declParamsList = new ArrayList<String>();
 41  0
         declParamsList.add( "Date desiredStartDate" );
 42  0
         declParamsList.add( "Date desiredEndDate" );
 43  
 
 44  0
         List<Object> paramsList = new ArrayList<Object>();
 45  0
         paramsList.add( startDate );
 46  0
         paramsList.add( endDate );
 47  
 
 48  0
         if ( desiredArtifact != null && !"".equals( desiredArtifact ) )
 49  
         {
 50  0
             whereClause = whereClause + " && artifact.like(desiredArtifact)";
 51  0
             declParamsList.add( "String desiredArtifact" );
 52  0
             paramsList.add( desiredArtifact );            
 53  
         }
 54  
 
 55  0
         if ( desiredRepositoryId != null && !"".equals( desiredRepositoryId ) )
 56  
         {
 57  0
             whereClause = whereClause + " && repositoryId == desiredRepositoryId";
 58  0
             declParamsList.add( "String desiredRepositoryId" );
 59  0
             paramsList.add( desiredRepositoryId );
 60  
         }
 61  
 
 62  0
         if ( desiredEvent != null && !"".equals( desiredEvent ) )
 63  
         {
 64  0
             whereClause = whereClause + " && event ==  desiredEvent";
 65  0
             declParamsList.add( "String desiredEvent" );
 66  0
             paramsList.add( desiredEvent );
 67  
         }
 68  
 
 69  0
         int size = declParamsList.size();
 70  0
         int i = 0;
 71  0
         declParams = new String[size];       
 72  
         
 73  0
         while( i < size )
 74  
         {
 75  0
             declParams[i] = declParamsList.get( i );
 76  0
             i++;
 77  
         }        
 78  
         
 79  0
         params = paramsList.toArray();
 80  0
     }
 81  
 
 82  
     public ArchivaAuditLogsConstraint( int[] range, String desiredArtifact, String desiredRepositoryId,
 83  
                                        String desiredEvent, Date startDate, Date endDate )
 84  
     {
 85  0
         super( range );
 86  0
         createWhereClause( desiredArtifact, desiredRepositoryId, desiredEvent, startDate, endDate );
 87  0
     }
 88  
     
 89  
     public ArchivaAuditLogsConstraint( String desiredArtifact, String desiredRepositoryId,
 90  
                                        String desiredEvent, Date startDate, Date endDate )
 91  
     {
 92  0
         super();
 93  0
         createWhereClause( desiredArtifact, desiredRepositoryId, desiredEvent, startDate, endDate );
 94  0
     }
 95  
 
 96  
 
 97  
     public String getSortColumn()
 98  
     {
 99  0
         return "eventDate";
 100  
     }
 101  
 
 102  
     public String getWhereCondition()
 103  
     {
 104  0
         return whereClause;
 105  
     }
 106  
 }