Çàïðîñû ê ìåòàäàííûì

Ê ñîæàëåíèþ, â ïëàòôîðìå 1Ñ8 íåò âîçìîæíîñòè âûïîëíÿòü çàïðîñû ê ìåòàäàííûì.

À ïðè àíàëèçå êîíôèãóðàöèè ïîðîé õî÷åòñÿ ïîëó÷èòü ñïèñîê âñåõ ñïðàâî÷íèêîâ èëè âñåõ ðåêâèçèòîâ äîêóìåíòîâ, êîòîðûå ñîäåðæàò îïðåäåëåííûé òèï.

Äëÿ òàêèõ öåëåé ïðîãðàììèñòû îáû÷íî ïèøóò îáõîä äåðåâà ìåòàäàííûõ.

ß òîæå òàê ðàíüøå äåëàë, íî ïîòîì íàïèñàë óíèâåðñàëüíóþ ôóíêöèþ îáõîäà äåðåâà.

Îíà íå ñëèøêîì øóñòðàÿ, ò.ê. èñïîëüçóåò êîìàíäó «Âûïîëíèòü» äëÿ îòáîðà ðåçóëüòàòà, íî â òàêèõ çàäà÷àõ øóñòðîñòü íå âñåãäà íóæíà.

Âîò êîä ôóíêöèè, îáõîäÿùåé ìåòàäàííûå:

