1 package org.apache.maven.archiva.database.constraints;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
22 import java.util.ArrayList;
23 import java.util.Date;
24 import java.util.List;
27 * ArchivaAuditLogsConstraint
29 public class ArchivaAuditLogsConstraint
30 extends RangeConstraint
32 private String whereClause;
34 private void createWhereClause( String desiredArtifact, String desiredRepositoryId, String desiredEvent,
35 Date startDate, Date endDate )
37 whereClause = "eventDate >= desiredStartDate && eventDate <= desiredEndDate";
38 declImports = new String[] { "import java.util.Date" };
40 List<String> declParamsList = new ArrayList<String>();
41 declParamsList.add( "Date desiredStartDate" );
42 declParamsList.add( "Date desiredEndDate" );
44 List<Object> paramsList = new ArrayList<Object>();
45 paramsList.add( startDate );
46 paramsList.add( endDate );
48 if ( desiredArtifact != null && !"".equals( desiredArtifact ) )
50 whereClause = whereClause + " && artifact.like(desiredArtifact)";
51 declParamsList.add( "String desiredArtifact" );
52 paramsList.add( desiredArtifact );
55 if ( desiredRepositoryId != null && !"".equals( desiredRepositoryId ) )
57 whereClause = whereClause + " && repositoryId == desiredRepositoryId";
58 declParamsList.add( "String desiredRepositoryId" );
59 paramsList.add( desiredRepositoryId );
62 if ( desiredEvent != null && !"".equals( desiredEvent ) )
64 whereClause = whereClause + " && event == desiredEvent";
65 declParamsList.add( "String desiredEvent" );
66 paramsList.add( desiredEvent );
69 int size = declParamsList.size();
71 declParams = new String[size];
75 declParams[i] = declParamsList.get( i );
79 params = paramsList.toArray();
82 public ArchivaAuditLogsConstraint( int[] range, String desiredArtifact, String desiredRepositoryId,
83 String desiredEvent, Date startDate, Date endDate )
86 createWhereClause( desiredArtifact, desiredRepositoryId, desiredEvent, startDate, endDate );
89 public ArchivaAuditLogsConstraint( String desiredArtifact, String desiredRepositoryId,
90 String desiredEvent, Date startDate, Date endDate )
93 createWhereClause( desiredArtifact, desiredRepositoryId, desiredEvent, startDate, endDate );
97 public String getSortColumn()
102 public String getWhereCondition()