DB 参考書。 グローバル。 入れ子構造。 ライブ例

ランドセルにパラシュートを備えたカメラの今後の「ネスティング」の例を示す注意を引くための写真。



パート1

パート2

パート3



前回、私たちはcreate()メソッドを持っているという事実に落ち着きました。このメソッドは、 グローバルなルール^ RuleDictionaryに基づいて、ディレクトリ要素を作成します。 単純な単一レベルのディレクトリの要素を作成する例を分析しました。 今日は、グローバルとメソッドを使用して、ネスト構造を作成する方法を検討します。



プログラムコードでは、 「透明な」変数tおよびmapが使用されました。これらはメソッドに明示的に渡されませんが、それらの内部で使用可能です。 特に、ほとんどの場合、CachéObject Scriptの構文が新しいことを考えると、これは作業を実証する最良の方法ではないと言われました。 したがって、ネスト構造を進める前に、プログラムにいくつかの変更を加えます。




マクロ



マクロを使用すると、定数、グローバル変数、ローカル変数、個々のコードなどにエイリアス(他の名前)を指定できます。 マクロを使用する利点は、データの実際の場所(名前空間名、グローバルなど)を変更する場合、プログラムコードを変更する必要はなく、1つのマクロ(incファイル内)を変更し、プロジェクトを再コンパイルするだけです。すべてが新しい名前で機能します。 また、マクロを使用すると、理解を失うことなく記録を減らすことができます。 マクロはサービスワード#defineで宣言され、マクロの名前はスペースを介して渡されます。スペースがこのマクロの意味を示した後でもです。 マクロには他のマクロを含めることができます。主なことは、マクロが以前に定義されていることです。 パラメーターをマクロに渡すことができます(マクロパラメーターは%で始まります)。



#define defNameSpace "MONTOLOGY"



このマクロは、 MONTOLOGYの代わりエイリアスを作成します。 $$$ defNameSpaceを記述できるようになりました 。 3ドルは、マクロが(システムのシステムではなく)開発者によって作成されたことを意味します。 $$$ defNameSpaceに"MONTOLOGY "よりも多くの文字が含まれており、明快さは低いという事実にもかかわらず、このマクロは他のマクロやプログラムコードで使用されるため、非常に便利です。



次のDictionary.incファイルがあるとします



#;     #define defNameSpace "MONTOLOGY" #;    #define dData ^|$$$defNameSpace|Dictionary #;    #define dName ^|$$$defNameSpace|NameDictionaryElement #;    #define dIndex ^|$$$defNameSpace|IndexDictionary #;   #define dRefs ^|$$$defNameSpace|RefsDictionary #;    #define dMaxID $increment($$$dData("MaxID")) #;   #define dRule ^|$$$defNameSpace|RuleDictionary #;      #define dDTO ^|$$$defNameSpace|tmwOntology #;        #define getDTOin(%param,%def) $get($$$dDTO($job,"in",%param),%def) #;        #define setDTOproc(%param,%val) set $$$dDTO($job,"proc",%param)=%val #;        #define getDTOproc(%param,%def) $get($$$dDTO($job,"proc",%param),%def) #;        #define setDTOout(%param,%val) set $$$dDTO($job,"out",%param)=%val #;        #define getDTOout(%param,%def) $get($$$dDTO($job,"out",%param),%def) #;          #define getDTOname(%lang) $get($$$dDTO($job,"in","nameList",%lang))
      
      





さて、グローバルにアクセスするために: ^ | "MONTOLOGY" | IndexDictionary 、プログラムコードに$$$ dIndexを書くことができます。 マクロ$$$ dMaxIDに注意してください :インクリメント操作を実行します。 コンパイラは、単に辞書プログラム全体を調べて、すべてのマクロを実際の意味に置き換えます。 通常のテキスト置換を実行します。 マクロ$$$ dDTO (辞書データ転送オブジェクト)-透過変数マップの代わりに、サブプログラム間でパラメーターを転送するために使用します。 $ jobは、現在のプロセス番号が格納されるシステム変数です。 つまり、 $$ dDTOマクロでアクセスできる^ | "MONTOLOGY" | tmwOntology globalで複数のプロセスが同時に動作できると想定しています。 それぞれが独自のインデックス$$$ dDTO($ job)を参照し、次のサービスブランチが使用されます。





以前の記事のグローバルは、次のマクロを使用してプログラムコード内で利用できます。



たとえば、マクロを使用して、 Dictionaryプログラムの最初のメソッドを書き換えます



(マクロなしで):

 #; -------------------------------------------------------------------------------------------------- #;   #; -------------------------------------------------------------------------------------------------- Dictionary #; -------------------------------------------------------------------------------------------------- #;   . #; -------------------------------------------------------------------------------------------------- retrieve(id,lang="ru",version=0) quit $get(^NameDictionaryElement(id,lang,version),"") #; --------------------------------------------------------------------------------------------------
      
      





次のようになりました(マクロ付き):

 #; -------------------------------------------------------------------------------------------------- #;    Dictionary.inc,   (inc) -      #include Dictionary #; -------------------------------------------------------------------------------------------------- #;   #; -------------------------------------------------------------------------------------------------- Dictionary #; -------------------------------------------------------------------------------------------------- #;   . #; -------------------------------------------------------------------------------------------------- retrieve(id,lang="ru",version=0) quit $get($$$dName(id,lang,version),"") #; --------------------------------------------------------------------------------------------------
      
      





マクロの使用を考慮し、透過変数を使用せずに、 プログラムのコード全体を変換します。



