/*
* Copyright 2008 GigaSpaces Technologies LTD. All rights reserved.
*
* THIS SOFTWARE IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. GIGASPACES WILL NOT
* BE LIABLE FOR ANY DAMAGE OR LOSS IN CONNECTION WITH THE SOFTWARE.
*/
package com.gigaspaces.examples.tutorials.queries.common;
import com.gigaspaces.annotation.pojo.SpaceClass;
import com.gigaspaces.annotation.pojo.SpaceId;
import com.gigaspaces.annotation.pojo.SpaceProperty;
import com.gigaspaces.annotation.pojo.SpaceProperty.IndexType;
/**
* Some important properties: <p>
*
* orderID - annotated as the object unique space id (see the getter method for the annotation).
* firstName (used to perform routing when working with partitioned space, see getter method for annotation).
* status - indicating if this OrderEvent object is new, approved, or rejected.
* type - indicating if this OrderEvent object is normal or insecure.
* riskInvolved - integer representing the risk involved for the order. <p>
*
* Annotations: <p>
*
* <code>@SpaceProperty(index=IndexType.BASIC)</code> annotation above the getter indicates that
* the field is indexed.
* Querying indexed fields speeds up read and take operations. Possible values of NONE and BASIC. <p>
*
* <code>@SpaceRouting</code> annotation (see getFirstName()) indicates that firstName field
* will be used as a routing index to perform routing when working with partitioned space. <p>
*
* <code>@SpaceClass</code> annotation in this example is only to indicate that this class is a space class.
*/
@SpaceClass
public class OrderEvent {
public static final String STATUS_NEW = "New";
public static final String STATUS_APPROVED = "Approved";
public static final String STATUS_REJECTED = "Rejected";
public static final String TYPE_INSECURE = "Insecure";
public static final String TYPE_NORMAL = "Normal";
/** ID of the order. */
private String orderID;
/** Order's feeder placer ID. */
private String feederID;
/** First name of the order placer. */
private String firstName;
/** Last name of the order placer. */
private String lastName;
/** Risk involved factor for the order. */
private Integer riskInvolved;
/** Order price. */
private Integer price;
/** Order status, Possible values: New, Approved, Rejected. */
private String status;
/** Order type, Possible values: Normal, Insecure */
private String type;
/**
* <code>@SpaceProperty</code> Defines this field data to be indexed.
* Querying indexed fields speeds up read and take operations.
*/
@SpaceProperty(index = IndexType.BASIC)
public Integer getRiskInvolved() {
return riskInvolved;
}
public void setRiskInvolved(Integer riskInvolved) {
this.riskInvolved = riskInvolved;
}
public Integer getPrice() {
return price;
}
public void setPrice(Integer price) {
this.price = price;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
* @return userName - Gets the user name of the orderEvent object.
* <code>@SpaceProperty</code> Defines if this field data is indexed.
*/
@SpaceProperty(index = IndexType.BASIC)
public String getFirstName() {
return firstName;
}
/**
* @param firstName - set the user name of the orderEvent object.
*/
public void setFirstName(String userName) {
this.firstName = userName;
}
/**
* @return orderEvent ID. <p>
*
* <code>@SpaceID</code> Defines whether this field value is used when generating the Entry's UID,
* its value will be auto generated when it is written to the space.
* (Since auto-generate is declared as true, the field isn't indexed).
*/
@SpaceId(autoGenerate = true)
public String getOrderID() {
return orderID;
}
/**
* @param orderEvent ID - Sets the ID of the orderEvent.
*/
public void setOrderID(String orderID) {
this.orderID = orderID;
}
/**
* @return status - the orderEvent status.
* <code>@SpaceProperty</code> Defines this field data to be indexed.
*/
@SpaceProperty(index = IndexType.BASIC)
public String getStatus() {
return status;
}
/**
* @param status - Sets the orderEvent status.
*/
public void setStatus(String status) {
this.status = status;
}
/**
* @return clientID - Gets the clientID of the orderEvent object.
*/
public String getFeederID() {
return feederID;
}
/**
* @param feederID - Sets the orderEvent feederID.
*/
public void setClientID(String clientID) {
this.feederID = clientID;
}
/**
* @return type - the orderEvent type.
* <code>@SpaceProperty</code> Defines if this field data is indexed.
*/
@SpaceProperty(index = IndexType.BASIC)
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
/**
* Empty Constructor.
* */
public OrderEvent() {
}
/**
* OrderEvent Constructor.
* @param firstName
* @param lastName
* @param feederID
* @param type
* @param riskInvolvedFactor
* @param price
*/
public OrderEvent(String firstName, String lastName, String feederID, String type, Integer riskInvolvedFactor, Integer price) {
this.firstName = firstName;
this.lastName=lastName;
this.feederID = feederID;
this.type = type;
this.riskInvolved = riskInvolvedFactor;
this.price = price;
this.status = STATUS_NEW;
}
/**
* Outputs the orderEvent object attributes.
*/
public String toString() {
return "type["+type+"] status["+status+"] price["+price+"] first Name["+firstName
+"] last Name["+lastName+"] risk involved["+riskInvolved+"]";
}
}