Examples of SlopeOneTuple


Examples of saasppcf.webapp.server.persistence.entity.SlopeOneTuple

   * @param secondItem
   * @return
   */
  public SlopeOneTuple get(String firstItem, String secondItem) {
    String compositeKey = StringUtilities.generateUniqueID(firstItem, secondItem).toString();
    SlopeOneTuple find = manager.find(SlopeOneTuple.class, compositeKey);
    if(find!=null) {
      if(find.getSecondItem().compareTo(firstItem)==0) {
        //there has been a reversal, so set the deviation accordingly
        find.setDeviation(0-find.getDeviation());
      }
    }
    return find;
  }
View Full Code Here

Examples of saasppcf.webapp.server.persistence.entity.SlopeOneTuple

   *
   * @param tuple
   */
  public boolean put(SlopeOneTuple tuple) {
    String compositeKey = StringUtilities.generateUniqueID(tuple.getFirstItem(), tuple.getSecondItem()).toString();
    SlopeOneTuple find = manager.find(SlopeOneTuple.class, compositeKey);
    EntityTransaction txn = manager.getTransaction();
    txn.begin();
    if(find!=null) {
      find.setCardinality(tuple.getCardinality());
      if(find.getSecondItem().compareTo(tuple.getFirstItem())==0) {
        //there has been a reversal, so set the deviation accordingly
        find.setDeviation(0-tuple.getDeviation());
      }
      else {
        find.setDeviation(tuple.getDeviation());
      }
    }
    else {
      manager.persist(find);
    }
View Full Code Here

Examples of saasppcf.webapp.server.persistence.entity.SlopeOneTuple

   *
   * @param tuple
   */
  public boolean add(SlopeOneTuple tuple) {
    String compositeKey = StringUtilities.generateUniqueID(tuple.getFirstItem(), tuple.getSecondItem()).toString();
    SlopeOneTuple find = manager.find(SlopeOneTuple.class, compositeKey);
    EntityTransaction txn = manager.getTransaction();
    txn.begin();
    if(find!=null) {
      find.setCardinality(find.getCardinality() + tuple.getCardinality());
      if(find.getSecondItem().compareTo(tuple.getFirstItem())==0) {
        //there has been a reversal, so set the deviation accordingly
        find.setDeviation(0 - find.getDeviation() - tuple.getDeviation());
      }
      else {
        find.setDeviation(find.getDeviation() + tuple.getDeviation());
      }
    }
    else {
      manager.persist(find);
    }
View Full Code Here

Examples of saasppcf.webapp.server.persistence.entity.SlopeOneTuple

  /**
   * Deletes a SlopeOne tuple for an item-item pair from the datastore.
   */
  public boolean remove(SlopeOneTuple tuple) {
    String compositeKey = StringUtilities.generateUniqueID(tuple.getFirstItem(), tuple.getSecondItem()).toString();
    SlopeOneTuple find = manager.find(SlopeOneTuple.class, compositeKey);
    if(find!=null) {
      EntityTransaction txn = manager.getTransaction();
      txn.begin();
      manager.remove(find);
      try {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.