Ôóíêöèÿ ÎáîéòèÌåòàäàííûå(Ï, Êîä)

                //Îáõîäèò ìåòàäàííûå, âûáèðàÿ êîä îòáîðà...

                ÌÄÊëàñc=Íîâûé Ìàññèâ();

                ÌÄÊëàñc.Äîáàâèòü("ÐåãèñòðûÑâåäåíèé");

                ÌÄÊëàñc.Äîáàâèòü("Êîíñòàíòû");

                ÌÄÊëàñc.Äîáàâèòü("Ñïðàâî÷íèêè");

                ÌÄÊëàñc.Äîáàâèòü("Äîêóìåíòû");

                ÌÄÊëàñc.Äîáàâèòü("ÐåãèñòðûÁóõãàëòåðèè");

                ÌÄÊëàñc.Äîáàâèòü("ÐåãèñòðûÍàêîïëåíèÿ");

                ÌÄÊëàñc.Äîáàâèòü("ÐåãèñòðûÐàñ÷åòà");

                ÌÄÊëàñc.Äîáàâèòü("Ïåðå÷èñëåíèÿ");

                ÌÄÊëàñc.Äîáàâèòü("Îò÷åòû");

                ÌÄÊëàñc.Äîáàâèòü("Îáðàáîòêè");

                ÌÄÊëàñc.Äîáàâèòü("ÆóðíàëûÄîêóìåíòîâ");

                ÌÄÊëàñc.Äîáàâèòü("ÏëàíûÂèäîâÕàðàêòåðèñòèê");

                ÌÄÊëàñc.Äîáàâèòü("ÏëàíûÑ÷åòîâ");

                ÌÄÊëàñc.Äîáàâèòü("ÁèçíåñÏðîöåññû");

                ÌÄÊëàñc.Äîáàâèòü("Çàäà÷è");

                ÌÄÊëàñc.Äîáàâèòü("ÏëàíûÂèäîâÐàñ÷åòà");

                ÒÇ=Íîâûé ÒàáëèöàÇíà÷åíèé();

                ÒÇ.Êîëîíêè.Äîáàâèòü("Êëàññ");

                ÒÇ.Êîëîíêè.Äîáàâèòü("Âèä");

                //ÒÇ.Êîëîíêè.Äîáàâèòü("Ðåêâèçèò");

                ÒÇ.Êîëîíêè.Äîáàâèòü("Àòðèáóò");

                ÒÇ.Êîëîíêè.Äîáàâèòü("ÒèïÀòðèáóòà");

                ÒÇ.Êîëîíêè.Äîáàâèòü("ÂèäÀòðèáóòà");

                ÒÇ.Êîëîíêè.Äîáàâèòü("Ñèíîíèì");

                ÒÇ.Êîëîíêè.Äîáàâèòü("Óðîâåíü");

                Ï.Âñòàâèòü("ÒÇ", ÒÇ);

                Ï.Âñòàâèòü("Ïðîïóñòèòü", ëîæü);        

                Äëÿ Êàæäîãî Êëàññ ÈÇ ÌÄÊëàñc Öèêë

                               Îïèñàíèå=Íîâûé Ñòðóêòóðà();

                               Îïèñàíèå.Âñòàâèòü("Êëàññ", Êëàññ);

                               Îïèñàíèå.Âñòàâèòü("Óðîâåíü", "Êëàññ");

                               ÎáîéòèÌåòàäàííûåÑëóæ(Ï, Îïèñàíèå, Êîä);

                               Åñëè Ï.Ïðîïóñòèòü Òîãäà

                                               Ïðîäîëæèòü;

                               ÊîíåöÅñëè;                      

                               Åñëè Êëàññ="Êîíñòàíòû" Òîãäà

                                               Äëÿ Êàæäîãî ÌÄÀòðèáóò ÈÇ Ìåòàäàííûå.Êîíñòàíòû Öèêë

                                                               Îïèñàíèå=Íîâûé Ñòðóêòóðà();

                                                               Îïèñàíèå.Âñòàâèòü("Êëàññ", Êëàññ);

                                                               Îïèñàíèå.Âñòàâèòü("Óðîâåíü", "Àòðèáóò");

                                                               Îïèñàíèå.Âñòàâèòü("Âèä", Íåîïðåäåëåíî);

                                                               Îïèñàíèå.Âñòàâèòü("Àòðèáóò", ÌÄÀòðèáóò.Èìÿ);

                                                               Îïèñàíèå.Âñòàâèòü("ÒèïÀòðèáóòà", ÌÄÀòðèáóò.Òèï);

                                                               Îïèñàíèå.Âñòàâèòü("ÂèäÀòðèáóòà", "Ðåêâèçèò");

                                                               ÎáîéòèÌåòàäàííûåÑëóæ(Ï, Îïèñàíèå, Êîä);

                                               ÊîíåöÖèêëà;

                                               ÏðîäîëæèòÜ;

                               ÊîíåöÅñëè;

                                Ïîïûòêà

                                               Äëÿ Êàæäîãî ÌÄÂèä ÈÇ Ìåòàäàííûå[Êëàññ] Öèêë

                                                               Îïèñàíèå=Íîâûé Ñòðóêòóðà();

                                                               Îïèñàíèå.Âñòàâèòü("Êëàññ", Êëàññ);

                                                               Îïèñàíèå.Âñòàâèòü("Âèä", ÌÄÂèä.Èìÿ);

                                                               Îïèñàíèå.Âñòàâèòü("Óðîâåíü", "Âèä");

                                                               Îïèñàíèå.Âñòàâèòü("Ñèíîíèì", ÌÄÂèä.Ñèíîíèì);

                                                               ÎáîéòèÌåòàäàííûåÑëóæ(Ï, Îïèñàíèå, Êîä);

                                                               Åñëè Ï.Ïðîïóñòèòü Òîãäà

                                                                              Ïðîäîëæèòü;

                                                               ÊîíåöÅñëè;

                                                               Ïîïûòêà

                                                                              Äëÿ Êàæäîãî ÌÄÀòðèáóò ÈÇ ÌÄÂèä.Ðåêâèçèòû Öèêë

                                                                                              Îïèñàíèå.Âñòàâèòü("Óðîâåíü", "Àòðèáóò");

                                                                                              Îïèñàíèå.Âñòàâèòü("Àòðèáóò", ÌÄÀòðèáóò.Èìÿ);

                                                                                              Îïèñàíèå.Âñòàâèòü("Ñèíîíèì", ÌÄÀòðèáóò.Ñèíîíèì);

                                                                                              Îïèñàíèå.Âñòàâèòü("ÒèïÀòðèáóòà", ÌÄÀòðèáóò.Òèï);

                                                                                              Îïèñàíèå.Âñòàâèòü("ÂèäÀòðèáóòà", "Ðåêâèçèò");

                                                                                              ÎáîéòèÌåòàäàííûåÑëóæ(Ï, Îïèñàíèå, Êîä);

                                                                              ÊîíåöÖèêëà;

                                                               Èñêëþ÷åíèå

                                                               ÊîíåöÏîïûòêè;

                                                               Ïîïûòêà

                                                                              Äëÿ Êàæäîãî ÌÄÀòðèáóò ÈÇ ÌÄÂèä.Èçìåðåíèÿ Öèêë

                                                                                              Îïèñàíèå.Âñòàâèòü("Óðîâåíü", "Àòðèáóò");

                                                                                              Îïèñàíèå.Âñòàâèòü("Àòðèáóò", ÌÄÀòðèáóò.Èìÿ);

                                                                                              Îïèñàíèå.Âñòàâèòü("Ñèíîíèì", ÌÄÀòðèáóò.Ñèíîíèì);

                                                                                              Îïèñàíèå.Âñòàâèòü("ÒèïÀòðèáóòà", ÌÄÀòðèáóò.Òèï);

                                                                                              Îïèñàíèå.Âñòàâèòü("ÂèäÀòðèáóòà", "Èçìåðåíèå");

                                                                                              ÎáîéòèÌåòàäàííûåÑëóæ(Ï, Îïèñàíèå, Êîä);

                                                                              ÊîíåöÖèêëà;

                                                               Èñêëþ÷åíèå

                                                               ÊîíåöÏîïûòêè;

                                                               Ïîïûòêà

                                                                              Äëÿ Êàæäîãî ÌÄÀòðèáóò ÈÇ ÌÄÂèä.Ðåñóðñû Öèêë

                                                                                              Îïèñàíèå.Âñòàâèòü("Óðîâåíü", "Àòðèáóò");

                                                                                              Îïèñàíèå.Âñòàâèòü("Àòðèáóò", ÌÄÀòðèáóò.Èìÿ);

                                                                                              Îïèñàíèå.Âñòàâèòü("Ñèíîíèì", ÌÄÀòðèáóò.Ñèíîíèì);

                                                                                              Îïèñàíèå.Âñòàâèòü("ÒèïÀòðèáóòà", ÌÄÀòðèáóò.Òèï);

                                                                                              Îïèñàíèå.Âñòàâèòü("ÂèäÀòðèáóòà", "Ðåñóðñ");

                                                                                              ÎáîéòèÌåòàäàííûåÑëóæ(Ï, Îïèñàíèå, Êîä);

                                                                              ÊîíåöÖèêëà;

                                                               Èñêëþ÷åíèå

                                                               ÊîíåöÏîïûòêè;

                                               ÊîíåöÖèêëà;

                               Èñêëþ÷åíèå

                               ÊîíåöÏîïûòêè;

                ÊîíåöÖèêëà;

                Âîçâðàò Ï;

