Skip to content

Commit 3475c0b

Browse files
authored
Чтение описание типов реквизитов и метаданных (#519)
* typo fix * impl ValueTypeOwner * fix converters for forms items * - скорректирована структура Колонок журнала документов: убраны несуществующие колонки + добавлен список ссылок на реквизиты документов - доработан конвертор типов - корректировка тестов * - Доработано чтение типов и квалификаторов - рефакторинг, фикс тестов * sq fixes * дополнил документацию примерами * fix
1 parent b0401df commit 3475c0b

File tree

113 files changed

+26375
-957
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+26375
-957
lines changed

build.gradle.kts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ gitVersioning.apply {
4444
repositories {
4545
mavenLocal()
4646
mavenCentral()
47+
maven("https://central.sonatype.com/repository/maven-snapshots")
4748
}
4849

4950
dependencies {
@@ -57,9 +58,11 @@ dependencies {
5758

5859
// прочее
5960
implementation("commons-io", "commons-io", "2.18.0")
61+
implementation("io.github.1c-syntax", "bsl-common-library", "0.9.0.9-SNAPSHOT")
6062
implementation("io.github.1c-syntax", "utils", "0.6.3")
61-
implementation("io.github.1c-syntax", "bsl-common-library", "0.8.1")
62-
implementation("io.github.1c-syntax", "supportconf", "0.14.3")
63+
implementation("io.github.1c-syntax", "supportconf", "0.14.3") {
64+
exclude("io.github.1c-syntax", "bsl-common-library")
65+
}
6366

6467
// быстрый поиск классов
6568
implementation("io.github.classgraph", "classgraph", "4.8.179")

docs/ru/examples.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- [Работа с метаданными](#работа-с-метаданными)
1010
- [Работа с формами](#работа-с-формами)
1111
- [Работа с модулями](#работа-с-модулями)
12+
- [Анализ описания типов данных](#анализ-типов-данных)
1213
- [Поиск и фильтрация объектов](#поиск-и-фильтрация-объектов)
1314
- [Практические сценарии](#практические-сценарии)
1415

@@ -269,6 +270,139 @@ allModules.stream()
269270
});
270271
```
271272

273+
## Анализ типов данных
274+
275+
При чтении описания метаданных для объектов и их атрибутов вычисляются описания типов. Все сущности, имеющие описания типов данных, реализуют интерфейс `ValueTypeOwner`.
276+
277+
Ниже приведены примеры, как можно использовать данную информацию.
278+
279+
### Получение описания типа реквизита справочника
280+
281+
Часть описания реквизита справочника
282+
283+
```xml
284+
<attributes uuid="dff5b5d8-762d-4490-a336-dcc8d93c17d5">
285+
<name>Реквизит2</name>
286+
<type>
287+
<types>Number</types>
288+
<numberQualifiers>
289+
<precision>10</precision>
290+
</numberQualifiers>
291+
</type>
292+
<minValue xsi:type="core:UndefinedValue"/>
293+
<maxValue xsi:type="core:UndefinedValue"/>
294+
<fillValue xsi:type="core:UndefinedValue"/>
295+
<fullTextSearch>Use</fullTextSearch>
296+
</attributes>
297+
```
298+
299+
Код, которым можно посмотреть описание типа
300+
301+
```java
302+
// найдем справочник из прочитанной конфигурации
303+
var childMDO = configuration.findChild("Catalog.Справочник1");
304+
305+
// проверим, что это на самом деле справочник
306+
if (childMDO.isPresent() && childMDO.get() instanceof Catalog catalog) {
307+
308+
// убедимся, что у справочника есть дочерние
309+
assertThat(catalog.getChildren()).isNotEmpty();
310+
311+
// найдем нужный дочерний (реквизит)
312+
var childAttribute = catalog.findChild(md -> "Реквизит2".equals(md.getName()));
313+
314+
// проверим, что он есть и нужного типа
315+
if (childAttribute.isPresent() && childAttribute.get() instanceof ObjectAttribute objectAttribute) {
316+
317+
// проверим наименование
318+
assertThat(objectAttribute.getName()).isEqualTo("Реквизит2");
319+
320+
// описание типа `getValueType`
321+
assertThat(objectAttribute.getValueType()).isNotNull();
322+
// убеимся в наличии примитивного типа СТРОКА в составе описания
323+
assertThat(objectAttribute.getValueType().contains(PrimitiveValueType.NUMBER)).isTrue();
324+
// убедимся, что тип не составно
325+
assertThat(objectAttribute.getValueType().isComposite()).isFalse();
326+
// убедимся, что квалификаторы прочитаны
327+
assertThat(objectAttribute.getValueType().getQualifiers()).hasSize(1);
328+
329+
// убедимся, что прочитан квалификатор числа
330+
var qualifier = objectAttribute.getValueType().getQualifiers().get(0);
331+
assertThat(qualifier).isInstanceOf(NumberQualifiers.class);
332+
333+
// убаимся, что квалификатор числа содожержит верную информацию
334+
var numberQualifiers = (NumberQualifiers) qualifier;
335+
assertThat(numberQualifiers.getPrecision()).isEqualTo(10); // длина 10
336+
assertThat(numberQualifiers.getScale()).isEqualTo(0); // точность 0
337+
assertThat(numberQualifiers.isNonNegative()).isFalse(); // возможны любые знаки
338+
}
339+
}
340+
}
341+
```
342+
343+
### Определение состава определяемого типа
344+
345+
Часть описания определяемого типа
346+
347+
```xml
348+
<name>ЗначениеДоступа</name>
349+
<type>
350+
<types>CatalogRef.ПапкиФайлов</types>
351+
<types>CatalogRef.ВнешниеПользователи</types>
352+
<types>CatalogRef.КлючиДоступа</types>
353+
<types>CatalogRef.ИдентификаторыОбъектовРасширений</types>
354+
<types>CatalogRef.ГруппыВнешнихПользователей</types>
355+
<types>CatalogRef.ГруппыПользователей</types>
356+
<types>EnumRef.ДополнительныеЗначенияДоступа</types>
357+
<types>ChartOfCharacteristicTypesRef.ДополнительныеРеквизитыИСведения</types>
358+
<types>CatalogRef.ДополнительныеОтчетыИОбработки</types>
359+
<types>CatalogRef.Пользователи</types>
360+
<types>CatalogRef.ГруппыИсполнителейЗадач</types>
361+
<types>CatalogRef.УчетныеЗаписиЭлектроннойПочты</types>
362+
<types>CatalogRef.ИдентификаторыОбъектовМетаданных</types>
363+
</type>
364+
```
365+
366+
Код, которым можно посмотреть описание типа
367+
368+
```java
369+
370+
// найдем определяемый тип прочитанной конфигурации
371+
var childMDO = configuration.findChild("DefinedType.ЗначениеДоступа");
372+
if (childMDO.isPresent() && childMDO.get() instanceof DefinedType definedType) {
373+
assertThat(definedType.getName()).isEqualTo("ЗначениеДоступа");
374+
// убедимся, что тип прочитан
375+
assertThat(definedType.getValueType()).isNotNull();
376+
// убедимся, что в составе нет ЧИСЛА
377+
assertThat(definedType.getValueType().contains(PrimitiveValueType.NUMBER)).isFalse();
378+
// убедимся, что описание соответствует составному типу
379+
assertThat(definedType.getValueType().isComposite()).isTrue();
380+
// квалификаторов нет
381+
assertThat(definedType.getValueType().getQualifiers()).isEmpty();
382+
383+
// создадим типа по имени
384+
var typeContains = MetadataValueType.fromString("EnumRef.ДополнительныеЗначенияДоступа");
385+
386+
assertThat(typeContains).isNotNull();
387+
// полученый тип относится к перечислению
388+
assertThat(typeContains.getKind()).isEqualTo(MDOType.ENUM);
389+
// тип не составной
390+
assertThat(typeContains.isComposite()).isFalse();
391+
// есть имя на английском
392+
assertThat(typeContains.getName()).isEqualTo("EnumRef.ДополнительныеЗначенияДоступа");
393+
// и русском
394+
assertThat(typeContains.getNameRu()).isEqualTo("ПеречислениеСсылка.ДополнительныеЗначенияДоступа");
395+
396+
// второй тип
397+
var typeNotContains = MetadataValueType.fromString("CatalogRef.Контрагенты");
398+
assertThat(typeNotContains).isNotNull();
399+
// убедимся, что первый тип входит в состав описания
400+
assertThat(definedType.getValueType().contains(typeContains)).isTrue();
401+
// убедимся, что второй тип нпе входит в состав
402+
assertThat(definedType.getValueType().contains(typeNotContains)).isFalse();
403+
}
404+
```
405+
272406
## Поиск и фильтрация объектов
273407

274408
### Поиск объекта по ссылке

docs/ru/features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
## Поддерживаемые метаданные
2424

25-
На данный момент поддерживается загрузка всех видов метаданных, существующих в версиях платформы 1С до 8.3.24. В заивисимости от типа объекта и потребностей, объем читаемой информации может различаться (реализация чтения дополнительной информации выполняется от задач).
25+
На данный момент поддерживается загрузка всех видов метаданных, существующих в версиях платформы 1С до 8.5. В зависимости от типа объекта и потребностей, объем читаемой информации может различаться (реализация чтения дополнительной информации выполняется от задач).
2626
Актуальное содержимое того или иного вида объекта метаданных можно всегда находится в классе его реализации в пакете [mdo](com.github._1c_syntax.bsl.mdo).
2727

2828
Немного о структуре пакета:

src/main/java/com/github/_1c_syntax/bsl/mdclasses/Configuration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public class Configuration implements CF {
113113
*/
114114
public static final Configuration EMPTY = createEmptyConfiguration();
115115

116-
private static final List<RoleRight> POSSIBLE_RIGHTS = computePossibleRighs();
116+
private static final List<RoleRight> POSSIBLE_RIGHTS = computePossibleRights();
117117

118118
/*
119119
* CF
@@ -406,7 +406,7 @@ private static Configuration createEmptyConfiguration() {
406406
.build();
407407
}
408408

409-
private static List<RoleRight> computePossibleRighs() {
409+
private static List<RoleRight> computePossibleRights() {
410410
return List.of(
411411
RoleRight.ADMINISTRATION,
412412
RoleRight.DATA_ADMINISTRATION,

src/main/java/com/github/_1c_syntax/bsl/mdo/AccumulationRegister.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
/*
2-
* This file is a part of MDClasses.
3-
*
4-
* Copyright (c) 2019 - 2025
5-
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6-
*
7-
* SPDX-License-Identifier: LGPL-3.0-or-later
8-
*
9-
* MDClasses is free software; you can redistribute it and/or
10-
* modify it under the terms of the GNU Lesser General Public
11-
* License as published by the Free Software Foundation; either
12-
* version 3.0 of the License, or (at your option) any later version.
13-
*
14-
* MDClasses is distributed in the hope that it will be useful,
15-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17-
* Lesser General Public License for more details.
18-
*
19-
* You should have received a copy of the GNU Lesser General Public
20-
* License along with MDClasses.
21-
*/
22-
package com.github._1c_syntax.bsl.mdo;
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2025
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.bsl.mdo;
2323

2424
import com.github._1c_syntax.bsl.mdo.children.Dimension;
2525
import com.github._1c_syntax.bsl.mdo.children.ObjectCommand;
@@ -49,7 +49,7 @@
4949
@EqualsAndHashCode(of = {"name", "uuid"})
5050
public class AccumulationRegister implements Register, AccessRightsOwner {
5151

52-
private static final List<RoleRight> POSSIBLE_RIGHTS = computePossibleRighs();
52+
private static final List<RoleRight> POSSIBLE_RIGHTS = computePossibleRights();
5353

5454
/*
5555
* Register
@@ -137,7 +137,7 @@ private List<Module> computeAllModules() {
137137
return LazyLoader.computeAllModules(this);
138138
}
139139

140-
private static List<RoleRight> computePossibleRighs() {
140+
private static List<RoleRight> computePossibleRights() {
141141
return List.of(
142142
RoleRight.READ,
143143
RoleRight.UPDATE,

src/main/java/com/github/_1c_syntax/bsl/mdo/Attribute.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
import com.github._1c_syntax.bsl.mdo.support.IndexingType;
2626

2727
/**
28-
* Интерфейс объектов, выступающих в роли реквизитов, т.е. хранящие данные
28+
* Интерфейс объектов, выступающих в роли реквизитов, т.е. хранящих данные
2929
* это могут быть реквизиты, колонки, измерения, а также общие реквизиты и константы
3030
*/
31-
public interface Attribute extends MDChild {
31+
public interface Attribute extends MDChild, ValueTypeOwner {
3232
/**
3333
* Режим пароля. Только для реквизитов с типом с типом `Строка`
3434
*/

src/main/java/com/github/_1c_syntax/bsl/mdo/BusinessProcess.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
/*
2-
* This file is a part of MDClasses.
3-
*
4-
* Copyright (c) 2019 - 2025
5-
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6-
*
7-
* SPDX-License-Identifier: LGPL-3.0-or-later
8-
*
9-
* MDClasses is free software; you can redistribute it and/or
10-
* modify it under the terms of the GNU Lesser General Public
11-
* License as published by the Free Software Foundation; either
12-
* version 3.0 of the License, or (at your option) any later version.
13-
*
14-
* MDClasses is distributed in the hope that it will be useful,
15-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17-
* Lesser General Public License for more details.
18-
*
19-
* You should have received a copy of the GNU Lesser General Public
20-
* License along with MDClasses.
21-
*/
22-
package com.github._1c_syntax.bsl.mdo;
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2025
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.bsl.mdo;
2323

2424
import com.github._1c_syntax.bsl.mdo.children.ObjectCommand;
2525
import com.github._1c_syntax.bsl.mdo.children.ObjectForm;
@@ -47,7 +47,7 @@
4747
@EqualsAndHashCode(of = {"name", "uuid"})
4848
public class BusinessProcess implements ReferenceObject, AccessRightsOwner {
4949

50-
private static final List<RoleRight> POSSIBLE_RIGHTS = computePossibleRighs();
50+
private static final List<RoleRight> POSSIBLE_RIGHTS = computePossibleRights();
5151

5252
/*
5353
* ReferenceObject
@@ -161,7 +161,7 @@ private List<Module> computeAllModules() {
161161
return LazyLoader.computeAllModules(this);
162162
}
163163

164-
private static List<RoleRight> computePossibleRighs() {
164+
private static List<RoleRight> computePossibleRights() {
165165
return List.of(
166166
RoleRight.INSERT,
167167
RoleRight.READ,

0 commit comments

Comments
 (0)