1 13 14 19 package org.ejbca.util.query; 20 21 32 public class ApprovalMatch extends BasicMatch { 33 35 public static final int MATCH_WITH_UNIQUEID = 0; 36 public static final int MATCH_WITH_APPROVALID = 1; 37 public static final int MATCH_WITH_APPROVALTYPE = 2; 38 public static final int MATCH_WITH_ENDENTITYPROFILEID = 3; 39 public static final int MATCH_WITH_CAID = 4; 40 public static final int MATCH_WITH_REQUESTADMINCERTISSUERDN = 5; 41 public static final int MATCH_WITH_REQUESTADMINCERTSERIALNUMBER = 6; 42 public static final int MATCH_WITH_STATUS = 7; 43 public static final int MATCH_WITH_REMAININGAPPROVALS = 8; 44 45 46 47 48 static final String [] MATCH_WITH_SQLNAMES = {"id","approvalid", "approvaltype", "endentityprofileid", "caid" 50 , "reqadmincertissuerdn", "reqadmincertsn", "status", "remainingapprovals"}; 52 53 55 65 public ApprovalMatch(int matchwith, int matchtype, String matchvalue) 66 throws NumberFormatException { 67 this.matchwith = matchwith; 68 this.matchtype = matchtype; 69 this.matchvalue = matchvalue; 70 71 if (matchwith != MATCH_WITH_REQUESTADMINCERTISSUERDN && 74 matchwith != MATCH_WITH_REQUESTADMINCERTSERIALNUMBER){ 75 new Integer (matchvalue); 76 } 77 } 78 79 84 public String getQueryString() { 85 String returnval = ""; 86 87 if (matchtype == BasicMatch.MATCH_TYPE_EQUALS) { 88 String stringChar = "'"; 91 if ((matchwith >= MATCH_WITH_UNIQUEID && matchwith <= MATCH_WITH_CAID) || (matchwith == MATCH_WITH_STATUS) || (matchwith == MATCH_WITH_REMAININGAPPROVALS)) { 92 stringChar = ""; 93 } 94 returnval = MATCH_WITH_SQLNAMES[matchwith] + " = "+stringChar + matchvalue + stringChar; 95 } 96 97 if (matchtype == BasicMatch.MATCH_TYPE_BEGINSWITH) { 98 returnval = MATCH_WITH_SQLNAMES[matchwith] + " LIKE '" + matchvalue + "%'"; 99 } 100 101 if (matchtype == BasicMatch.MATCH_TYPE_CONTAINS) { 102 returnval = MATCH_WITH_SQLNAMES[matchwith] + " LIKE '%" + matchvalue + "%'"; 103 } 104 105 return returnval; 106 } 107 108 110 115 public boolean isLegalQuery() { 116 return !(matchvalue.trim().equals("")); 117 } 118 119 private int matchwith; 122 private int matchtype; 123 private String matchvalue; 124 } 125 | Popular Tags |