Subversion Repositories SmartDukaan

Rev

Rev 2717 | Rev 2981 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2717 Rev 2816
Line 141... Line 141...
141
 
141
 
142
    /**
142
    /**
143
     * Creates a transaction and multiple orders for the given cart. Returns the transaction ID created.
143
     * Creates a transaction and multiple orders for the given cart. Returns the transaction ID created.
144
     * 
144
     * 
145
     * @param cartId
145
     * @param cartId
-
 
146
     * @param sessionSource
-
 
147
     * @param sessionStartTime
146
     */
148
     */
147
    public long createOrders(long cartId) throws ShoppingCartException, TException;
149
    public long createOrders(long cartId, String sessionSource, long sessionStartTime) throws ShoppingCartException, TException;
148
 
150
 
149
    /**
151
    /**
150
     * Validates that:
152
     * Validates that:
151
     * 1. The checkout timestamp is greater than the updatedOn timestamp.
153
     * 1. The checkout timestamp is greater than the updatedOn timestamp.
152
     * 2. All of the lines in the cart are active items.
154
     * 2. All of the lines in the cart are active items.
Line 2186... Line 2188...
2186
        throw result.scx;
2188
        throw result.scx;
2187
      }
2189
      }
2188
      return;
2190
      return;
2189
    }
2191
    }
2190
 
2192
 
2191
    public long createOrders(long cartId) throws ShoppingCartException, TException
2193
    public long createOrders(long cartId, String sessionSource, long sessionStartTime) throws ShoppingCartException, TException
2192
    {
2194
    {
2193
      send_createOrders(cartId);
2195
      send_createOrders(cartId, sessionSource, sessionStartTime);
2194
      return recv_createOrders();
2196
      return recv_createOrders();
2195
    }
2197
    }
2196
 
2198
 
2197
    public void send_createOrders(long cartId) throws TException
2199
    public void send_createOrders(long cartId, String sessionSource, long sessionStartTime) throws TException
2198
    {
2200
    {
2199
      oprot_.writeMessageBegin(new TMessage("createOrders", TMessageType.CALL, seqid_));
2201
      oprot_.writeMessageBegin(new TMessage("createOrders", TMessageType.CALL, seqid_));
2200
      createOrders_args args = new createOrders_args();
2202
      createOrders_args args = new createOrders_args();
2201
      args.cartId = cartId;
2203
      args.cartId = cartId;
-
 
2204
      args.sessionSource = sessionSource;
-
 
2205
      args.sessionStartTime = sessionStartTime;
2202
      args.write(oprot_);
2206
      args.write(oprot_);
2203
      oprot_.writeMessageEnd();
2207
      oprot_.writeMessageEnd();
2204
      oprot_.getTransport().flush();
2208
      oprot_.getTransport().flush();
2205
    }
2209
    }
2206
 
2210
 
Line 4296... Line 4300...
4296
        createOrders_args args = new createOrders_args();
4300
        createOrders_args args = new createOrders_args();
4297
        args.read(iprot);
4301
        args.read(iprot);
4298
        iprot.readMessageEnd();
4302
        iprot.readMessageEnd();
4299
        createOrders_result result = new createOrders_result();
4303
        createOrders_result result = new createOrders_result();
4300
        try {
4304
        try {
4301
          result.success = iface_.createOrders(args.cartId);
4305
          result.success = iface_.createOrders(args.cartId, args.sessionSource, args.sessionStartTime);
4302
          result.setSuccessIsSet(true);
4306
          result.setSuccessIsSet(true);
4303
        } catch (ShoppingCartException scx) {
4307
        } catch (ShoppingCartException scx) {
4304
          result.scx = scx;
4308
          result.scx = scx;
4305
        } catch (Throwable th) {
4309
        } catch (Throwable th) {
4306
          LOGGER.error("Internal error processing createOrders", th);
4310
          LOGGER.error("Internal error processing createOrders", th);
Line 41694... Line 41698...
41694
 
41698
 
41695
  public static class createOrders_args implements TBase<createOrders_args._Fields>, java.io.Serializable, Cloneable, Comparable<createOrders_args>   {
41699
  public static class createOrders_args implements TBase<createOrders_args._Fields>, java.io.Serializable, Cloneable, Comparable<createOrders_args>   {
41696
    private static final TStruct STRUCT_DESC = new TStruct("createOrders_args");
41700
    private static final TStruct STRUCT_DESC = new TStruct("createOrders_args");
41697
 
41701
 
41698
    private static final TField CART_ID_FIELD_DESC = new TField("cartId", TType.I64, (short)1);
41702
    private static final TField CART_ID_FIELD_DESC = new TField("cartId", TType.I64, (short)1);
-
 
41703
    private static final TField SESSION_SOURCE_FIELD_DESC = new TField("sessionSource", TType.STRING, (short)2);
-
 
41704
    private static final TField SESSION_START_TIME_FIELD_DESC = new TField("sessionStartTime", TType.I64, (short)3);
41699
 
41705
 
41700
    private long cartId;
41706
    private long cartId;
-
 
41707
    private String sessionSource;
-
 
41708
    private long sessionStartTime;
41701
 
41709
 
41702
    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
41710
    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
41703
    public enum _Fields implements TFieldIdEnum {
41711
    public enum _Fields implements TFieldIdEnum {
41704
      CART_ID((short)1, "cartId");
41712
      CART_ID((short)1, "cartId"),
-
 
41713
      SESSION_SOURCE((short)2, "sessionSource"),
-
 
41714
      SESSION_START_TIME((short)3, "sessionStartTime");
41705
 
41715
 
41706
      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
41716
      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
41707
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
41717
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
41708
 
41718
 
41709
      static {
41719
      static {
Line 41754... Line 41764...
41754
      }
41764
      }
41755
    }
41765
    }
41756
 
41766
 
41757
    // isset id assignments
41767
    // isset id assignments
41758
    private static final int __CARTID_ISSET_ID = 0;
41768
    private static final int __CARTID_ISSET_ID = 0;
-
 
41769
    private static final int __SESSIONSTARTTIME_ISSET_ID = 1;
41759
    private BitSet __isset_bit_vector = new BitSet(1);
41770
    private BitSet __isset_bit_vector = new BitSet(2);
41760
 
41771
 
41761
    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
41772
    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
41762
      put(_Fields.CART_ID, new FieldMetaData("cartId", TFieldRequirementType.DEFAULT, 
41773
      put(_Fields.CART_ID, new FieldMetaData("cartId", TFieldRequirementType.DEFAULT, 
41763
          new FieldValueMetaData(TType.I64)));
41774
          new FieldValueMetaData(TType.I64)));
-
 
41775
      put(_Fields.SESSION_SOURCE, new FieldMetaData("sessionSource", TFieldRequirementType.DEFAULT, 
-
 
41776
          new FieldValueMetaData(TType.STRING)));
-
 
41777
      put(_Fields.SESSION_START_TIME, new FieldMetaData("sessionStartTime", TFieldRequirementType.DEFAULT, 
-
 
41778
          new FieldValueMetaData(TType.I64)));
41764
    }});
41779
    }});
41765
 
41780
 
41766
    static {
41781
    static {
41767
      FieldMetaData.addStructMetaDataMap(createOrders_args.class, metaDataMap);
41782
      FieldMetaData.addStructMetaDataMap(createOrders_args.class, metaDataMap);
41768
    }
41783
    }
41769
 
41784
 
41770
    public createOrders_args() {
41785
    public createOrders_args() {
41771
    }
41786
    }
41772
 
41787
 
41773
    public createOrders_args(
41788
    public createOrders_args(
41774
      long cartId)
41789
      long cartId,
-
 
41790
      String sessionSource,
-
 
41791
      long sessionStartTime)
41775
    {
41792
    {
41776
      this();
41793
      this();
41777
      this.cartId = cartId;
41794
      this.cartId = cartId;
41778
      setCartIdIsSet(true);
41795
      setCartIdIsSet(true);
-
 
41796
      this.sessionSource = sessionSource;
-
 
41797
      this.sessionStartTime = sessionStartTime;
-
 
41798
      setSessionStartTimeIsSet(true);
41779
    }
41799
    }
41780
 
41800
 
41781
    /**
41801
    /**
41782
     * Performs a deep copy on <i>other</i>.
41802
     * Performs a deep copy on <i>other</i>.
41783
     */