ÊîíåöÔóíêöèè

Ôóíêöèÿ ÎáîéòèÌåòàäàííûåÑëóæ(Ï, Îïèñàíèå, Êîä)

                //îáêñÎáðàáîòêàÏðåðûâàíèÿÏîëüçîâàòåëÿ();

                Ï.Ïðîïóñòèòü = ëîæü;

                Ð = ëîæü;

                Âûïîëíèòü(Êîä);

                Åñëè Ð = èñòèíà Òîãäà

                               Ñòð = Ï.ÒÇ.Äîáàâèòü();

                                ÇàïîëíèòüÇíà÷åíèÿÑâîéñòâ(Ñòð, Îïèñàíèå);

                ÊîíåöÅñëè;

                Âîçâðàò Ð;

ÊîíåöÔóíêöèè

Ïàðàìåòðû ôóíêöèè:

Ï - ýòî ïóñòàÿ ñòðóêòóðà, â íåå â áóäåò äîáàâëåíà òàáëèöà çíà÷åíèé ñ ðåçóëüòàòîì â ïîëå "ÒÇ".

Êîä - ýòî óñëîâèå îòáîðà çàïèñåé èç ìåòàäàííûõ.

Äëÿ ôóíêöèè ìåòàäàííûå ïðåäñòàâëÿþòñÿ êàê ïëîñêàÿ òàáëèöà ñ êîëîíêàìè:

