1 16 package org.outerj.daisy.query.model; 17 18 import org.outerj.daisy.query.QueryContext; 19 import org.outerj.daisy.repository.query.QueryException; 20 import org.outerj.daisy.repository.query.EvaluationContext; 21 import org.outerj.daisy.repository.Document; 22 import org.outerj.daisy.repository.Version; 23 24 import java.sql.PreparedStatement ; 25 import java.sql.SQLException ; 26 27 public class HasPartWithMimeType extends AbstractPredicateExpr { 28 private final String mimeType; 29 30 public HasPartWithMimeType(String mimeType) { 31 this.mimeType = mimeType; 32 } 33 34 public void prepare(QueryContext context) throws QueryException { 35 } 37 38 public boolean evaluate(Document document, Version version, EvaluationContext evaluationContext) throws QueryException { 39 return false; 40 } 41 42 public void generateSql(StringBuffer sql, SqlGenerationContext context) throws QueryException { 43 String alias = context.getNewPartsTableAlias(); 44 45 sql.append(alias); 46 sql.append('.'); 47 sql.append(SqlGenerationContext.PartsTable.MIMETYPE); 48 sql.append(" LIKE ?"); 49 } 50 51 public int bindSql(PreparedStatement stmt, int bindPos, EvaluationContext evaluationContext) throws SQLException { 52 stmt.setString(bindPos, mimeType); 53 bindPos++; 54 return bindPos; 55 } 56 57 public AclConditionViolation isAclAllowed() { 58 return new AclConditionViolation("HasPartWithMimeType is not allowed in ACL conditions"); 59 } 60 61 public Tristate appliesTo(Document document) { 62 throw new IllegalStateException (); 63 } 64 } 65 | Popular Tags |