41803
     */
41784
    public createOrders_args(createOrders_args other) {
41804
    public createOrders_args(createOrders_args other) {
41785
      __isset_bit_vector.clear();
41805
      __isset_bit_vector.clear();
41786
      __isset_bit_vector.or(other.__isset_bit_vector);
41806
      __isset_bit_vector.or(other.__isset_bit_vector);
41787
      this.cartId = other.cartId;
41807
      this.cartId = other.cartId;
-
 
41808
      if (other.isSetSessionSource()) {
-
 
41809
        this.sessionSource = other.sessionSource;
-
 
41810
      }
-
 
41811
      this.sessionStartTime = other.sessionStartTime;
41788
    }
41812
    }
41789
 
41813
 
41790
    public createOrders_args deepCopy() {
41814
    public createOrders_args deepCopy() {
41791
      return new createOrders_args(this);
41815
      return new createOrders_args(this);
41792
    }
41816
    }
Line 41817... Line 41841...
41817
 
41841
 
41818
    public void setCartIdIsSet(boolean value) {
41842
    public void setCartIdIsSet(boolean value) {
41819
      __isset_bit_vector.set(__CARTID_ISSET_ID, value);
41843
      __isset_bit_vector.set(__CARTID_ISSET_ID, value);
41820
    }
41844
    }
