Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ gitVersioning.apply {
repositories {
mavenLocal()
mavenCentral()
maven("https://central.sonatype.com/repository/maven-snapshots")
}

dependencies {
Expand All @@ -57,9 +58,11 @@ dependencies {

// прочее
implementation("commons-io", "commons-io", "2.18.0")
implementation("io.github.1c-syntax", "bsl-common-library", "0.9.0.9-SNAPSHOT")
implementation("io.github.1c-syntax", "utils", "0.6.3")
implementation("io.github.1c-syntax", "bsl-common-library", "0.8.1")
implementation("io.github.1c-syntax", "supportconf", "0.14.3")
implementation("io.github.1c-syntax", "supportconf", "0.14.3") {
exclude("io.github.1c-syntax", "bsl-common-library")
}

// быстрый поиск классов
implementation("io.github.classgraph", "classgraph", "4.8.179")
Expand Down
134 changes: 134 additions & 0 deletions docs/ru/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [Работа с метаданными](#работа-с-метаданными)
- [Работа с формами](#работа-с-формами)
- [Работа с модулями](#работа-с-модулями)
- [Анализ описания типов данных](#анализ-типов-данных)
- [Поиск и фильтрация объектов](#поиск-и-фильтрация-объектов)
- [Практические сценарии](#практические-сценарии)

Expand Down Expand Up @@ -269,6 +270,139 @@ allModules.stream()
});
```

## Анализ типов данных

При чтении описания метаданных для объектов и их атрибутов вычисляются описания типов. Все сущности, имеющие описания типов данных, реализуют интерфейс `ValueTypeOwner`.

Ниже приведены примеры, как можно использовать данную информацию.

### Получение описания типа реквизита справочника

Часть описания реквизита справочника

```xml
<attributes uuid="dff5b5d8-762d-4490-a336-dcc8d93c17d5">
<name>Реквизит2</name>
<type>
<types>Number</types>
<numberQualifiers>
<precision>10</precision>
</numberQualifiers>
</type>
<minValue xsi:type="core:UndefinedValue"/>
<maxValue xsi:type="core:UndefinedValue"/>
<fillValue xsi:type="core:UndefinedValue"/>
<fullTextSearch>Use</fullTextSearch>
</attributes>
```

Код, которым можно посмотреть описание типа

```java
// найдем справочник из прочитанной конфигурации
var childMDO = configuration.findChild("Catalog.Справочник1");

// проверим, что это на самом деле справочник
if (childMDO.isPresent() && childMDO.get() instanceof Catalog catalog) {

// убедимся, что у справочника есть дочерние
assertThat(catalog.getChildren()).isNotEmpty();

// найдем нужный дочерний (реквизит)
var childAttribute = catalog.findChild(md -> "Реквизит2".equals(md.getName()));

// проверим, что он есть и нужного типа
if (childAttribute.isPresent() && childAttribute.get() instanceof ObjectAttribute objectAttribute) {

// проверим наименование
assertThat(objectAttribute.getName()).isEqualTo("Реквизит2");

// описание типа `getValueType`
assertThat(objectAttribute.getValueType()).isNotNull();
// убеимся в наличии примитивного типа СТРОКА в составе описания
assertThat(objectAttribute.getValueType().contains(PrimitiveValueType.NUMBER)).isTrue();
// убедимся, что тип не составно
assertThat(objectAttribute.getValueType().isComposite()).isFalse();
// убедимся, что квалификаторы прочитаны
assertThat(objectAttribute.getValueType().getQualifiers()).hasSize(1);

// убедимся, что прочитан квалификатор числа
var qualifier = objectAttribute.getValueType().getQualifiers().get(0);
assertThat(qualifier).isInstanceOf(NumberQualifiers.class);

// убаимся, что квалификатор числа содожержит верную информацию
var numberQualifiers = (NumberQualifiers) qualifier;
assertThat(numberQualifiers.getPrecision()).isEqualTo(10); // длина 10
assertThat(numberQualifiers.getScale()).isEqualTo(0); // точность 0
assertThat(numberQualifiers.isNonNegative()).isFalse(); // возможны любые знаки
}
}
}
```

### Определение состава определяемого типа

Часть описания определяемого типа

```xml
<name>ЗначениеДоступа</name>
<type>
<types>CatalogRef.ПапкиФайлов</types>
<types>CatalogRef.ВнешниеПользователи</types>
<types>CatalogRef.КлючиДоступа</types>
<types>CatalogRef.ИдентификаторыОбъектовРасширений</types>
<types>CatalogRef.ГруппыВнешнихПользователей</types>
<types>CatalogRef.ГруппыПользователей</types>
<types>EnumRef.ДополнительныеЗначенияДоступа</types>
<types>ChartOfCharacteristicTypesRef.ДополнительныеРеквизитыИСведения</types>
<types>CatalogRef.ДополнительныеОтчетыИОбработки</types>
<types>CatalogRef.Пользователи</types>
<types>CatalogRef.ГруппыИсполнителейЗадач</types>
<types>CatalogRef.УчетныеЗаписиЭлектроннойПочты</types>
<types>CatalogRef.ИдентификаторыОбъектовМетаданных</types>
</type>
```

Код, которым можно посмотреть описание типа

```java

// найдем определяемый тип прочитанной конфигурации
var childMDO = configuration.findChild("DefinedType.ЗначениеДоступа");
if (childMDO.isPresent() && childMDO.get() instanceof DefinedType definedType) {
assertThat(definedType.getName()).isEqualTo("ЗначениеДоступа");
// убедимся, что тип прочитан
assertThat(definedType.getValueType()).isNotNull();
// убедимся, что в составе нет ЧИСЛА
assertThat(definedType.getValueType().contains(PrimitiveValueType.NUMBER)).isFalse();
// убедимся, что описание соответствует составному типу
assertThat(definedType.getValueType().isComposite()).isTrue();
// квалификаторов нет
assertThat(definedType.getValueType().getQualifiers()).isEmpty();

// создадим типа по имени
var typeContains = MetadataValueType.fromString("EnumRef.ДополнительныеЗначенияДоступа");

assertThat(typeContains).isNotNull();
// полученый тип относится к перечислению
assertThat(typeContains.getKind()).isEqualTo(MDOType.ENUM);
// тип не составной
assertThat(typeContains.isComposite()).isFalse();
// есть имя на английском
assertThat(typeContains.getName()).isEqualTo("EnumRef.ДополнительныеЗначенияДоступа");
// и русском
assertThat(typeContains.getNameRu()).isEqualTo("ПеречислениеСсылка.ДополнительныеЗначенияДоступа");

// второй тип
var typeNotContains = MetadataValueType.fromString("CatalogRef.Контрагенты");
assertThat(typeNotContains).isNotNull();
// убедимся, что первый тип входит в состав описания
assertThat(definedType.getValueType().contains(typeContains)).isTrue();
// убедимся, что второй тип нпе входит в состав
assertThat(definedType.getValueType().contains(typeNotContains)).isFalse();
}
```

## Поиск и фильтрация объектов

### Поиск объекта по ссылке
Expand Down
2 changes: 1 addition & 1 deletion docs/ru/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

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

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

Немного о структуре пакета:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public class Configuration implements CF {
*/
public static final Configuration EMPTY = createEmptyConfiguration();

private static final List<RoleRight> POSSIBLE_RIGHTS = computePossibleRighs();
private static final List<RoleRight> POSSIBLE_RIGHTS = computePossibleRights();

/*
* CF
Expand Down Expand Up @@ -406,7 +406,7 @@ private static Configuration createEmptyConfiguration() {
.build();
}

private static List<RoleRight> computePossibleRighs() {
private static List<RoleRight> computePossibleRights() {
return List.of(
RoleRight.ADMINISTRATION,
RoleRight.DATA_ADMINISTRATION,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/*
* This file is a part of MDClasses.
*
* Copyright (c) 2019 - 2025
* Tymko Oleg <olegtymko@yandex.ru>, Maximov Valery <maximovvalery@gmail.com> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* MDClasses is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* MDClasses is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with MDClasses.
*/
package com.github._1c_syntax.bsl.mdo;
/*
* This file is a part of MDClasses.
*
* Copyright (c) 2019 - 2025
* Tymko Oleg <olegtymko@yandex.ru>, Maximov Valery <maximovvalery@gmail.com> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* MDClasses is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* MDClasses is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with MDClasses.
*/
package com.github._1c_syntax.bsl.mdo;

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

private static final List<RoleRight> POSSIBLE_RIGHTS = computePossibleRighs();
private static final List<RoleRight> POSSIBLE_RIGHTS = computePossibleRights();

/*
* Register
Expand Down Expand Up @@ -137,7 +137,7 @@ private List<Module> computeAllModules() {
return LazyLoader.computeAllModules(this);
}

private static List<RoleRight> computePossibleRighs() {
private static List<RoleRight> computePossibleRights() {
return List.of(
RoleRight.READ,
RoleRight.UPDATE,
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/github/_1c_syntax/bsl/mdo/Attribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
import com.github._1c_syntax.bsl.mdo.support.IndexingType;

/**
* Интерфейс объектов, выступающих в роли реквизитов, т.е. хранящие данные
* Интерфейс объектов, выступающих в роли реквизитов, т.е. хранящих данные
* это могут быть реквизиты, колонки, измерения, а также общие реквизиты и константы
*/
public interface Attribute extends MDChild {
public interface Attribute extends MDChild, ValueTypeOwner {
/**
* Режим пароля. Только для реквизитов с типом с типом `Строка`
*/
Expand Down
48 changes: 24 additions & 24 deletions src/main/java/com/github/_1c_syntax/bsl/mdo/BusinessProcess.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/*
* This file is a part of MDClasses.
*
* Copyright (c) 2019 - 2025
* Tymko Oleg <olegtymko@yandex.ru>, Maximov Valery <maximovvalery@gmail.com> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* MDClasses is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* MDClasses is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with MDClasses.
*/
package com.github._1c_syntax.bsl.mdo;
/*
* This file is a part of MDClasses.
*
* Copyright (c) 2019 - 2025
* Tymko Oleg <olegtymko@yandex.ru>, Maximov Valery <maximovvalery@gmail.com> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* MDClasses is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* MDClasses is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with MDClasses.
*/
package com.github._1c_syntax.bsl.mdo;

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

private static final List<RoleRight> POSSIBLE_RIGHTS = computePossibleRighs();
private static final List<RoleRight> POSSIBLE_RIGHTS = computePossibleRights();

/*
* ReferenceObject
Expand Down Expand Up @@ -161,7 +161,7 @@ private List<Module> computeAllModules() {
return LazyLoader.computeAllModules(this);
}

private static List<RoleRight> computePossibleRighs() {
private static List<RoleRight> computePossibleRights() {
return List.of(
RoleRight.INSERT,
RoleRight.READ,
Expand Down
Loading
Loading