Ext.define('OrderClass', {
    constructor: function(nodePath, itemType, elementSeq, responseID, listType, actionSequence, actionType){
        this.NodePath = nodePath;
        this.ItemType = itemType;
        this.ElementSequence = (typeof(elementSeq) != 'undefined') ? elementSeq : -1;
        this.ResponseID = (typeof(responseID) != 'undefined') ? responseID : -1;
        this.ListType = (typeof(listType) != 'undefined') ? listType : null;
        this.ActionSequence = (typeof(actionSequence) != 'undefined') ? actionSequence : -1;
        this.ActionType = (typeof(actionType) != 'undefined') ? actionType : null;
    },
    getNodePathCount: function(){
        var nodePaths = this.NodePath.split("|");
        return nodePaths.length;
    },
    getListOrder: function(){
        if (this.ListType) {
            switch (this.ListType) {
                case "BACKGROUNDLIST":
                    return 0;
                case "FOREGROUNDLIST":
                    return 1;
                case "INTRODUCTION":
                    return 2;
                case "INFORMATION":
                    return 3;
                case "INTERACTION":
                    return 4;
                case "MENUINFORMATION":
                    return 5;
                case "MENUINTERACTION":
                    return 6;
                case "RESPONSE":
                    return 7;
                case "ENDLIST":
                    return 8;
            }
        }
        else {
            return -1;
        }
    },
    compareTo: function(other){
        if (this.getNodePathCount() < other.getNodePathCount()) {
            return -1;
        }
        if (this.getNodePathCount() > other.getNodePathCount()) {
            return 1;
        }
        if (this.NodePath != other.NodePath) {
            return 2;
        }
        if (this.ElementSequence < other.ElementSequence) {
            return -1;
        }
        if (this.ElementSequence > other.ElementSequence) {
            return 1;
        }
        if (this.ResponseID != other.ResponseID) {
            if (this.ResponseID < 0) {
                return -1;
            }
            if (other.ResponseID < 0) {
                return 1;
            }
        }
        if (this.getListOrder() < other.getListOrder()) {
            return -1;
        }
        if (this.getListOrder() > other.getListOrder()) {
            return 1;
        }
        if (this.ActionSequence < other.ActionSequence) {
            return -1;
        }
        if (this.ActionSequence > other.ActionSequence) {
            return 1;
        }
        return 0;
    },
    toString: function(){
        return "Itemtype: " + this.ItemType + "\nNodePath: " + this.NodePath + "\nElementSequence: " + this.ElementSequence + "\nResponseID: " + this.ResponseID + "\nListType: " + this.ListType + "\nActionSequence: " + this.ActionSequence + (this.ActionType ? ("\nActionType: " + this.ActionType) : "");
    }
});
