001/**
002 * Copyright 2005-2016 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.kew.rule.dao.impl;
017
018import javax.persistence.EntityManager;
019import javax.persistence.PersistenceContext;
020
021import org.kuali.rice.core.framework.persistence.jpa.OrmUtils;
022import org.kuali.rice.kew.rule.RuleTemplateOptionBo;
023import org.kuali.rice.kew.rule.dao.RuleTemplateOptionDAO;
024
025
026public class RuleTemplateOptionDAOJpaImpl implements RuleTemplateOptionDAO {
027
028        @PersistenceContext(unitName="kew-unit")
029        private EntityManager entityManager;
030        
031  /*
032   * (non-Javadoc)
033   * @see org.kuali.rice.kew.rule.dao.RuleTemplateOptionDAO#delete(java.lang.Long)
034   */
035  public void delete(String ruleTemplateOptionId) {
036          entityManager.remove(findByRuleTemplateOptionId(ruleTemplateOptionId));
037  }
038
039  /*
040   * (non-Javadoc)
041   * @see org.kuali.rice.kew.rule.dao.RuleTemplateOptionDAO#findByRuleTemplateOptionId(java.lang.Long)
042   */
043  public RuleTemplateOptionBo findByRuleTemplateOptionId(String ruleTemplateOptionId) {
044          return entityManager.find(RuleTemplateOptionBo.class, ruleTemplateOptionId);
045  }
046  
047  public void save (RuleTemplateOptionBo ruleTemplateOption){
048          if(ruleTemplateOption.getId()==null){
049                  entityManager.persist(ruleTemplateOption);
050          }else{
051                  OrmUtils.merge(entityManager, ruleTemplateOption);
052          }
053  }
054
055    public EntityManager getEntityManager() {
056        return this.entityManager;
057    }
058    
059    public void setEntityManager(EntityManager entityManager) {
060        this.entityManager = entityManager;
061    }
062}