| 1 |  |   | 
  | 2 |  |   | 
  | 3 |  |   | 
  | 4 |  |   | 
  | 5 |  |   | 
  | 6 |  |   | 
  | 7 |  |   | 
  | 8 |  |   | 
  | 9 |  |   | 
  | 10 |  |   | 
  | 11 |  |   | 
  | 12 |  |   | 
  | 13 |  |   | 
  | 14 |  |   | 
  | 15 |  |   | 
  | 16 |  |   | 
  | 17 |  |  package org.kuali.rice.kew.useroptions.dao.impl; | 
  | 18 |  |   | 
  | 19 |  |  import org.apache.ojb.broker.PersistenceBroker; | 
  | 20 |  |  import org.apache.ojb.broker.query.Criteria; | 
  | 21 |  |  import org.apache.ojb.broker.query.QueryByCriteria; | 
  | 22 |  |  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; | 
  | 23 |  |  import org.kuali.rice.core.api.util.RiceConstants; | 
  | 24 |  |  import org.kuali.rice.core.framework.persistence.platform.DatabasePlatform; | 
  | 25 |  |  import org.kuali.rice.kew.useroptions.UserOptions; | 
  | 26 |  |  import org.kuali.rice.kew.useroptions.dao.UserOptionsDAO; | 
  | 27 |  |  import org.springmodules.orm.ojb.PersistenceBrokerCallback; | 
  | 28 |  |  import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport; | 
  | 29 |  |   | 
  | 30 |  |  import java.util.ArrayList; | 
  | 31 |  |  import java.util.Collection; | 
  | 32 |  |  import java.util.List; | 
  | 33 |  |   | 
  | 34 |  |   | 
  | 35 | 0 |  public class UserOptionsDAOOjbImpl extends PersistenceBrokerDaoSupport implements UserOptionsDAO { | 
  | 36 |  |   | 
  | 37 |  |          public Long getNewOptionIdForActionList() { | 
  | 38 | 0 |          return (Long)this.getPersistenceBrokerTemplate().execute(new PersistenceBrokerCallback() { | 
  | 39 |  |              public Object doInPersistenceBroker(PersistenceBroker broker) { | 
  | 40 | 0 |                      return getPlatform().getNextValSQL("KREW_ACTN_LIST_OPTN_S", broker); | 
  | 41 |  |              } | 
  | 42 |  |          }); | 
  | 43 |  |      } | 
  | 44 |  |   | 
  | 45 |  |          protected DatabasePlatform getPlatform() { | 
  | 46 | 0 |              return (DatabasePlatform)GlobalResourceLoader.getService(RiceConstants.DB_PLATFORM); | 
  | 47 |  |      } | 
  | 48 |  |   | 
  | 49 |  |      public List<UserOptions> findByUserQualified(String principalId, String likeString) { | 
  | 50 | 0 |          Criteria criteria = new Criteria(); | 
  | 51 | 0 |          criteria.addEqualTo("workflowId", principalId); | 
  | 52 | 0 |          criteria.addLike("optionId", likeString); | 
  | 53 | 0 |          return new ArrayList<UserOptions>(this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(UserOptions.class, criteria))); | 
  | 54 |  |      } | 
  | 55 |  |   | 
  | 56 |  |      public void deleteByUserQualified(String principalId, String likeString) { | 
  | 57 | 0 |          Criteria criteria = new Criteria(); | 
  | 58 | 0 |          criteria.addEqualTo("workflowId", principalId); | 
  | 59 | 0 |          criteria.addLike("optionId", likeString); | 
  | 60 | 0 |          this.getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(UserOptions.class, criteria)); | 
  | 61 | 0 |      } | 
  | 62 |  |   | 
  | 63 |  |      public Collection<UserOptions> findByWorkflowUser(String principalId) { | 
  | 64 | 0 |          UserOptions userOptions = new UserOptions(); | 
  | 65 | 0 |          userOptions.setWorkflowId(principalId); | 
  | 66 | 0 |          return this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(userOptions)); | 
  | 67 |  |      } | 
  | 68 |  |   | 
  | 69 |  |      public void save(UserOptions userOptions) { | 
  | 70 | 0 |              this.getPersistenceBrokerTemplate().store(userOptions); | 
  | 71 | 0 |      } | 
  | 72 |  |       | 
  | 73 |  |      public void save(Collection<UserOptions> userOptions) { | 
  | 74 | 0 |              if (userOptions != null) for (UserOptions option : userOptions) { | 
  | 75 | 0 |                      this.getPersistenceBrokerTemplate().store(option); | 
  | 76 |  |              } | 
  | 77 | 0 |      } | 
  | 78 |  |       | 
  | 79 |  |      public void deleteUserOptions(UserOptions userOptions) { | 
  | 80 | 0 |              this.getPersistenceBrokerTemplate().delete(userOptions); | 
  | 81 | 0 |      } | 
  | 82 |  |   | 
  | 83 |  |      public UserOptions findByOptionId(String optionId, String principalId) { | 
  | 84 | 0 |          UserOptions userOptions = new UserOptions(); | 
  | 85 | 0 |          userOptions.setOptionId(optionId); | 
  | 86 | 0 |          userOptions.setWorkflowId(principalId); | 
  | 87 | 0 |          return (UserOptions) this.getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(userOptions)); | 
  | 88 |  |      } | 
  | 89 |  |   | 
  | 90 |  |      public Collection<UserOptions> findByOptionValue(String optionId, String optionValue) { | 
  | 91 | 0 |          UserOptions userOptions = new UserOptions(); | 
  | 92 | 0 |          userOptions.setOptionId(optionId); | 
  | 93 | 0 |          userOptions.setOptionVal(optionValue); | 
  | 94 | 0 |          return this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(userOptions)); | 
  | 95 |  |      } | 
  | 96 |  |  } |