% ------------------------------------------------------------------ %
%                                                                    %
% Datei:        beispiel.tex                                         %
% Autor:        Oliver Nietsch                                       %
%                                                                    %
% Universitaet Hamburg                                               %
% Fachbereich Informatik                                             %
% Arbeitsbereich DBIS                                                %
%                                                                    %
% Thema: Studienarbeit: "Gateway zwischen dem StP-Repository         %
%                        und Tycoon"                                 %
%                                                                    %
% Inhalt: LaTeX-Dokument: Studienarbeit,                             %
%                         Anhang A.4: Tycoon-Skript Beispiel1.tyc    %
%                                                                    %
% Version vom  22. 2.1996                                            %
% ------------------------------------------------------------------ %

\section{Tycoon-Skript Beispiel1.tyc}
\label{Ann:Bsp1}

\begin{scriptsize}
\begin{verbatim}
(* ------------------------------------------------------------------ *)
(* Datei:        Beispiel1.tyc                                        *)
(* Autor:        Oliver Nietsch                                       *)
(*                                                                    *)
(* Universitaet Hamburg                                               *)
(* Fachbereich Informatik                                             *)
(* Arbeitsbereich DBIS                                                *)
(*                                                                    *)
(* Inhalt: Tycoon-Anweisungen zum exemplarischen Aufruf der gesamten  *)
(*         StP Funktionalitaet auf Basis des StP API Datentyps        *)
(*         "oms_node_tp"                                              *)
(*                                                                    *)
(* Voraussetzungen: libstp.so in ${TYCOON_ROOT}/lib/${TYCOON_HOST}    *)
(* Tycoon-Bibliothek: ${TYCOON_ROOT}/bootlib/stpenv                   *)
(*                                                                    *)
(* Version vom  7. 2.1996                                             *)
(* ------------------------------------------------------------------ *)

import omsError;

import omsTime;
import omsTransaction;
import omsRepository;

import omsApplicationType;
import omsObjectId;

import omsIdList;
import omsCollection;
import omsBigCollection;
import omsNode;


let annot = 7;
let projdir = "/local/dbis11/software/StP/project";
let system = "tutor";
let query = "node[name=\'interessanter Node\' && type=701576 && scope_node_id=0
&& sig=\'moin_moin\']";

let name = "interessanter Node";
let type = omsApplicationType.type;
let scope = omsObjectId.optional();
let sig = "moin_moin";


oms_repos_tp Functions:
=======================

omsRepository.init();
                          (* Setzen der StP Umgebungsvariablen: *)
                          (* Sichtbarkeitsbereich: Nur innerhalb des *)
                          (* momentan aktiven Tycoon-Subprozesses *)

let rep = omsRepository.connectSystem(projdir system);
 
omsRepository.isOpen(rep);
let serverName = omsRepository.currentServerName(rep);
let repName = omsRepository.currentReposName(rep);
omsRepository.currentReposId(rep);

let rep = omsRepository.connectRep(serverName repName);

omsRepository.disconnect(rep);


oms_node_tp Creation & Retrieval Functions:
===========================================

let node1 = omsNode.create(rep name type omsObjectId.optional() sig);

let node2 = omsNode.find(rep name type omsObjectId.optional() sig);

let node2 = omsNode.findById(rep id);
let attributeRWC = omsNode.name(node2);
  let name = attributeRWC.get();

