डीबी। संदर्भ पुस्तकें। वैश्विक। नेस्टेड संरचनाएँ। जीवंत उदाहरण

ध्यान आकर्षित करने के लिए एक तस्वीर, एक व्यंग्य में पैराशूट के साथ कैमरे के आगामी "घोंसले के शिकार" के उदाहरण को प्रदर्शित करने के लिए।

भाग 1
भाग २
भाग ३

पिछली बार, हमने इस तथ्य पर समझौता किया था कि हमारे पास एक बनाने () विधि है, जो नियमों के आधार पर वैश्विक ^ नियम , निर्देशिका तत्व बनाता है। हमने एक सरल, एकल-स्तरीय निर्देशिका के तत्वों को बनाने के एक उदाहरण का विश्लेषण किया है। आज, हम विचार करेंगे कि कैसे, हमारे ग्लोबल्स और तरीकों की मदद से, नेस्टेड संरचनाएं बनाना संभव है।

प्रोग्राम कोड में , "पारदर्शी" चर टी और मानचित्र का उपयोग किया गया था, जो स्पष्ट रूप से तरीकों से पारित नहीं होते हैं, लेकिन उनके अंदर उपलब्ध हैं। मुझे बताया गया था कि यह काम प्रदर्शित करने का सबसे अच्छा तरीका नहीं है, विशेष रूप से यह देखते हुए कि ज्यादातर के लिए, कैच ऑब्जेक्ट स्क्रिप्ट का वाक्यविन्यास नया है। इसलिए, नेस्टेड संरचनाओं के साथ आगे बढ़ने से पहले, हम कार्यक्रम में कुछ बदलाव करेंगे।


मैक्रो


मैक्रों आपको स्थिरांक, वैश्विक और स्थानीय चर, कोड के अलग-अलग टुकड़े, और अधिक के लिए उपनाम (अन्य नाम) निर्दिष्ट करने की अनुमति देते हैं। मैक्रोज़ का उपयोग करने का लाभ यह है कि यदि आप अपने डेटा (नाम स्थान, वैश्विक, आदि) के वास्तविक स्थान को बदलते हैं, तो आपको प्रोग्राम कोड में कुछ भी बदलने की आवश्यकता नहीं है, बस एक मैक्रो (इंक फ़ाइल में) को बदल दें, परियोजना को फिर से शुरू करें, और सब कुछ नए नामों के साथ काम करेगा। इसके अलावा, मैक्रोज़ का उपयोग आपको बिना समझ खोए रिकॉर्डिंग को कम करने की अनुमति देता है। मैक्रो को सेवा शब्द #define द्वारा घोषित किया जाता है, फिर मैक्रो का नाम एक स्पेस से होकर गुजरता है, और स्पेस के बाद भी संकेत दिया जाता है कि यह मैक्रो क्या है। मैक्रोज़ अपने भीतर अन्य मैक्रो शामिल कर सकते हैं, मुख्य बात यह है कि उन्हें पहले परिभाषित किया जाएगा। आप मैक्रोज़ को पैरामीटर पास कर सकते हैं (मैक्रो पैरामीटर एक % से शुरू होते हैं)।

# डेफ़ाइन डीनेम स्पेस "मोनोलॉजी"

यह मैक्रो मॉन्टोलॉजी के बजाय एक उपनाम बनाता है - अब हम $ $ $ $ लिख सकते हैं। तीन डॉलर का मतलब है कि डेवलपर द्वारा मैक्रो बनाया गया था (सिस्टम एक नहीं)। इस तथ्य के बावजूद कि $ $ $ डीएननेमस्पेस में "मोनोटॉलॉजी " की तुलना में अधिक वर्ण और कम स्पष्टता है, यह मैक्रो हमारे लिए बहुत उपयोगी है, क्योंकि इसका उपयोग अन्य मैक्रोज़ में किया जाएगा, और प्रोग्राम कोड में, यह व्यावहारिक रूप से नहीं होगा।

मान लीजिए हमारे पास निम्नलिखित 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 (डिक्शनरी डेटा ट्रांसफर ऑब्जेक्ट) - हम उप-वर्ग के बीच मापदंडों को स्थानांतरित करने के लिए, पारदर्शी चर मानचित्र के बजाय उपयोग करेंगे। $ नौकरी एक सिस्टम वैरिएबल है जिसके अंदर वर्तमान प्रक्रिया संख्या संग्रहीत होती है। यही है, हम मानते हैं कि कई प्रक्रियाएँ एक साथ काम कर सकती हैं ^ | "MONTOLOGY" | tmwOntology वैश्विक , $$$ dDTO मैक्रो द्वारा सुलभ। उनमें से प्रत्येक अपने स्वयं के सूचकांक $ $ $ $ dDTO ($ नौकरी) को संदर्भित करेगा, और फिर निम्नलिखित सेवा शाखाओं का उपयोग किया जाएगा:


पिछले लेखों से हमारे ग्लोबल्स, निम्न मैक्रोज़ का उपयोग करके प्रोग्राम कोड के अंदर उपलब्ध हैं:

उदाहरण के लिए, हम शब्दकोश कार्यक्रम की पहली विधि को फिर से लिखते हैं, मैक्रोज़ के उपयोग को ध्यान में रखते हुए