Àòðèáóò - èìÿ ðåêâèçèòà îáúåêòà (äëÿ óðîâíÿ "Àòðèáóò")

ÒèïÀòðèáóòà - òèï çíà÷åíèÿ ðåêâèçèòà îáúåêòà (äëÿ óðîâíÿ "Àòðèáóò")

ÂèäÀòðèáóòà - "Ðåêâèçèò", "Èçìåðåíèå", "Ðåñóðñ" (äëÿ óðîâíÿ "Àòðèáóò")

Ñèíîíèì - ñèíîíèì òåêóùåãî ìåòàäàííîãî, åñëè îí çàäàí (äëÿ óðîâíÿ "Âèä" èëè "Àòðèáóò")

Óðîâåíü - óðîâåíü òåêóùåé çàïèñè, ò.å. ÷òî îïèñûâàåò òåêóùàÿ çàïèñü "Êëàññ", "Âèä" èëè "Àòðèáóò"

Ò.å., ïî ñóòè, ìåòàäàííûå ðàññìàòðèâàþòñÿ êàê èåðàðõè÷åñêèé ñïðàâî÷íèê ñ óðîâíÿìè èåðàðõèè: Êëàññ, çàòåì Âèä, çàòåì Àòðèáóò.

Âûðàæåíèå äëÿ êîä çàïèñûâàåòñÿ íà ÿçûêå 1Ñ, ãäå Îïèñàíèå - òåêóùàÿ çàïèñü ìåòàäàííûõ, åñëè â ïåðåìåííóþ Ð âîçâðàùàåòñÿ èñòèíà, òî îñóùåñòâëÿåòñÿ îòáîð.

Ïðèìåð îòáîðà ðåêâèçèòîâ, ñîäåðæàùèõ òèï ÕðàíèëèùåÇíà÷åíèÿ:

Êîä = "Ð = Îïèñàíèå.Óðîâåíü = ""Àòðèáóò"" È Îïèñàíèå.ÒèïÀòðèáóòà.ÑîäåðæèòÒèï(Òèï(""ÕðàíèëèùåÇíà÷åíèÿ""))";

Ïðèìåð ïîëó÷åíèÿ ñïèñêà âñåõ ñïðàâî÷íèêîâ:

Êîä = "Ð = Îïèñàíèå.Óðîâåíü = ""Âèä"" È Îïèñàíèå.Êëàññ = "Ñïðàâî÷íèêè";

Çàïðîñ ê ìåòàäàííûì èñïîëüçîâàí òàêæå â ñëåäóþùèõ ìîèõ ðàçðàáîòêàõ:

·         Ãðàááåð êàðòèíîê

·         Ïðîâåðêà ðàçìåðà äàííûõ â õðàíèëèùàõ çíà÷åíèé

·         Àíàëèç ïðàâ äîñòóïà

Êîíå÷íî, îáðàáîòêó ìîæíî óñêîðèòü, èçáàâèòüñÿ îò Âûïîëíèòü, íî ïîêà è â òàêîì âèäå îíà íåïëîõî ñïðàâëÿåòñÿ.

Êàê âèäíî, íå âñå îáúåêòû ìåòàäàííûõ ïîääåðæèâàþòñÿ, íàïðèìåð, íåò áèçíåñ-ïðîöåññîâ, íî îñíîâíûå òèïû åñòü, îñòàëüíûå ìîæíî ïðèêðóòèòü. ;-)

Áóäóò èäåè - ïèøèòå, à ìîæåò áåðèòå, è ïîäòà÷èâàéòå ïîä ñâîè íóæäû, à ïîòîì øëèòå ìíå èñïðàâëåíèÿ. Åñëè ÷òî, îïóáëèêóþ.