Pure CORBA

Home   About Us   Downloads

Recycle Broker IDL


module RecycleBroker {
    typedef string      NameType;
    typedef string      AddressType;
    typedef long        KeyType;
    typedef float       PriceType;

    enum WasteType {
        BROWN_GLASS, GREEN_GLASS, CLEAR_GLASS, SCRAP_STEEL,
        ALUMINIUM_CANS, PLASTIC_BOTTLES, WASTE_PAPER
    };

    // User Exceptions
    exception NoPermission { };
    exception NotLoggedOn  { };
    exception NotFound     { };
    exception InsufficientQuantity { };
    exception NetworkError {
        string reason;
        string telephone;
    };

    // struct RecycleBroker::CustomerDetails
    struct CustomerDetails {
        NameType         name;
        AddressType      address;
        string           email_address;
        string           password;
    };

    struct CustomerDetailsFull {
        CustomerDetails  public_details;
        KeyType          branch_id;
        KeyType          customer_id;
    };

    // struct RecycleBroker::WasteItemDetails
    struct WasteItemDetails {
        WasteType        waste;
        long             quantity;
        PriceType        price_per_kilo;
    };

    struct WasteItemDetailsFull {
        WasteItemDetails public_details;
        KeyType          branch_id;
        KeyType          customer_id;
        KeyType          wasteitem_id;
    };

    // struct RecycleBroker::BranchDetails
    struct BranchDetails {
        AddressType      address;
        string           telephone;
    };

    struct BranchDetailsFull {
        BranchDetails    public_details;
        KeyType          branch_id;
    };

    interface Office;

    interface Customer {
        // attributes
        attribute NameType         name;
        attribute AddressType      address;
        attribute string           email_address;
        attribute string           password;
        readonly attribute KeyType branch_id;
        readonly attribute KeyType customer_id;

        // operations
        CustomerDetails  get_details();
    };

    interface WasteItem {
        // attributes
        attribute WasteType        waste;
        attribute long             quantity;
        attribute PriceType        price_per_kilo;
        readonly attribute KeyType branch_id;
        readonly attribute KeyType customer_id;
        readonly attribute KeyType wasteitem_id;

        // operations
        WasteItemDetails get_details();
    };

    typedef sequence CustomerIdSeq;
    typedef sequence CustomerDetailsSeq;

    interface CustomerAdmin {
        Customer create(
             in  CustomerDetails initialData,
             out KeyType         customer_id
        )
        raises (NoPermission);

        Customer find(in KeyType customer_id)
        raises (NoPermission, NotFound);

        CustomerIdSeq find_by_name(in NameType name)
        raises (NoPermission, NotFound);
    };

    typedef sequence   WasteItemIdSeq;
    typedef sequence WasteItemSeq;
    typedef sequence WasteItemDetailsSeq;

    interface WasteItemAdmin {
        WasteItem create(
             in  WasteItemDetails initialData,
             out KeyType          wasteitem_id
        )
        raises (NoPermission);

        WasteItem find(in KeyType wasteitem_id)
        raises (NotFound);
        WasteItemIdSeq find_by_waste(in WasteType waste)
        raises (NotFound);
        WasteItemIdSeq find_by_branch(in KeyType branch_id)
        raises (NotFound);
        WasteItemIdSeq find_all();

        WasteItemDetailsSeq get_details(in WasteItemIdSeq id_seq)
        raises (NotFound);
    };

    typedef sequence BranchDetailsSeq;

    interface OfficeAdmin {
        BranchDetailsSeq get_all_details();
    };

    interface Browsing {
        WasteItemAdmin get_waste_item_admin();
    };

    interface Selling {
        enum Status {INITIAL,
                     LOGGED_ON,
                     LOGGED_OFF };

        readonly attribute Status current_status;

        Customer      create_customer(
                          in CustomerDetails initialData,
                          out KeyType        customer_id
                      );

        Customer      log_on(in NameType name, in string password)
                      raises (NoPermission);
        
        WasteItem     create_waste_item(
                           in WasteItemDetails  initialData,
                           out KeyType          wasteitem_id
                      )
                      raises (NotLoggedOn);

        void          log_off()  raises (NotLoggedOn);
    };

    interface Buying {
        enum Status {INITIAL,
                     LOGGED_ON,
                     LOGGED_OFF };

        readonly attribute Status current_status;

        Customer      create_customer(
                          in CustomerDetails initialData,
                          out KeyType        customer_id
                      );

        Customer      log_on(in NameType name, in string password)
                      raises (NoPermission);
        
        void          buy_item(
                          in KeyType wasteitem_id,
                          in long    quantity
                      )
                      raises (NotFound,
                              InsufficientQuantity,
                              NetworkError,
                              NotLoggedOn
                      );

        void          log_off()  raises (NotLoggedOn);
    };

    interface Office {
        // attributes
        readonly attribute string address;
        readonly attribute long   branch_id;

        // Customer operations
        Browsing       get_browsing();
        Selling        get_selling();
        Buying         get_buying();

        // Agent operations
        CustomerAdmin  get_customer_admin();
        WasteItemAdmin get_waste_item_admin();
    };

    typedef sequence WasteItemDetailsFullSeq;
    typedef sequence  CustomerDetailsFullSeq;

    interface HeadOffice : Office {
        void replicate_waste_item_details(
             in WasteItemDetailsFullSeq detailsSeq
        );

        void replicate_customer_details(
            in CustomerDetailsFullSeq detailsSeq
        );
    };

    interface BranchOffice : Office { };
};