変換された辞書プログラム
 #; -------------------------------------------------------------------------------------------------- #;    Dictionary.inc,   (inc) -      #include Dictionary #; -------------------------------------------------------------------------------------------------- #;   #; -------------------------------------------------------------------------------------------------- Dictionary #; -------------------------------------------------------------------------------------------------- #;   . #; -------------------------------------------------------------------------------------------------- retrieve(id,lang="ru",version=0) quit $get($$$dName(id,lang,version),"") #; -------------------------------------------------------------------------------------------------- #;      . #; -------------------------------------------------------------------------------------------------- retrieveListByIndex(ontology,type,index,value,str="",lang="ru") #;     ,       set str=$zconvert(str,"L") set id="" for { #;  ()    set id=$order($$$dIndex(ontology,type,index,value,id)) #;  ,        quit:id="" #;   set name=$$retrieve(id,lang) #;      str if $extract($zconvert(name,"L"),1,$length(str))=str { #;  (  ) write id_" "_name,! } } quit #; -------------------------------------------------------------------------------------------------- #;   . #;         . #; -------------------------------------------------------------------------------------------------- create() #;     kill $$$dDTO($job,"out") #;     t #;         create new t #;      set t("err")=$$check("create") #; ,    if t("err")<0 { quit t("err") } st("ontology")=$$$getDTOin("ontology","") st("type")=$$$getDTOin("type","") st("id")=$$$getDTOproc("id","") #;   "UpdateTime" do setProperty(t("ontology"),t("type"),"UpdateTime",$horolog,t("id"),"false") #;   "uid" do setProperty(t("ontology"),t("type"),"uid",$$$getDTOin("uid",888),t("id"),"true") set t("lang")="" for { #;    (     ) set t("lang")=$order($$$dDTO($job,"in","nameList",t("lang"))) #;   ,     quit:t("lang")="" #;      set t("name")=$get($$$dDTO($job,"in","nameList",t("lang")),"") #;      do setName(t("ontology"),t("type"),t("lang"),t("name"),t("id")) } #;          do saveOntoAndTypeID(t("id"),t("ontology"),t("type")) #;         do saveElementPath(t("id"),$$$getDTOproc("path","")) #;         $$$setDTOout("id",t("id")) #;     kill $$$dDTO($job,"in") #;     kill $$$dDTO($job,"porc") #;     quit t("id") #; -------------------------------------------------------------------------------------------------- #;  . #;    ^RuleDictionary    . #; -------------------------------------------------------------------------------------------------- check(action)private #;     check new check #;        action set check=$case(action,"create":$$checkCreate(),"update":$$checkUpdate(),"delete":$$checkDelete(),:-1) #;   quit:check<0 check #; ,      "check",        if $data($$$dRule($$$getDTOin("ontology",""),$$$getDTOin("type",""),action,"check")) { #;  check("map")        set check("map")=$name($$$dRule($$$getDTOin("ontology",""),$$$getDTOin("type",""),action,"check")) } else { #;  check("map")              set check("map")=$name($$$dRule("SimpleOntology","SimpleType",action,"check")) } set check("i")="" for { #;     set check("i")=$order(@check("map")@(check("i"))) #;   ,     quit:check("i")="" #;     xecute $get(@check("map")@(check("i"))) #;   ,     quit:check<0 } #;    quit check #; -------------------------------------------------------------------------------------------------- #;      . #; -------------------------------------------------------------------------------------------------- checkCreate()private new t #;       quit:$$$getDTOin("ontology","")="" -1 #;  ,      quit:$$$getDTOin("type","")="" -1 #;     set t("check")=$$checkNames() #;  ,     quit:t("check")<0 t("check") #;       $$$setDTOproc("id",$$$dMaxID) #;      ^Dictionary $$$setDTOproc("path",$name($$$dData($$$getDTOin("ontology",""),$$$getDTOin("type",""),$$$getDTOproc("id","")))) #;     quit 0 #; -------------------------------------------------------------------------------------------------- checkUpdate() quit 0 #; -------------------------------------------------------------------------------------------------- checkDelete() quit 0 #; -------------------------------------------------------------------------------------------------- #;     . #; -------------------------------------------------------------------------------------------------- checkNames()private new t #;   t("check")  #;         set t("check")=-1 set t("lang")="" for { #;    set t("lang")=$order($$$dDTO($job,"in","nameList",t("lang"))) #;   ,     quit:t("lang")="" #;      set t("name")=$get($$$dDTO($job,"in","nameList",t("lang")),"") #;    if t("name")="" { #;   t("check")  set t("check")=-1 #;    quit } else { #;  t("check")   ,     set t("check")=0 } } #;     quit t("check") #; -------------------------------------------------------------------------------------------------- #;    . #; -------------------------------------------------------------------------------------------------- processingNames(function) new t set t("lang")="" for { #;     set t("lang")=$order($$$dDTO($job,"in","nameList",t("lang"))) quit:t("lang")="" #;        xecute "set "_$name($$$dDTO($job,"in","nameList",t("lang")))_"=$$"_function_"("""_$$$getDTOname(t("lang"))_""")" } quit #; -------------------------------------------------------------------------------------------------- checkUniqueNameElementAllLang() new t set t("check")=0 st("ontology")=$$$getDTOin("ontology","") st("type")=$$$getDTOin("type","") set t("lang")="" for { #;     set t("lang")=$order($$$dDTO($job,"in","nameList",t("lang"))) quit:t("lang")="" #;    set t("name")=$get($$$dDTO($job,"in","nameList",t("lang")),"") #;   t("check")     (0 -  ) st("check")=$$checkUniqueNameElement(t("ontology"),t("type"),t("lang"),t("name"),$$$getDTOproc("id","")) #;     -    quit:t("check")<0 } quit t("check") #; -------------------------------------------------------------------------------------------------- #;         . #; -------------------------------------------------------------------------------------------------- clearPunctuationAndControlChar(str) new t #;  t("str")     set t("str")="" #;      for t("i")=1:1:$length(str) { #;    set t("ch")=$extract(str,t("i")) if `((t("ch")?1P)||(t("ch")?1C)) { #;       set t("str")=t("str")_t("ch") } } #;    quit t("str") #; -------------------------------------------------------------------------------------------------- #; -------------------------------------------------------------------------------------------------- #;       . #;      . #;        (     ). #;      ,   "."   . #; -------------------------------------------------------------------------------------------------- specialClearStr(str) new t set t("str")="",t("flag")="start",t("delim")="" for t("i")=1:1:$L(str) { set t("ch")=$extract(str,t("i")) ;#     set:t("ch")=$char(9) t("ch")=" " continue:(t("ch")?1C) if (t("flag")="start")&&`(t("ch")?1P) { set t("str")=t("ch"),t("flag")="word" } elseif t("flag")="word" { if `(t("ch")?1P) { set t("str")=t("str")_t("ch") } else { set t("delim")=t("ch"),t("flag")="delim" } } elseif t("flag")="delim" { if (t("ch")?1P) { set:t("ch")`=" " t("delim")=t("ch") } else { set t("str")=t("str")_t("delim")_t("ch"),t("flag")="word",t("delim")="" } } } set:t("delim")="." t("str")=t("str")_t("delim") quit t("str") #; -------------------------------------------------------------------------------------------------- #; -------------------------------------------------------------------------------------------------- #;      ,   ,   . #;  ,   . #; -------------------------------------------------------------------------------------------------- checkUniqueNameElement(ontology,type,lang,name,id) new t #;    set t("q")=0 set t("uniqueId")="" for { #; ,         #;   , ,   (  ) set t("uniqueId")=$order($$$dIndex(ontology,type,"name",lang,$zconvert(name,"l"),t("uniqueId"))) #;     quit:t("uniqueId")="" #; ,      #;     update if (t("uniqueId")`=id) { #;  ,       set t("q")=-1 quit } } #;   quit t("q") #; -------------------------------------------------------------------------------------------------- #;  ,     . #;         . #; -------------------------------------------------------------------------------------------------- setProperty(ontology,type,property,value,id,index="true")private #;      ()    set $$$dData(ontology,type,id,0,property)=value #;    if index="true" { #;   set $$$dIndex(ontology,type,property,value,id)=1 #;      set $$$dRefs(id,$name($$$dIndex(ontology,type,property,value,id)))=1 } quit 0 #; -------------------------------------------------------------------------------------------------- #;   ,     . #;  (  )   . #; -------------------------------------------------------------------------------------------------- setName(ontology,type,lang,value,id)private #;         set $$$dName(id,lang,0)=value #;   / set $$$dName(id,lang,0,"UpdateTime")=$horolog #;     set $$$dIndex(ontology,type,"name",lang,$zconvert(value,"l"),id)=1 #;    set $$$dRefs(id,$name($$$dIndex(ontology,type,"name",lang,$zconvert(value,"l"),id)))=1 quit 0 #; -------------------------------------------------------------------------------------------------- saveOntoAndTypeID(id,ontology,type) set $$$dIndex("ID",id,"ontology")=ontology set $$$dRefs(id,$name($$$dIndex("ID",id,"ontology")))=1 set $$$dIndex("ID",id,"type")=type set $$$dRefs(id,$name($$$dIndex("ID",id,"type")))=1 quit #; -------------------------------------------------------------------------------------------------- saveElementPath(id,path) set $$$dIndex("ID",id,"path")=path set $$$dRefs(id,$name($$$dIndex("ID",id,"path")))=1 quit #; --------------------------------------------------------------------------------------------------
      
      