let node2 = omsNode.findByQuery(rep omsQuery.new("node[name=\'interessanter Node\' && type=701576
&& scope_node_id=0 && sig=\'moin_moin\']"));
  let scopeNodeId = omsNode.id(node4);
    omsObjectId.toInt(scopeNodeId);


oms_node_tp Utility Functions:
==============================

let node4 = omsNode.copy(node2);
let attributeRWC = omsNode.signature(node4);
  let signature = attributeRWC.get();

omsNode.equal(node2 node4);
omsNode.free(node4);
omsNode.printImageAssign("hallo");


oms_node_tp Attribute Access & Assign Functions:
================================================

let attributeR = omsNode.reposId(node2);
  let reposId = attributeR.get();
let id = omsNode.id(node2);
  omsObjectId.toInt(id);
let attributeRWC = omsNode.name(node2);
  let name = attributeRWC.get();
let attributeRW = omsNode.type(node2);
  let type = attributeRW.get();
let attributeRWO = omsNode.scopeNode(node2);
  let scopeNodeId = attributeRWO.get();
    omsObjectId.toInt(scopeNode);
let attributeRWC = omsNode.signature(node2);
  let signature = attributeRWC.get();
let attributeRWO = omsNode.annotFile(node2);
  let annotFileId = attributeRWO.get();
    omsObjectId.toInt(annotFile);

let attributeRWC = omsNode.name(node2);
  let name = attributeRWC.copy();
let attributeRWC = omsNode.signature(node2);
  let signature = attributeRWC.copy();

let attributeRWC = omsNode.name(node2);
  attributeRWC.set("hallo Node");
let attributeRWC = omsNode.type(node2);
  attributeRWC.set(type);
let attributeRWO = omsNode.scopeNode(node2);
  attributeRWO.set(scopeNode);
let attributeRWC = omsNode.signature(node2);
  attributeRWC.set("moin");
let attributeRWO = omsNode.annotFile(node2);
  attributeRWO.set(annotFile);

omsNode.compareAttrs(node2 name type scope sig);


oms_node_tp Repository Management Functions:
============================================

omsNode.update(node1);
omsNode.delete(node2);
omsNode.check(node1);


oms_node_tp Typed Collection Functions:
=======================================

let coll1 = omsCollection.create(rep :omsRep.Node :omsRep.NodeHandle omsRep.nodeDescriptor query);
  let node10 = coll1.get(0);
    let attributeRWC = omsNode.name(node10);               
    let name = attributeRWC.get();
   
coll1.add(node2);
coll1.addUnique(node2);
coll1.delete(node2);
coll1.deleteEquivalent(node2);
coll1.count();
coll1.free();
coll1.freeAll();
coll1.freeContents();


oms_node_tp Typed Big Collection Functions:
===========================================

let bigcoll1 = omsBigCollection.create(rep :omsRep.Node :omsRep.NodeHandle 
omsRep.nodeDescriptor query);
  let node11 = bigcoll1.next();

bigcoll1.free();
bigcoll1.reset();


oms_node_tp Navigation Functions:
=================================

let attributeRWO = omsNode.scopeNode(node2);
  let scopeNode = attributeRWO.deref();
let attributeRWO = omsNode.annotFile(node2);
  let annotFile = attributeRWO.deref();

let coll2 = omsNode.notes(node2);
let coll3 = omsNode.viewpoints(node2);
let coll4 = omsNode.scopedNodes(node2);
let coll5 = omsNode.scopedLinks(node2);
let coll6 = omsNode.scopedCntxs(node2);
let coll7 = omsNode.outLinks(node2);
let coll8 = omsNode.inLinks(node2);
let coll9 = omsNode.nodeRefs(node2);


oms_time_tp Functions:
======================

omsTime.inputFormatAssign("%C");  
omsTime.outputFormatAssign("%C"); 
omsTime.localEnvironmentAssign(timeText);
let timeText = omsTime.toText(time);
omsTime.textToTime(timeText);
let time = omsTime.now();

omsTime.relTextToTime(timeText);


oms_txn_tp Functions:
=====================

omsTransaction.start(rep);
omsTransaction.inProgress();
omsTransaction.commit(rep);
omsTransaction.abort();
omsTransaction.reset();


oms_id_list Functions:
======================

let idlist = omsIdList.create(rep omsPDMType.node "oliver" query);
idlist.free();
omsIdList.freeAll();


oms_app_type_tp Functions:
==========================

let annotFilename = omsApplicationType.annotFilename(rep omsApplicationType.type);
let appTypeCode = omsApplicationType.codeGet(rep omsPDMType.node 0);
omsApplicationType.codeToText(appTypeCode);

omsApplicationType.comment(appTypeCode);
omsApplicationType.method(appTypeCode "Attribute"); 

let pdmType = omsApplicationType.pdmType(appTypeCode);

omsApplicationType.printString(appTypeCode);
omsApplicationType.textGet(rep omsPDMType.node 0);
omsApplicationType.textGetCopy(rep omsPDMType.node 0);
let appTypeCode2 = omsApplicationType.textToCode(rep omsPDMType.node "hallo");

let datatype = omsApplicationType.datatype(appTypeCode);

let filename = omsApplicationType.filename();


oms_pdm_type_tp Functions:
==========================

omsPDMType.toText(pdmType);
let pdmType2 = omsPDMType.fromText("node");


Error Handling:
===============

let errorHandler(isError :Bool num :Int msg :String) :Ok =
  begin
    (* Other statements ... *)
    raise omsError.omsError end
  end;

omsError.setErrorHandler(errorHandler);
\end{verbatim}
\end{scriptsize}

\clearemptydoublepage