41821
 
41845
 
-
 
41846
    public String getSessionSource() {
-
 
41847
      return this.sessionSource;
-
 
41848
    }
-
 
41849
 
-
 
41850
    public createOrders_args setSessionSource(String sessionSource) {
-
 
41851
      this.sessionSource = sessionSource;
-
 
41852
      return this;
-
 
41853
    }
-
 
41854
 
-
 
41855
    public void unsetSessionSource() {
-
 
41856
      this.sessionSource = null;
-
 
41857
    }
-
 
41858
 
-
 
41859
    /** Returns true if field sessionSource is set (has been asigned a value) and false otherwise */
-
 
41860
    public boolean isSetSessionSource() {
-
 
41861
      return this.sessionSource != null;
-
 
41862
    }
-
 
41863
 
-
 
41864
    public void setSessionSourceIsSet(boolean value) {
-
 
41865
      if (!value) {
-
 
41866
        this.sessionSource = null;
-
 
41867
      }
-
 
41868
    }
-
 
41869
 
-
 
41870
    public long getSessionStartTime() {
-
 
41871
      return this.sessionStartTime;
-
 
41872
    }
-
 
41873
 
-
 
41874
    public createOrders_args setSessionStartTime(long sessionStartTime) {
-
 
41875
      this.sessionStartTime = sessionStartTime;
-
 
41876
      setSessionStartTimeIsSet(true);
-
 
41877
      return this;
-
 
41878
    }
-
 
41879
 
-
 
41880
    public void unsetSessionStartTime() {
-
 
41881
      __isset_bit_vector.clear(__SESSIONSTARTTIME_ISSET_ID);
-
 
41882
    }
-
 
41883
 
-
 
41884
    /** Returns true if field sessionStartTime is set (has been asigned a value) and false otherwise */
-
 
41885
    public boolean isSetSessionStartTime() {
-
 
41886
      return __isset_bit_vector.get(__SESSIONSTARTTIME_ISSET_ID);
-
 
41887
    }
-
 
41888
 
-
 
41889
    public void setSessionStartTimeIsSet(boolean value) {
-
 
41890
      __isset_bit_vector.set(__SESSIONSTARTTIME_ISSET_ID, value);
-
 
41891
    }
-
 
41892
 
41822
    public void setFieldValue(_Fields field, Object value) {
41893
    public void setFieldValue(_Fields field, Object value) {
41823
      switch (field) {
41894
      switch (field) {
41824
      case CART_ID:
41895
      case CART_ID:
41825
        if (value == null) {
41896
        if (value == null) {
41826
          unsetCartId();
41897
          unsetCartId();
41827
        } else {
41898
        } else {
41828
          setCartId((Long)value);
41899
          setCartId((Long)value);
41829
        }
41900
        }
41830
        break;
41901
        break;
41831
 
41902
 
-
 
41903
      case SESSION_SOURCE:
-
 
41904
        if (value == null) {
-
 
41905
          unsetSessionSource();
-
 
41906
        } else {
-
 
41907
          setSessionSource((String)value);
-
 
41908
        }
-
 
41909
        break;
-
 
41910
 
-
 
41911
      case SESSION_START_TIME:
-
 
41912
        if (value == null) {
-
 
41913
          unsetSessionStartTime();
-
 
41914
        } else {
-
 
41915
          setSessionStartTime((Long)value);
-
 
41916
        }
-
 
41917
        break;
-
 
41918
 
41832
      }
41919
      }
41833
    }
41920
    }
41834
 
