Package com.changestuffs.shared.actions

Examples of com.changestuffs.shared.actions.UpdateOfferResult


  @Logued
  @Validate
  @Override
  public UpdateOfferResult execute(@Valid UpdateOfferAction action,
      ExecutionContext context) throws ActionException {
    UpdateOfferResult result = null;
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    ArticlesOAM oam = provider.get();
    result = oam.updateOffer(user.getEmail(), action.getOfferId(),
        action.getProductIdNames());
View Full Code Here


    return result;
  }
 
  @Transactional
  public UpdateOfferResult updateOffer(String userId, String offerId, Map<String,String> productIdNames){
    UpdateOfferResult result = null;
    Offer offer = model.find(Offer.class, KeyFactory.stringToKey(offerId));
    if(!userId.equals(offer.getUserId())){
      log.log(Level.WARNING, "User "+userId+" is trying to update an offer of "+offer.getUserId());
      return null;
    }
    Set<ProductOffered> offers = new HashSet<ProductOffered>();
    for(Entry<String,String> entry : productIdNames.entrySet()){
      ProductOffered productOffered = new ProductOffered();
      productOffered.setOffer(offer);
      productOffered.setProductId(entry.getKey());
      productOffered.setProductName(entry.getValue());
      offers.add(productOffered);
      model.persist(productOffered);
    }
    offer.setProductOffered(offers);
    result = new UpdateOfferResult(new OffersPerProduct(offerId, KeyFactory.keyToString(offer.getProduct().getKey()), offer.getProduct().getName(), productIdNames));
    log.info("Offer updated");
    return result;
  }
View Full Code Here

TOP

Related Classes of com.changestuffs.shared.actions.UpdateOfferResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.