プログラムのリストでは、記号記号に置き換えられます -これは、コードをより美しく表示するために必要です。 Cachéでプログラムコードをコピーする場合、逆置換を実行する必要があります。すべての文字を` by 'で置換します。



変換されたルールグローバル:



 MONTOLOGY>zwrite ^RuleDictionary("SimpleOntology") ^RuleDictionary("SimpleOntology","SimpleType","create","check",10)="do processingNames(""clearPunctuationAndControlChar"")" ^RuleDictionary("SimpleOntology","SimpleType","create","check",20)="s check=$$checkUniqueNameElementAllLang()" ^RuleDictionary("SimpleOntology","SimpleType","update","check",10)="do processingNames(""clearPunctuationAndControlChar"")" ^RuleDictionary("SimpleOntology","SimpleType","update","check",20)="s check=$$checkUniqueNameElementAllLang()" MONTOLOGY>
      
      





グローバルCtrl + C / Vを作成
 set ^RuleDictionary("SimpleOntology","SimpleType","create","check",10)="do processingNames(""clearPunctuationAndControlChar"")" set ^RuleDictionary("SimpleOntology","SimpleType","create","check",20)="s check=$$checkUniqueNameElementAllLang()" set ^RuleDictionary("SimpleOntology","SimpleType","update","check",10)="do processingNames(""clearPunctuationAndControlChar"")" set ^RuleDictionary("SimpleOntology","SimpleType","update","check",20)="s check=$$checkUniqueNameElementAllLang()"
      
      







グローバル(ルールグローバルを除く)をクリアし、ディレクトリの最初の2つの要素を前回と同様に挿入して、マクロに切り替えて透過変数を回避するときにどこでも間違いを犯さないようにします。



変換された辞書プログラムの確認
^ RuleDictionaryルールglobalを除くすべてのグローバルを削除します。

 MONTOLOGY>kill ^Dictionary,^IndexDictionary,^NameDictionaryElement,^RefsDictionary MONTOLOGY>
      
      





ディレクトリの最初の2つの要素を作成しましょう。

 MONTOLOGY>kill ^tmwOntology($job) MONTOLOGY>set ^tmwOntology($job,"in","ontology")="Vehicle",^tmwOntology($job,"in","type")="TransmissionType" MONTOLOGY>set ^tmwOntology($job,"in","nameList","ru")=" ,",^tmwOntology($job,"in","nameList","partUri")="akp" MONTOLOGY>write $$create^Dictionary() 1 MONTOLOGY>kill ^tmwOntology($job) MONTOLOGY>set ^tmwOntology($job,"in","ontology")="Vehicle",^tmwOntology($job,"in","type")="TransmissionType" MONTOLOGY>set ^tmwOntology($job,"in","nameList","ru")="",^tmwOntology($job,"in","nameList","partUri")="meh" MONTOLOGY>write $$create^Dictionary() 2 MONTOLOGY>
      
      





すべてのグローバルを印刷します。

 MONTOLOGY>zwrite ^Dictionary,^IndexDictionary,^NameDictionaryElement,^RefsDictionary ^Dictionary("MaxID")=2 ^Dictionary("Vehicle","TransmissionType",1,0,"UpdateTime")="62968,77638" ^Dictionary("Vehicle","TransmissionType",1,0,"uid")=888 ^Dictionary("Vehicle","TransmissionType",2,0,"UpdateTime")="62968,77664" ^Dictionary("Vehicle","TransmissionType",2,0,"uid")=888 ^IndexDictionary("ID",1,"ontology")="Vehicle" ^IndexDictionary("ID",1,"path")="^|""MONTOLOGY""|Dictionary(""Vehicle"",""TransmissionType"",1)" ^IndexDictionary("ID",1,"type")="TransmissionType" ^IndexDictionary("ID",2,"ontology")="Vehicle" ^IndexDictionary("ID",2,"path")="^|""MONTOLOGY""|Dictionary(""Vehicle"",""TransmissionType"",2)" ^IndexDictionary("ID",2,"type")="TransmissionType" ^IndexDictionary("Vehicle","TransmissionType","name","partUri","akp",1)=1 ^IndexDictionary("Vehicle","TransmissionType","name","partUri","meh",2)=1 ^IndexDictionary("Vehicle","TransmissionType","name","ru","",1)=1 ^IndexDictionary("Vehicle","TransmissionType","name","ru","",2)=1 ^IndexDictionary("Vehicle","TransmissionType","uid",888,1)=1 ^IndexDictionary("Vehicle","TransmissionType","uid",888,2)=1 ^NameDictionaryElement(1,"partUri",0)="akp" ^NameDictionaryElement(1,"partUri",0,"UpdateTime")="62968,77638" ^NameDictionaryElement(1,"ru",0)="" ^NameDictionaryElement(1,"ru",0,"UpdateTime")="62968,77638" ^NameDictionaryElement(2,"partUri",0)="meh" ^NameDictionaryElement(2,"partUri",0,"UpdateTime")="62968,77664" ^NameDictionaryElement(2,"ru",0)="" ^NameDictionaryElement(2,"ru",0,"UpdateTime")="62968,77664" ^RefsDictionary(1,"^|""MONTOLOGY""|IndexDictionary(""ID"",1,""ontology"")")=1 ^RefsDictionary(1,"^|""MONTOLOGY""|IndexDictionary(""ID"",1,""path"")")=1 ^RefsDictionary(1,"^|""MONTOLOGY""|IndexDictionary(""ID"",1,""type"")")=1 ^RefsDictionary(1,"^|""MONTOLOGY""|IndexDictionary(""Vehicle"",""TransmissionType"",""name"",""partUri"",""akp"",1)")=1 ^RefsDictionary(1,"^|""MONTOLOGY""|IndexDictionary(""Vehicle"",""TransmissionType"",""name"",""ru"","""",1)")=1 ^RefsDictionary(1,"^|""MONTOLOGY""|IndexDictionary(""Vehicle"",""TransmissionType"",""uid"",888,1)")=1 ^RefsDictionary(2,"^|""MONTOLOGY""|IndexDictionary(""ID"",2,""ontology"")")=1 ^RefsDictionary(2,"^|""MONTOLOGY""|IndexDictionary(""ID"",2,""path"")")=1 ^RefsDictionary(2,"^|""MONTOLOGY""|IndexDictionary(""ID"",2,""type"")")=1 ^RefsDictionary(2,"^|""MONTOLOGY""|IndexDictionary(""Vehicle"",""TransmissionType"",""name"",""partUri"",""meh"",2)")=1 ^RefsDictionary(2,"^|""MONTOLOGY""|IndexDictionary(""Vehicle"",""TransmissionType"",""name"",""ru"","""",2)")=1 ^RefsDictionary(2,"^|""MONTOLOGY""|IndexDictionary(""Vehicle"",""TransmissionType"",""uid"",888,2)")=1
      
      





ご覧のとおり、これらのグローバルは「UpdateTime」の値のみが異なります。 辞書プログラムに変更を加えることは成功したとみなすことができます。




入れ子構造



ネストされたディレクトリ構造の最も単純な例を考えてみましょう。 VehicleオントロジーにMakeディレクトリが含まれ、その中にModelディレクトリ(vehicle make-models)が含まれているとします。 これらのディレクトリをルールグローバル^ RuleDIctionaryで説明します。 便宜上、グローバルルールを初期化するInitRuleDicプログラムを作成します。 また、デフォルトでディレクトリとオントロジーのルールを作成します。 プログラム内で^ RuleDictionaryの代わりに、 $$$ dRuleの略記法を使用できるようになりました



 #; ------------------------------------------------------------------------------------------------------------ #include Dictionary #; ------------------------------------------------------------------------------------------------------------ InitRuleDic #; ------------------------------------------------------------------------------------------------------------ kill $$$dRule set $$$dRule("SimpleOntology","SimpleType","create","check",10)="do processingNames(""clearPunctuationAndControlChar"")" set $$$dRule("SimpleOntology","SimpleType","create","check",20)="s check=$$checkUniqueNameElementAllLang()" set $$$dRule("SimpleOntology","SimpleType","update","check",10)="do processingNames(""clearPunctuationAndControlChar"")" set $$$dRule("SimpleOntology","SimpleType","update","check",20)="s check=$$checkUniqueNameElementAllLang()" set $$$dRule("Vehicle","Make","property","lastId")="otherId" set $$$dRule("Vehicle","Make","property","lastId","index")="true" set $$$dRule("Vehicle","Make","create","check",10)="do processingNames(""specialClearStr"")" set $$$dRule("Vehicle","Make","create","check",20)="s check=$$checkUniqueNameElementAllLang()" set $$$dRule("Vehicle","Make","create","check",50)="s check=$$checkUniqueParamElement(""lastId"",""Vehicle"",""Make"")" set $$$dRule("Vehicle","Make","update","check",10)="do processingNames(""specialClearStr"")" set $$$dRule("Vehicle","Make","update","check",20)="s check=$$checkUniqueNameElementAllLang()" set $$$dRule("Vehicle","Make","update","check",50)="s check=$$checkUniqueParamElement(""lastId"",""Vehicle"",""Make"")" set $$$dRule("Vehicle","Model","parent")="Make" set $$$dRule("Vehicle","Model","property","parentId")="parent" set $$$dRule("Vehicle","Model","property","parentId","index")="true" set $$$dRule("Vehicle","Model","property","lastId")="otherId" set $$$dRule("Vehicle","Model","property","lastId","index")="true" set $$$dRule("Vehicle","Model","create","check",15)="do processingNames(""specialClearStr"")" set $$$dRule("Vehicle","Model","create","check",20)="s check=$$checkUniqueNameElementAllLang(""true"")" set $$$dRule("Vehicle","Model","create","check",50)="s check=$$checkUniqueParamElement(""lastId"",""Vehicle"",""Model"")" set $$$dRule("Vehicle","Model","update","check",15)="do processingNames(""specialClearStr"")" set $$$dRule("Vehicle","Model","update","check",20)="s check=$$checkUniqueNameElementAllLang(""true"")" set $$$dRule("Vehicle","Model","update","check",50)="s check=$$checkUniqueParamElement(""lastId"",""Vehicle"",""Model"")" zwrite $$$dRule quit #; ------------------------------------------------------------------------------------------------------------
      
      





グローバルルールを詳しく見てみましょう。 Make参照では、 lastIdプロパティが表示されています。 これは、古いデータベース内のディレクトリ項目の識別子です(グローバルではありません)。 一部の場所では、過去の識別子がバインディングに使用される場合があるため、保持する必要があります。 このようなディレクトリの要素(異なるシステム)間の対応を見つけるタスクは、データ移行の分野で最も関連性の高いタスクの1つです。 otherIdプロパティのタイプはプログラムで処理されず、内部の内容をテキストで思い出させるだけです。必要に応じて、プロセッサがディレクトリ処理メソッドでこのタイプのプロパティにハングアップするのを防ぐことはできません。"ture"を持つインデックスブランチ示されるように、lastIdプロパティインデックス可能です。次は、要素を作成/更新するときにチェックするために使用される3つの関数のセットです。checkUniqueParamElement()関数は私たちにとって新しいものです-プログラムに追加してください。



checkUniqueParamElement()
 #; -------------------------------------------------------------------------------------------------- #;      . #; -------------------------------------------------------------------------------------------------- checkUniqueParamElement(param,ontology,type) new t #;    set t("value")=$$$getDTOin(param,"") #;   ,     -    quit:t("value")="" 0 #;    set t("q")=0 set t("uniqueId")="" for { #; ,         #;   , ,    set t("uniqueId")=$o($$$dIndex(ontology,type,param,t("value"),t("uniqueId"))) #;     quit:t("uniqueId")="" #; ,      #;     update if (t("uniqueId")`=$$$getDTOproc("id","")) { #;  ,       set t("q")=-1 quit } } quit t("q") #; --------------------------------------------------------------------------------------------------
      
      







create()メソッドの機能を拡張しましょう-プロパティの処理を追加します:

  st("property")="" for { #;    st("property")=$o($$$dDTO($j,"in",t("property"))) #;   ,    quit:t("property")="" #;  ,              continue:$get($$$dRule(t("ontology"),t("type"),"property",t("property")),"")="" #;    set t("index")=$get($$$dRule(t("ontology"),t("type"),"property",t("property"),"index"),"false") #;    set t("value")=$get($$$dDTO($j,"in",t("property")),"") #;     -   if t("value")`="" { do setProperty(t("ontology"),t("type"),t("property"),t("value"),t("id"),t("index"),$$$getDTOproc("pathParent","")) } }
      
      





フルバージョン作成
 #; -------------------------------------------------------------------------------------------------- #;   . #;         . #; -------------------------------------------------------------------------------------------------- create() #;     kill $$$dDTO($job,"out") #;     t #;         create new t #;      set t("err")=$$check("create") #; ,    if t("err")<0 { quit t("err") } st("ontology")=$$$getDTOin("ontology","") st("type")=$$$getDTOin("type","") st("id")=$$$getDTOproc("id","") #;   "UpdateTime" do setProperty(t("ontology"),t("type"),"UpdateTime",$horolog,t("id"),"false",$$$getDTOproc("pathParent","")) #;   "uid" do setProperty(t("ontology"),t("type"),"uid",$$$getDTOin("uid",888),t("id"),"true",$$$getDTOproc("pathParent","")) set t("lang")="" for { #;    (     ) set t("lang")=$order($$$dDTO($job,"in","nameList",t("lang"))) #;   ,     quit:t("lang")="" #;      set t("name")=$get($$$dDTO($job,"in","nameList",t("lang")),"") #;      do setName(t("ontology"),t("type"),t("lang"),t("name"),t("id")) } st("property")="" for { #;    st("property")=$o($$$dDTO($j,"in",t("property"))) #;   ,    quit:t("property")="" #;  ,              continue:$get($$$dRule(t("ontology"),t("type"),"property",t("property")),"")="" #;    set t("index")=$get($$$dRule(t("ontology"),t("type"),"property",t("property"),"index"),"false") #;    set t("value")=$get($$$dDTO($j,"in",t("property")),"") #;     -   if t("value")`="" { do setProperty(t("ontology"),t("type"),t("property"),t("value"),t("id"),t("index"),$$$getDTOproc("pathParent","")) } } #;          do saveOntoAndTypeID(t("id"),t("ontology"),t("type")) #;         do saveElementPath(t("id"),$$$getDTOproc("path","")) #;         $$$setDTOout("id",t("id")) #;     kill $$$dDTO($job,"in") #;     kill $$$dDTO($job,"porc") #;     quit t("id") #; --------------------------------------------------------------------------------------------------
      
      







行に注意して



ください do setProperty(t( "ontology")、t( "type")、t( "property")、t( "value")、t( "id")、t( "index")、 $$$ getDTOproc( "pathParent"、 ""))別のpathParentパラメーターがsetProperty()



メソッド呼び出しに追加されました-ネストの処理に必要です。



いくつかの自動車ブランドをディレクトリに追加します(ブランドは私がランダムに選んだものです-ここには広告はありません)。
 MONTOLOGY>kill ^tmwOntology($job) MONTOLOGY>set ^tmwOntology($job,"in","ontology")="Vehicle",^tmwOntology($job,"in","type")="Make" MONTOLOGY>set ^tmwOntology($job,"in","nameList","ru")="MAZDA",^tmwOntology($job,"in","nameList","partUri")="mazda" MONTOLOGY>set ^tmwOntology($job,"in","lastId")=122 MONTOLOGY>write $$create^Dictionary() 3 MONTOLOGY>kill ^tmwOntology($job) MONTOLOGY>set ^tmwOntology($job,"in","ontology")="Vehicle",^tmwOntology($job,"in","type")="Make" MONTOLOGY>set ^tmwOntology($job,"in","nameList","ru")="BMW",^tmwOntology($job,"in","nameList","partUri")="bmw" MONTOLOGY>set ^tmwOntology($job,"in","lastId")=1269 MONTOLOGY>write $$create^Dictionary() 4 MONTOLOGY>
      
      







モデル参照のルールよく見てください。枝があった親が値で«メイク» -これは、表示のための親ディレクトリつまりモデル、あるメイク。次にparentIdインデックス付きプロパティが宣言されます。このプロパティには、親識別子が格納されます。^辞書 globalのネストされたディレクトリの要素をchildrenブランチに保存します親要素。ネストレベルの数をプログラムで制限することはありません(変数インデックスの長さのみに制限があります)。また、ネストされたディレクトリのインデックスと名前は、通常のディレクトリとまったく同じ方法で保存されると想定しています。親チェック関数を作成します。



 #; -------------------------------------------------------------------------------------------------- #;   ,   . #;     . #; -------------------------------------------------------------------------------------------------- checkParent()private new t #;           (  ) st("parent")=$get($$$dRule($$$getDTOin("ontology",""),$$$getDTOin("type",""),"parent"),"") #;    if t("parent")`="" { #;    parentId      set t("parentId")=$$$getDTOin("parentId","") #;       if t("parentId")="" { quit -1 } #;       #;        if $get($$$dIndex("ID",t("parentId"),"ontology"),"")`=$$$getDTOin("ontology","") { quit -1 } #;       if $get($$$dIndex("ID",t("parentId"),"type"),"")`=t("parent") { quit -1 } #;     st("pathParent")=$get($$$dIndex("ID",t("parentId"),"path"),"") #;      if t("pathParent")="" { quit -1 } #;          $$$setDTOproc("pathParent",t("pathParent")) } #;      quit 0 #; --------------------------------------------------------------------------------------------------
      
      





ご覧のとおり、関数は、作成された要素がネストされているかどうかをグローバルなルールでチェックし、ネストされている場合、送信された親識別子の存在と正確性をチェックします。また、checkCreate()メソッドにいくつかの変更を加える必要があります。親チェックへの呼び出しをその中に追加し、^辞書グローバル内のディレクトリ項目へのパスを作成するためのルールを変更します。



 #; -------------------------------------------------------------------------------------------------- #;      . #; -------------------------------------------------------------------------------------------------- checkCreate()private new t #;       quit:$$$getDTOin("ontology","")="" -1 #;  ,      quit:$$$getDTOin("type","")="" -1 #;     st("check")=$$checkParent() #;  ,     quit:t("check")<0 t("check") #;     set t("check")=$$checkNames() #;  ,     quit:t("check")<0 t("check") #;       $$$setDTOproc("id",$$$dMaxID) #;      ^Dictionary if $$$getDTOproc("pathParent","")="" { #;    -     ^Dictionary(ontology) set t("path")=$name($$$dData($$$getDTOin("ontology",""))) } else { #;      -         children set t("path")=$name(@($$$getDTOproc("pathParent",""))@(0,"children")) } #;           st("path")=$name(@(t("path"))@($$$getDTOin("type",""),$$$getDTOproc("id",""))) $$$setDTOproc("path",t("path")) #;     quit 0 #; --------------------------------------------------------------------------------------------------
      
      





また、グローバルルールの次の行に注意して



ください。set $$$ dRule( "Vehicle"、 "Model"、 "create"、 "check"、20)= "s check = $$ checkUniqueNameElementAllLang(" "true" ")" checkUniqueNameElement()



メソッドに、1つのinparentパラメーターを追加しました、ディレクトリのすべての要素内で一意性をチェックする必要があるか、親内でのみ一意性をチェックする必要があるかを決定します。私たちの場合、これは簡単に説明できます。同じ名前の多くの車のモデルがありますが、ブランドは異なります。親内でのみ一致するかどうかを確認する必要があります。この場合、エラーが発生します。たとえば、アドレスディレクトリを実装するときに、同様の要件が発生する場合があります。ある国では、同じ名前の多数の集落があります。ニコラエフ、ポルタバ、チェルカースィなどのようなウクライナの集落のユニークな存在に驚くことはありませんでした。したがって、一意性がチェックされるドメインを制限する必要がある場合があります。



 #; -------------------------------------------------------------------------------------------------- #;      ,   ,   . #;  ,   . #; -------------------------------------------------------------------------------------------------- checkUniqueNameElement(ontology,type,lang,name,id,inparent="false") new t #;    set t("q")=0 set t("uniqueId")="" for { #; ,         #;   , ,   (  ) set t("uniqueId")=$order($$$dIndex(ontology,type,"name",lang,$zconvert(name,"l"),t("uniqueId"))) #;     quit:t("uniqueId")="" #; ,      #;     update if (t("uniqueId")`=id) { #;          if inparent="false" { #;  ,       set t("q")=-1 quit } else { #;        if $data($$$dIndex(ontology,type,"parentId",$$$getDTOin("parentId",""),t("uniqueId"))) { #;          #;    /  set t("q")=-1 quit } } } } #;   quit t("q") #; --------------------------------------------------------------------------------------------------
      
      





すべての辞書コード
 #; -------------------------------------------------------------------------------------------------- #;    Dictionary.inc,   (inc) -      #include Dictionary #; -------------------------------------------------------------------------------------------------- #;   #; -------------------------------------------------------------------------------------------------- Dictionary #; -------------------------------------------------------------------------------------------------- #;   . #; -------------------------------------------------------------------------------------------------- retrieve(id,lang="ru",version=0) quit $get($$$dName(id,lang,version),"") #; -------------------------------------------------------------------------------------------------- #;      . #; -------------------------------------------------------------------------------------------------- retrieveListByIndex(ontology,type,index,value,str="",lang="ru") #;     ,       set str=$zconvert(str,"L") set id="" for { #;  ()    set id=$order($$$dIndex(ontology,type,index,value,id)) #;  ,        quit:id="" #;   set name=$$retrieve(id,lang) #;      str if $extract($zconvert(name,"L"),1,$length(str))=str { #;  (  ) write id_" "_name,! } } quit #; -------------------------------------------------------------------------------------------------- #;   . #;         . #; -------------------------------------------------------------------------------------------------- create() #;     kill $$$dDTO($job,"out") #;     t #;         create new t #;      set t("err")=$$check("create") #; ,    if t("err")<0 { quit t("err") } st("ontology")=$$$getDTOin("ontology","") st("type")=$$$getDTOin("type","") st("id")=$$$getDTOproc("id","") #;   "UpdateTime" do setProperty(t("ontology"),t("type"),"UpdateTime",$horolog,t("id"),"false",$$$getDTOproc("pathParent","")) #;   "uid" do setProperty(t("ontology"),t("type"),"uid",$$$getDTOin("uid",888),t("id"),"true",$$$getDTOproc("pathParent","")) set t("lang")="" for { #;    (     ) set t("lang")=$order($$$dDTO($job,"in","nameList",t("lang"))) #;   ,     quit:t("lang")="" #;      set t("name")=$get($$$dDTO($job,"in","nameList",t("lang")),"") #;      do setName(t("ontology"),t("type"),t("lang"),t("name"),t("id")) } st("property")="" for { #;    st("property")=$order($$$dDTO($j,"in",t("property"))) #;   ,    quit:t("property")="" #;  ,              continue:$get($$$dRule(t("ontology"),t("type"),"property",t("property")),"")="" #;    set t("index")=$get($$$dRule(t("ontology"),t("type"),"property",t("property"),"index"),"false") #;    set t("value")=$get($$$dDTO($j,"in",t("property")),"") #;     -   if t("value")`="" { do setProperty(t("ontology"),t("type"),t("property"),t("value"),t("id"),t("index"),$$$getDTOproc("pathParent","")) } } #;          do saveOntoAndTypeID(t("id"),t("ontology"),t("type")) #;         do saveElementPath(t("id"),$$$getDTOproc("path","")) #;         $$$setDTOout("id",t("id")) #;     kill $$$dDTO($job,"in") #;     kill $$$dDTO($job,"porc") #;     quit t("id") #; -------------------------------------------------------------------------------------------------- #;  . #;    ^RuleDictionary    . #; -------------------------------------------------------------------------------------------------- check(action)private #;     check new check #;        action set check=$case(action,"create":$$checkCreate(),"update":$$checkUpdate(),"delete":$$checkDelete(),:-1) #;   quit:check<0 check #; ,      "check",        if $data($$$dRule($$$getDTOin("ontology",""),$$$getDTOin("type",""),action,"check")) { #;  check("map")        set check("map")=$name($$$dRule($$$getDTOin("ontology",""),$$$getDTOin("type",""),action,"check")) } else { #;  check("map")              set check("map")=$name($$$dRule("SimpleOntology","SimpleType",action,"check")) } set check("i")="" for { #;     set check("i")=$order(@check("map")@(check("i"))) #;   ,     quit:check("i")="" #;     xecute $get(@check("map")@(check("i"))) #;   ,     quit:check<0 } #;    quit check #; -------------------------------------------------------------------------------------------------- #;      . #; -------------------------------------------------------------------------------------------------- checkCreate()private new t #;       quit:$$$getDTOin("ontology","")="" -1 #;  ,      quit:$$$getDTOin("type","")="" -1 #;     st("check")=$$checkParent() #;  ,     quit:t("check")<0 t("check") #;     set t("check")=$$checkNames() #;  ,     quit:t("check")<0 t("check") #;       $$$setDTOproc("id",$$$dMaxID) #;      ^Dictionary if $$$getDTOproc("pathParent","")="" { #;    -     ^Dictionary(ontology) set t("path")=$name($$$dData($$$getDTOin("ontology",""))) } else { #;      -         children set t("path")=$name(@($$$getDTOproc("pathParent",""))@(0,"children")) } #;           st("path")=$name(@(t("path"))@($$$getDTOin("type",""),$$$getDTOproc("id",""))) $$$setDTOproc("path",t("path")) #;     quit 0 #; -------------------------------------------------------------------------------------------------- #;   ,   . #;     . #; -------------------------------------------------------------------------------------------------- checkParent()private new t #;           (  ) st("parent")=$get($$$dRule($$$getDTOin("ontology",""),$$$getDTOin("type",""),"parent"),"") #;    if t("parent")`="" { #;    parentId      set t("parentId")=$$$getDTOin("parentId","") #;       if t("parentId")="" { quit -1 } #;       #;        if $get($$$dIndex("ID",t("parentId"),"ontology"),"")`=$$$getDTOin("ontology","") { quit -1 } #;       if $get($$$dIndex("ID",t("parentId"),"type"),"")`=t("parent") { quit -1 } #;     st("pathParent")=$get($$$dIndex("ID",t("parentId"),"path"),"") #;      if t("pathParent")="" { quit -1 } #;          $$$setDTOproc("pathParent",t("pathParent")) } #;      quit 0 #; -------------------------------------------------------------------------------------------------- checkUpdate() quit 0 #; -------------------------------------------------------------------------------------------------- checkDelete() quit 0 #; -------------------------------------------------------------------------------------------------- #;     . #; -------------------------------------------------------------------------------------------------- checkNames()private new t #;   t("check")  #;         set t("check")=-1 set t("lang")="" for { #;    set t("lang")=$order($$$dDTO($job,"in","nameList",t("lang"))) #;   ,     quit:t("lang")="" #;      set t("name")=$get($$$dDTO($job,"in","nameList",t("lang")),"") #;    if t("name")="" { #;   t("check")  set t("check")=-1 #;    quit } else { #;  t("check")   ,     set t("check")=0 } } #;     quit t("check") #; -------------------------------------------------------------------------------------------------- #;    . #; -------------------------------------------------------------------------------------------------- processingNames(function) new t set t("lang")="" for { #;     set t("lang")=$order($$$dDTO($job,"in","nameList",t("lang"))) quit:t("lang")="" #;        xecute "set "_$name($$$dDTO($job,"in","nameList",t("lang")))_"=$$"_function_"("""_$$$getDTOname(t("lang"))_""")" } quit #; -------------------------------------------------------------------------------------------------- checkUniqueNameElementAllLang(inparent="false") new t set t("check")=0 st("ontology")=$$$getDTOin("ontology","") st("type")=$$$getDTOin("type","") set t("lang")="" for { #;     set t("lang")=$order($$$dDTO($job,"in","nameList",t("lang"))) quit:t("lang")="" #;    set t("name")=$get($$$dDTO($job,"in","nameList",t("lang")),"") #;   t("check")     (0 -  ) st("check")=$$checkUniqueNameElement(t("ontology"),t("type"),t("lang"),t("name"),$$$getDTOproc("id",""),inparent) #;     -    quit:t("check")<0 } quit t("check") #; -------------------------------------------------------------------------------------------------- #;         . #; -------------------------------------------------------------------------------------------------- clearPunctuationAndControlChar(str) new t #;  t("str")     set t("str")="" #;      for t("i")=1:1:$length(str) { #;    set t("ch")=$extract(str,t("i")) if `((t("ch")?1P)||(t("ch")?1C)) { #;       set t("str")=t("str")_t("ch") } } #;    quit t("str") #; -------------------------------------------------------------------------------------------------- #; -------------------------------------------------------------------------------------------------- #;       . #;      . #;        (     ). #;      ,   "."   . #; -------------------------------------------------------------------------------------------------- specialClearStr(str) new t set t("str")="",t("flag")="start",t("delim")="" for t("i")=1:1:$length(str) { set t("ch")=$extract(str,t("i")) ;#     set:t("ch")=$char(9) t("ch")=" " continue:(t("ch")?1C) if (t("flag")="start")&&`(t("ch")?1P) { set t("str")=t("ch"),t("flag")="word" } elseif t("flag")="word" { if `(t("ch")?1P) { set t("str")=t("str")_t("ch") } else { set t("delim")=t("ch"),t("flag")="delim" } } elseif t("flag")="delim" { if (t("ch")?1P) { set:t("ch")`=" " t("delim")=t("ch") } else { set t("str")=t("str")_t("delim")_t("ch"),t("flag")="word",t("delim")="" } } } set:t("delim")="." t("str")=t("str")_t("delim") quit t("str") #; -------------------------------------------------------------------------------------------------- #;      . #; -------------------------------------------------------------------------------------------------- checkUniqueParamElement(param,ontology,type) new t #;    set t("value")=$$$getDTOin(param,"") #;   ,     -    quit:t("value")="" 0 #;    set t("q")=0 set t("uniqueId")="" for { #; ,         #;   , ,    set t("uniqueId")=$order($$$dIndex(ontology,type,param,t("value"),t("uniqueId"))) #;     quit:t("uniqueId")="" #; ,      #;     update if (t("uniqueId")`=$$$getDTOproc("id","")) { #;  ,       set t("q")=-1 quit } } quit t("q") #; -------------------------------------------------------------------------------------------------- #;      ,   ,   . #;  ,   . #; -------------------------------------------------------------------------------------------------- checkUniqueNameElement(ontology,type,lang,name,id,inparent="false") new t #;    set t("q")=0 set t("uniqueId")="" for { #; ,         #;   , ,   (  ) set t("uniqueId")=$order($$$dIndex(ontology,type,"name",lang,$zconvert(name,"l"),t("uniqueId"))) #;     quit:t("uniqueId")="" #; ,      #;     update if (t("uniqueId")`=id) { #;          if inparent="false" { #;  ,       set t("q")=-1 quit } else { #;        if $data($$$dIndex(ontology,type,"parentId",$$$getDTOin("parentId",""),t("uniqueId"))) { #;          #;    /  set t("q")=-1 quit } } } } #;   quit t("q") #; -------------------------------------------------------------------------------------------------- #;  ,     . #;         . #; -------------------------------------------------------------------------------------------------- setProperty(ontology,type,property,value,id,index="true",pathParent="")private #;      ()    if pathParent="" { #;    set $$$dData(ontology,type,id,0,property)=value } else { #;    set @(pathParent)@(0,"children",type,id,0,property)=value } #;    if index="true" { #;   set $$$dIndex(ontology,type,property,value,id)=1 #;      set $$$dRefs(id,$name($$$dIndex(ontology,type,property,value,id)))=1 } quit 0 #; -------------------------------------------------------------------------------------------------- #;   ,     . #;  (  )   . #; -------------------------------------------------------------------------------------------------- setName(ontology,type,lang,value,id)private #;         set $$$dName(id,lang,0)=value #;   / set $$$dName(id,lang,0,"UpdateTime")=$horolog #;     set $$$dIndex(ontology,type,"name",lang,$zconvert(value,"l"),id)=1 #;    set $$$dRefs(id,$name($$$dIndex(ontology,type,"name",lang,$zconvert(value,"l"),id)))=1 quit 0 #; -------------------------------------------------------------------------------------------------- saveOntoAndTypeID(id,ontology,type) set $$$dIndex("ID",id,"ontology")=ontology set $$$dRefs(id,$name($$$dIndex("ID",id,"ontology")))=1 set $$$dIndex("ID",id,"type")=type set $$$dRefs(id,$name($$$dIndex("ID",id,"type")))=1 quit #; -------------------------------------------------------------------------------------------------- saveElementPath(id,path) set $$$dIndex("ID",id,"path")=path set $$$dRefs(id,$name($$$dIndex("ID",id,"path")))=1 quit #; --------------------------------------------------------------------------------------------------
      
      





' ` — . Caché — : ` '



いくつかのモデルを追加し、グローバルを印刷して、^ Dictionary globalでネストがどのように見えるかを確認します

 MONTOLOGY>kill ^tmwOntology($job) MONTOLOGY>set ^tmwOntology($job,"in","ontology")="Vehicle",^tmwOntology($job,"in","type")="Model" MONTOLOGY>set ^tmwOntology($job,"in","nameList","ru")=6,^tmwOntology($job,"in","nameList","partUri")=6 MONTOLOGY>set ^tmwOntology($job,"in","parentId")=3 MONTOLOGY>write $$create^Dictionary() 5 MONTOLOGY>kill ^tmwOntology($job) MONTOLOGY>set ^tmwOntology($job,"in","ontology")="Vehicle",^tmwOntology($job,"in","type")="Model" MONTOLOGY>set ^tmwOntology($job,"in","nameList","ru")="BMW",^tmwOntology($job,"in","nameList","partUri")="bmw" MONTOLOGY>^tmwOntology($job,"in","nameList","ru")=3,^tmwOntology($job,"in","nameList","partUri")=3 MONTOLOGY>write $$create^Dictionary() 6 MONTOLOGY>zw ^Dictionary ^Dictionary("MaxID")=6 ^Dictionary("Vehicle","Make",3,0,"UpdateTime")="62970,58071" ^Dictionary("Vehicle","Make",3,0,"children","Model",5,0,"UpdateTime")="62970,58071" ^Dictionary("Vehicle","Make",3,0,"children","Model",5,0,"parentId")=3 ^Dictionary("Vehicle","Make",3,0,"children","Model",5,0,"uid")=888 ^Dictionary("Vehicle","Make",3,0,"children","Model",6,0,"UpdateTime")="62970,58071" ^Dictionary("Vehicle","Make",3,0,"children","Model",6,0,"parentId")=3 ^Dictionary("Vehicle","Make",3,0,"children","Model",6,0,"uid")=888 ^Dictionary("Vehicle","Make",3,0,"lastId")=122 ^Dictionary("Vehicle","Make",3,0,"uid")=888 ^Dictionary("Vehicle","Make",4,0,"UpdateTime")="62970,58071" ^Dictionary("Vehicle","Make",4,0,"lastId")=1269 ^Dictionary("Vehicle","Make",4,0,"uid")=888 ^Dictionary("Vehicle","TransmissionType",1,0,"UpdateTime")="62970,58071" ^Dictionary("Vehicle","TransmissionType",1,0,"uid")=888 ^Dictionary("Vehicle","TransmissionType",2,0,"UpdateTime")="62970,58071" ^Dictionary("Vehicle","TransmissionType",2,0,"uid")=888 MONTOLOGY>zw ^IndexDictionary ^IndexDictionary("ID",1,"ontology")="Vehicle" ^IndexDictionary("ID",1,"path")="^|""MONTOLOGY""|Dictionary(""Vehicle"",""TransmissionType"",1)" ^IndexDictionary("ID",1,"type")="TransmissionType" ^IndexDictionary("ID",2,"ontology")="Vehicle" ^IndexDictionary("ID",2,"path")="^|""MONTOLOGY""|Dictionary(""Vehicle"",""TransmissionType"",2)" ^IndexDictionary("ID",2,"type")="TransmissionType" ^IndexDictionary("ID",3,"ontology")="Vehicle" ^IndexDictionary("ID",3,"path")="^|""MONTOLOGY""|Dictionary(""Vehicle"",""Make"",3)" ^IndexDictionary("ID",3,"type")="Make" ^IndexDictionary("ID",4,"ontology")="Vehicle" ^IndexDictionary("ID",4,"path")="^|""MONTOLOGY""|Dictionary(""Vehicle"",""Make"",4)" ^IndexDictionary("ID",4,"type")="Make" ^IndexDictionary("ID",5,"ontology")="Vehicle" ^IndexDictionary("ID",5,"path")="^|""MONTOLOGY""|Dictionary(""Vehicle"",""Make"",3,0,""children"",""Model"",5)" ^IndexDictionary("ID",5,"type")="Model" ^IndexDictionary("ID",6,"ontology")="Vehicle" ^IndexDictionary("ID",6,"path")="^|""MONTOLOGY""|Dictionary(""Vehicle"",""Make"",3,0,""children"",""Model"",6)" ^IndexDictionary("ID",6,"type")="Model" ^IndexDictionary("Vehicle","Make","lastId",122,3)=1 ^IndexDictionary("Vehicle","Make","lastId",1269,4)=1 ^IndexDictionary("Vehicle","Make","name","partUri","bmw",4)=1 ^IndexDictionary("Vehicle","Make","name","partUri","mazda",3)=1 ^IndexDictionary("Vehicle","Make","name","ru","bmw",4)=1 ^IndexDictionary("Vehicle","Make","name","ru","mazda",3)=1 ^IndexDictionary("Vehicle","Make","uid",888,3)=1 ^IndexDictionary("Vehicle","Make","uid",888,4)=1 ^IndexDictionary("Vehicle","Model","name","partUri",3,6)=1 ^IndexDictionary("Vehicle","Model","name","partUri",6,5)=1 ^IndexDictionary("Vehicle","Model","name","ru",3,6)=1 ^IndexDictionary("Vehicle","Model","name","ru",6,5)=1 ^IndexDictionary("Vehicle","Model","parentId",3,5)=1 ^IndexDictionary("Vehicle","Model","parentId",3,6)=1 ^IndexDictionary("Vehicle","Model","uid",888,5)=1 ^IndexDictionary("Vehicle","Model","uid",888,6)=1 ^IndexDictionary("Vehicle","TransmissionType","name","partUri","akp",1)=1 ^IndexDictionary("Vehicle","TransmissionType","name","partUri","meh",2)=1 ^IndexDictionary("Vehicle","TransmissionType","name","ru","",1)=1 ^IndexDictionary("Vehicle","TransmissionType","name","ru","",2)=1 ^IndexDictionary("Vehicle","TransmissionType","uid",888,1)=1 ^IndexDictionary("Vehicle","TransmissionType","uid",888,2)=1 MONTOLOGY>
      
      





MAZDAブランドの2つのモデルを追加しました3および6(数字はモデルの名前です)。



一箇所ですべてのクリーニングとディレクトリ
  kill ^Dictionary,^IndexDictionary,^NameDictionaryElement,^RefsDictionary d ^InitRuleDic kill ^tmwOntology($job) set ^tmwOntology($job,"in","ontology")="Vehicle",^tmwOntology($job,"in","type")="TransmissionType" set ^tmwOntology($job,"in","nameList","ru")=" ,",^tmwOntology($job,"in","nameList","partUri")="akp" write $$create^Dictionary(),! kill ^tmwOntology($job) set ^tmwOntology($job,"in","ontology")="Vehicle",^tmwOntology($job,"in","type")="TransmissionType" set ^tmwOntology($job,"in","nameList","ru")="",^tmwOntology($job,"in","nameList","partUri")="meh" write $$create^Dictionary(),! kill ^tmwOntology($job) set ^tmwOntology($job,"in","ontology")="Vehicle",^tmwOntology($job,"in","type")="Make" set ^tmwOntology($job,"in","nameList","ru")="MAZDA",^tmwOntology($job,"in","nameList","partUri")="mazda" set ^tmwOntology($job,"in","lastId")=122 write $$create^Dictionary(),! kill ^tmwOntology($job) set ^tmwOntology($job,"in","ontology")="Vehicle",^tmwOntology($job,"in","type")="Make" set ^tmwOntology($job,"in","nameList","ru")="BMW",^tmwOntology($job,"in","nameList","partUri")="bmw" set ^tmwOntology($job,"in","lastId")=1269 write $$create^Dictionary(),! kill ^tmwOntology($job) set ^tmwOntology($job,"in","ontology")="Vehicle",^tmwOntology($job,"in","type")="Model" set ^tmwOntology($job,"in","nameList","ru")=6,^tmwOntology($job,"in","nameList","partUri")=6 set ^tmwOntology($job,"in","parentId")=3 write $$create^Dictionary(),! kill ^tmwOntology($job) set ^tmwOntology($job,"in","ontology")="Vehicle",^tmwOntology($job,"in","type")="Model" set ^tmwOntology($job,"in","nameList","ru")=3,^tmwOntology($job,"in","nameList","partUri")=3 set ^tmwOntology($job,"in","parentId")=3 write $$create^Dictionary(),! zwrite ^Dictionary,^IndexDictionary,^NameDictionaryElement,^RefsDictionary
      
      







これらの記事では、トランザクション、ブロッキング、エラー処理の問題がまったく扱われていないという事実に多くの皆さんが注意を払っていると思います(エラーが発生した場合に-1を返すだけでは明らかに不十分です)。コメントに他の希望がなければ、これらの問題について次の記事で議論します。



これらの記事のグローバルとコードはライブプロジェクトで使用されます(この記事からは作成された要素の識別子は実際のシステムで使用されるものとは異なります)。



質問やコメントを歓迎します。データベースにこれを実装する方法を教えてください(グローバルがない場合でもSQLがある場合)。



ご清聴ありがとうございました。



All Articles