41921
 
41835
    public void setFieldValue(int fieldID, Object value) {
41922
    public void setFieldValue(int fieldID, Object value) {
41836
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
41923
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
Line 41839... Line 41926...
41839
    public Object getFieldValue(_Fields field) {
41926
    public Object getFieldValue(_Fields field) {
41840
      switch (field) {
41927
      switch (field) {
41841
      case CART_ID:
41928
      case CART_ID:
41842
        return new Long(getCartId());
41929
        return new Long(getCartId());
41843
 
41930
 
-
 
41931
      case SESSION_SOURCE:
-
 
41932
        return getSessionSource();
-
 
41933
 
-
 
41934
      case SESSION_START_TIME:
-
 
41935
        return new Long(getSessionStartTime());
-
 
41936
 
41844
      }
41937
      }
41845
      throw new IllegalStateException();
41938
      throw new IllegalStateException();
41846
    }
41939
    }
41847
 
41940
 
41848
    public Object getFieldValue(int fieldId) {
41941
    public Object getFieldValue(int fieldId) {
Line 41852... Line 41945...
41852
    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
41945
    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
41853
    public boolean isSet(_Fields field) {
41946
    public boolean isSet(_Fields field) {
41854
      switch (field) {
41947
      switch (field) {
41855
      case CART_ID:
41948
      case CART_ID:
41856
        return isSetCartId();
41949
        return isSetCartId();
-
 
41950
      case SESSION_SOURCE:
-
 
41951
        return isSetSessionSource();
-
 
41952
      case SESSION_START_TIME:
-
 
41953
        return isSetSessionStartTime();
41857
      }
41954
      }
41858
      throw new IllegalStateException();
41955
      throw new IllegalStateException();
41859
    }
41956
    }
41860
 
41957
 
41861
    public boolean isSet(int fieldID) {
41958
    public boolean isSet(int fieldID) {
Line 41882... Line 41979...
41882
          return false;
41979
          return false;
41883
        if (this.cartId != that.cartId)
41980
        if (this.cartId != that.cartId)
41884
          return false;
41981
          return false;
41885
      }
41982
      }
41886
 
41983
 
-
 
41984
      boolean this_present_sessionSource = true && this.isSetSessionSource();
-
 
41985
      boolean that_present_sessionSource = true && that.isSetSessionSource();
-
 
41986
      if (this_present_sessionSource || that_present_sessionSource) {
-
 
41987
        if (!(this_present_sessionSource && that_present_sessionSource))
-
 
41988
          return false;
-
 
41989
        if (!this.sessionSource.equals(that.sessionSource))
-
 
41990
          return false;
-
 
41991
      }
-
 
41992
 
-
 
41993
      boolean this_present_sessionStartTime = true;
-
 
41994
      boolean that_present_sessionStartTime = true;
-
 
41995
      if (this_present_sessionStartTime || that_present_sessionStartTime) {
-
 
41996
        if (!(this_present_sessionStartTime && that_present_sessionStartTime))
-
 
41997
          return false;
-
 
41998
        if (this.sessionStartTime != that.sessionStartTime)
-
 
41999
          return false;
-
 
42000
      }
-
 
42001
 
41887
      return true;
42002
      return true;
41888
    }
42003
    }
41889
 
42004
 
41890
    @Override
42005
    @Override
41891
    public int hashCode() {
42006
    public int hashCode() {
Line 41906... Line 42021...
41906
      }
42021
      }
41907
      lastComparison = TBaseHelper.compareTo(cartId, typedOther.cartId);
42022
      lastComparison = TBaseHelper.compareTo(cartId, typedOther.cartId);
41908
      if (lastComparison != 0) {
42023
      if (lastComparison != 0) {
41909
        return lastComparison;
42024
        return lastComparison;
41910
      }
42025
      }
-
 
42026
      lastComparison = Boolean.valueOf(isSetSessionSource()).compareTo(isSetSessionSource());
-
 
42027
      if (lastComparison != 0) {
-
 
42028
        return lastComparison;
-
 
42029
      }
-
 
42030
      lastComparison = TBaseHelper.compareTo(sessionSource, typedOther.sessionSource);
-
 
42031
      if (lastComparison != 0) {
-
 
42032
        return lastComparison;
-
 
42033
      }
-
 
42034
      lastComparison = Boolean.valueOf(isSetSessionStartTime()).compareTo(isSetSessionStartTime());
-
 
42035
      if (lastComparison != 0) {
-
 
42036
        return lastComparison;
-
 
42037
      }
-
 
42038
      lastComparison = TBaseHelper.compareTo(sessionStartTime, typedOther.sessionStartTime);
-
 
42039
      if (lastComparison != 0) {
-
 
42040
        return lastComparison;
-
 
42041
      }
41911
      return 0;
42042
      return 0;
41912
    }
42043
    }
