CREATE OR REPLACE PACKAGE mip_documents IS

  -- Author  : MULLENMD
  -- Created : 14/02/2008 13:36:30
  -- Purpose : Operations for managing docs in the MIP system

  PROCEDURE set_doc_scanning(p_docu_id     IN documents.id%TYPE,
                             p_description document_events.description%TYPE DEFAULT NULL);
  PROCEDURE set_doc_available(p_docu_id     IN documents.id%TYPE,
                              p_description document_events.description%TYPE DEFAULT NULL);
  PROCEDURE set_doc_remove_av(p_docu_id     IN documents.id%TYPE,
                              p_description document_events.description%TYPE DEFAULT NULL);
  PROCEDURE set_doc_remove_user(p_docu_id     IN documents.id%TYPE,
                                p_description document_events.description%TYPE DEFAULT NULL);
  PROCEDURE set_doc_remove_size(p_docu_id     IN documents.id%TYPE,
                                p_description document_events.description%TYPE DEFAULT NULL);
END mip_documents;
/
CREATE OR REPLACE PACKAGE BODY mip_documents IS

  --
  PROCEDURE add_document_event(p_docu_id     IN documents.id%TYPE,
                               p_event_date  DATE DEFAULT SYSDATE,
                               p_description document_events.description%TYPE DEFAULT NULL,
                               p_dost_code   document_status_types.code%TYPE) IS
  BEGIN
    INSERT INTO document_events
      (docu_id, dost_code, event_date, description, id)
    VALUES
      (p_docu_id,
       p_dost_code,
       p_event_date,
       p_description,
       doev_seq.NEXTVAL);
  
    COMMIT;
  END add_document_event;
  --

  --
  PROCEDURE set_doc_scanning(p_docu_id     IN documents.id%TYPE,
                             p_description document_events.description%TYPE DEFAULT NULL) IS
  BEGIN
    add_document_event(p_docu_id     => p_docu_id,
                       p_dost_code   => 'SCANNING',
                       p_description => p_description);
  END set_doc_scanning;
  --

  --
  PROCEDURE set_doc_available(p_docu_id     IN documents.id%TYPE,
                              p_description document_events.description%TYPE DEFAULT NULL) IS
  BEGIN
    add_document_event(p_docu_id     => p_docu_id,
                       p_dost_code   => 'AVAILABLE',
                       p_description => p_description);
  END set_doc_available;
  --

  --
  PROCEDURE set_doc_remove_av(p_docu_id     IN documents.id%TYPE,
                              p_description document_events.description%TYPE DEFAULT NULL) IS
  BEGIN
    add_document_event(p_docu_id     => p_docu_id,
                       p_dost_code   => 'REMOVED MALICIOUS',
                       p_description => p_description);
  END set_doc_remove_av;
  --

  --
  PROCEDURE set_doc_remove_user(p_docu_id     IN documents.id%TYPE,
                                p_description document_events.description%TYPE DEFAULT NULL) IS
  BEGIN
    add_document_event(p_docu_id     => p_docu_id,
                       p_dost_code   => 'REMOVED USER',
                       p_description => p_description);
  END set_doc_remove_user;
  --

  --
  PROCEDURE set_doc_remove_size(p_docu_id     IN documents.id%TYPE,
                                p_description document_events.description%TYPE DEFAULT NULL) IS
  BEGIN
    add_document_event(p_docu_id     => p_docu_id,
                       p_dost_code   => 'REMOVED SIZE',
                       p_description => p_description);
  END set_doc_remove_size;
  --
END mip_documents;
/