यह (मैक्रोज़ के बिना) था:
 #; -------------------------------------------------------------------------------------------------- #;   #; -------------------------------------------------------------------------------------------------- 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 #; -------------------------------------------------------------------------------------------------- 

कार्यक्रम की लिस्टिंग में, प्रतीक को ' एक प्रतीक द्वारा बदल दिया जाता है ' - यह कोड के अधिक सुंदर प्रदर्शन के लिए आवश्यक है। कैच में प्रोग्राम कोड की प्रतिलिपि बनाने के मामले में, रिवर्स रिप्लेसमेंट को अंजाम देना आवश्यक है: सभी पात्रों को बदलें

परिवर्तित नियम वैश्विक:

 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()" 


हम ग्लोबल्स (नियमों को छोड़कर वैश्विक) को हटा देंगे और पिछली बार के अनुसार , निर्देशिका के पहले दो तत्वों को सम्मिलित करेंगे, ताकि यह सुनिश्चित किया जा सके कि हमने मैक्रों पर स्विच करने और पारदर्शी चर से बचने के दौरान कहीं भी कोई गलती नहीं की।

परिवर्तित शब्दकोश कार्यक्रम की जाँच
^ नियम नियम वैश्विक को छोड़कर हमारे सभी ग्लोबल्स को हटा दें:
 MONTOLOGY>kill ^Dictionary,^IndexDictionary,^NameDictionaryElement,^RefsDictionary MONTOLOGY> 

चलो निर्देशिका के पहले दो तत्व बनाते हैं:
 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 

जैसा कि आप देख सकते हैं, ये ग्लोबल्स केवल "अपडेटटाइम" के मूल्य में इन से भिन्न हैं। शब्दकोश कार्यक्रम में परिवर्तन करना सफल माना जा सकता है।


नेस्टेड स्ट्रक्चर्स


नेस्टेड निर्देशिका संरचनाओं के सबसे सरल उदाहरण पर विचार करें। मान लीजिए कि वाहन ऑन्कोलॉजी में मेक निर्देशिका शामिल है, जिसके अंदर मॉडल निर्देशिका (वाहन मेक-मॉडल) शामिल है। हम अपने नियम में इन निर्देशिकाओं का वर्णन करेंगे वैश्विक नियम नियम। सुविधा के लिए, एक InitRuleDic प्रोग्राम बनाएं जो हमारे वैश्विक नियमों को आरंभ करेगा। हम इसमें डिफ़ॉल्ट रूप से निर्देशिकाओं और ऑन्कोलॉजी के नियमों को भी लिखते हैं। मुझे याद दिलाना है कि ^ नियम के बजाय, कार्यक्रमों के अंदर, अब हमारे पास संक्षिप्त रूप से $ $ $ $ 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 #; ------------------------------------------------------------------------------------------------------------ 

आइए हमारे वैश्विक नियमों पर एक नज़र डालें। मेक संदर्भ में, अंतिम संपत्ति दिखाई दी है । यह पुराने डेटाबेस में निर्देशिका आइटम की पहचानकर्ता है (ग्लोबल्स नहीं)। कुछ स्थानों पर, पिछले पहचानकर्ता का उपयोग बाध्यकारी के लिए किया जा सकता है, इसलिए इसे बनाए रखा जाना चाहिए। ऐसी निर्देशिकाओं के तत्वों (विभिन्न प्रणालियों में) के बीच पत्राचार खोजने का कार्य अभी भी डेटा माइग्रेशन के क्षेत्र में सबसे अधिक प्रासंगिक है। अन्य आईडियल प्रॉपर्टी के प्रकार को प्रोग्राम में प्रोसेस नहीं किया जाता है, यह सिर्फ एक टेक्स्ट रिमाइंडर है जो अंदर है। यदि आवश्यक हो, तो कुछ भी नहीं प्रोसेसर को इस प्रकार की संपत्ति को निर्देशिका प्रसंस्करण विधियों में लटकाए जाने से रोक देगा। अंतिम संपत्ति प्रॉपर्टी इंडेक्सेबल है, जैसा कि इंडेक्स शाखा द्वारा "ट्यूर" के साथ दर्शाया गया है। अगला तीन तत्वों का एक सेट है जिसका उपयोग किसी तत्व को बनाते / अद्यतन करते समय जांचने के लिए किया जाता है। 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") #; -------------------------------------------------------------------------------------------------- 


आइए हमारी बनाएँ () विधि की कार्यक्षमता का विस्तार करें - इसमें गुणों के प्रसंस्करण को जोड़ें:
  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"), $$$ getDTOTc "पथप्रदर्शक", "")

एक अन्य पथप्रदर्शक पैरामीटर को सेटप्रॉपर्टी () विधि में कॉल में जोड़ा गया था - यह घोंसले से निपटने के लिए आवश्यक है।

( - ).
 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> 


Model . parent «Make» — , , Model , Make . parentId , . , ^Dictionary , 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() : , ^Dictionary .

 #; -------------------------------------------------------------------------------------------------- #;      . #; -------------------------------------------------------------------------------------------------- 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() 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
 #; -------------------------------------------------------------------------------------------------- #;    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 .
 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 : 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).

आपका ध्यान देने के लिए धन्यवाद।

Source: https://habr.com/ru/post/In179949/


All Articles