41913
 
42044
 
41914
    public void read(TProtocol iprot) throws TException {
42045
    public void read(TProtocol iprot) throws TException {
41915
      TField field;
42046
      TField field;
Line 41931... Line 42062...
41931
                setCartIdIsSet(true);
42062
                setCartIdIsSet(true);
41932
              } else { 
42063
              } else { 
41933
                TProtocolUtil.skip(iprot, field.type);
42064
                TProtocolUtil.skip(iprot, field.type);
41934
              }
42065
              }
41935
              break;
42066
              break;
-
 
42067
            case SESSION_SOURCE:
-
 
42068
              if (field.type == TType.STRING) {
-
 
42069
                this.sessionSource = iprot.readString();
-
 
42070
              } else { 
-
 
42071
                TProtocolUtil.skip(iprot, field.type);
-
 
42072
              }
-
 
42073
              break;
-
 
42074
            case SESSION_START_TIME:
-
 
42075
              if (field.type == TType.I64) {
-
 
42076
                this.sessionStartTime = iprot.readI64();
-
 
42077
                setSessionStartTimeIsSet(true);
-
 
42078
              } else { 
-
 
42079
                TProtocolUtil.skip(iprot, field.type);
-
 
42080
              }
-
 
42081
              break;
41936
          }
42082
          }
41937
          iprot.readFieldEnd();
42083
          iprot.readFieldEnd();
41938
        }
42084
        }
41939
      }
42085
      }
41940
      iprot.readStructEnd();
42086
      iprot.readStructEnd();
Line 41946... Line 42092...
41946
 
42092
 
41947
      oprot.writeStructBegin(STRUCT_DESC);
42093
      oprot.writeStructBegin(STRUCT_DESC);
41948
      oprot.writeFieldBegin(CART_ID_FIELD_DESC);
42094
      oprot.writeFieldBegin(CART_ID_FIELD_DESC);
41949
      oprot.writeI64(this.cartId);
42095
      oprot.writeI64(this.cartId);
41950
      oprot.writeFieldEnd();
42096
      oprot.writeFieldEnd();
-
 
42097
      if (this.sessionSource != null) {
-
 
42098
        oprot.writeFieldBegin(SESSION_SOURCE_FIELD_DESC);
-
 
42099
        oprot.writeString(this.sessionSource);
-
 
42100
        oprot.writeFieldEnd();
-
 
42101
      }
-
 
42102
      oprot.writeFieldBegin(SESSION_START_TIME_FIELD_DESC);
-
 
42103
      oprot.writeI64(this.sessionStartTime);
-
 
42104
      oprot.writeFieldEnd();
41951
      oprot.writeFieldStop();
42105
      oprot.writeFieldStop();
41952
      oprot.writeStructEnd();
42106
      oprot.writeStructEnd();
41953
    }
42107
    }
41954
 
42108
 
41955
    @Override
42109
    @Override
Line 41958... Line 42112...
41958
      boolean first = true;
42112
      boolean first = true;
41959
 
42113
 
41960
      sb.append("cartId:");
42114
      sb.append("cartId:");
41961
      sb.append(this.cartId);
42115
      sb.append(this.cartId);
41962
      first = false;
42116
      first = false;
-
 
42117
      if (!first) sb.append(", ");
-
 
42118
      sb.append("sessionSource:");
-
 
42119
      if (this.sessionSource == null) {
-
 
42120
        sb.append("null");
-
 
42121
      } else {
-
 
42122
        sb.append(this.sessionSource);
-
 
42123
      }
-
 
42124
      first = false;
-
 
42125
      if (!first) sb.append(", ");
-
 
42126
      sb.append("sessionStartTime:");
-
 
42127
      sb.append(this.sessionStartTime);
-
 
42128
      first = false;
41963
      sb.append(")");
42129
      sb.append(")");
41964
      return sb.toString();
42130
      return sb.toString();
41965
    }
42131
    }
41966
 
42132
 
41967
    public void validate() throws TException {
42133
    public void validate() throws TException {