Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * #%L
   * BroadleafCommerce Framework
   * %%
   * Copyright (C) 2009 - 2013 Broadleaf Commerce
   * %%
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
  * 
  *       http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * #L%
  */
 package org.broadleafcommerce.core.offer.dao;
 
 
 import java.util.Date;
 import java.util.List;
 
 
 @Repository("blOfferDao")
 public class OfferDaoImpl implements OfferDao {
 
     @PersistenceContext(unitName="blPU")
     protected EntityManager em;
 
     @Resource(name="blEntityConfiguration")
 
     protected Long currentDateResolution = 10000L;
     protected Date cachedDate = SystemTime.asDate();
 
         Date returnDate = SystemTime.getCurrentDateWithinTimeResolution();
         if (returnDate != ) {
             if (SystemTime.shouldCacheDate()) {
                  = returnDate;
             }
         }
         return returnDate;
     }
 
     @Override
     public Offer create() {
         return ((Offer.createEntityInstance(Offer.class.getName()));
     }
 
     @Override
     public OfferInfo createOfferInfo() {
         return ((OfferInfo.createEntityInstance(OfferInfo.class.getName()));
     }
 
     @Override
     }
 
     @Override
     }
 
     @Override
     }
 
     @Override
     }
    @Override
    }
    @Override
    }
    @Override
    }
    @Override
    public void delete(Offer offer) {
        ((Statusoffer).setArchived('Y');
        .merge(offer);
    }
    @Override
    public void delete(OfferInfo offerInfo) {
        if (!.contains(offerInfo)) {
            offerInfo = (OfferInfo.find(.lookupEntityClass(OfferInfo.class.getName()), offerInfo.getId());
        }
        .remove(offerInfo);
    }
    @Override
    public Offer save(Offer offer) {
        return .merge(offer);
    }
    @Override
    public OfferInfo save(OfferInfo offerInfo) {
        return .merge(offerInfo);
    }
    @Override
    public List<OfferreadAllOffers() {
        Query query = .createNamedQuery("BC_READ_ALL_OFFERS");
        return query.getResultList();
    }
    @Override
    public Offer readOfferById(Long offerId) {
        return .find(OfferImpl.classofferId);
    }
    @Override
        //TODO change this to a JPA criteria
        Criteria criteria = ((HibernateEntityManager).getSession().createCriteria(OfferImpl.class);
        Calendar c = Calendar.getInstance();
        c.setTime(myDate);
        c.add(., +1);
        criteria.add(Restrictions.lt("startDate"c.getTime()));
        c = Calendar.getInstance();
        c.setTime(myDate);
        c.add(., -1);
        criteria.add(Restrictions.or(Restrictions.isNull("endDate"), Restrictions.gt("endDate"c.getTime())));
        criteria.add(Restrictions.or(Restrictions.eq("archiveStatus.archived"'N'),
                Restrictions.isNull("archiveStatus.archived")));
        // Automatically Added or (Automatically Added is null and deliveryType is Automatic)
        criteria.add(Restrictions.or(Restrictions.eq("automaticallyAdded"true),
                Restrictions.and(Restrictions.isNull("automaticallyAdded"),
                        Restrictions.eq("deliveryType""AUTOMATIC"))));
        criteria.setCacheable(true);
        criteria.setCacheRegion("query.Offer");
        return criteria.list();
    }
    @Override
    public Long getCurrentDateResolution() {
        return ;
    }
    @Override
    public void setCurrentDateResolution(Long currentDateResolution) {
        this. = currentDateResolution;
    }
New to GrepCode? Check out our FAQ X