Skip to content
Closed
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
108 changes: 108 additions & 0 deletions docs/ru/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [Базовые операции](#базовые-операции)
- [Работа с конфигурацией](#работа-с-конфигурацией)
- [Работа с метаданными](#работа-с-метаданными)
- [Работа с типами реквизитов](#работа-с-типами-реквизитов)
- [Работа с формами](#работа-с-формами)
- [Работа с модулями](#работа-с-модулями)
- [Поиск и фильтрация объектов](#поиск-и-фильтрация-объектов)
Expand Down Expand Up @@ -44,6 +45,11 @@ import com.github._1c_syntax.bsl.mdo.ModuleType;
import com.github._1c_syntax.bsl.mdo.Right;
import com.github._1c_syntax.bsl.mdo.Role;
import com.github._1c_syntax.bsl.mdo.Subsystem;
import com.github._1c_syntax.bsl.mdo.support.AttributeType;
import com.github._1c_syntax.bsl.mdo.support.NumberQualifier;
import com.github._1c_syntax.bsl.mdo.support.StringQualifier;
import com.github._1c_syntax.bsl.mdo.support.TypeCategory;
import com.github._1c_syntax.bsl.mdo.support.TypeDescription;
// ... и другие объекты метаданных

// Путь к каталогу конфигурации
Expand Down Expand Up @@ -200,6 +206,108 @@ configuration.getInformationRegisters().forEach(register -> {
});
```

## Работа с типами реквизитов

Библиотека предоставляет полную информацию о типах данных реквизитов метаданных.

### Получение базовой информации о типе

```java
// Работа с реквизитами справочника
Catalog catalog = (Catalog) configuration.findChild("Catalog.МойСправочник").orElse(null);

if (catalog != null) {
catalog.getAllAttributes().forEach(attribute -> {
AttributeType type = attribute.getType();

System.out.println("Реквизит: " + attribute.getName());
System.out.println(" Тип: " + type.getDisplayName());
System.out.println(" Составной: " + type.isComposite());
});
}
```

### Работа с примитивными типами

```java
// Пример работы со строковым типом
AttributeType type = attribute.getType();
List<TypeDescription> descriptions = type.getTypeDescriptions();

for (TypeDescription desc : descriptions) {
if (desc.isPrimitive() && "String".equals(desc.getTypeName())) {
System.out.println("Примитивный тип: " + desc.getTypeName());

// Получение квалификаторов строки
if (desc.getQualifier().isPresent() &&
desc.getQualifier().get() instanceof StringQualifier) {
StringQualifier sq = (StringQualifier) desc.getQualifier().get();
System.out.println(" Длина: " + sq.getLength());
System.out.println(" Допустимая длина: " + sq.getAllowedLength());
}
}
}
```

### Работа с ссылочными типами

```java
// Определение ссылочных типов
for (TypeDescription desc : type.getTypeDescriptions()) {
if (desc.isReference()) {
System.out.println("Ссылочный тип: " + desc.getTypeName());

// Анализ типа ссылки
if (desc.getTypeName().startsWith("CatalogRef.")) {
String catalogName = desc.getTypeName().substring("CatalogRef.".length());
System.out.println(" Ссылка на справочник: " + catalogName);
} else if (desc.getTypeName().startsWith("DocumentRef.")) {
String documentName = desc.getTypeName().substring("DocumentRef.".length());
System.out.println(" Ссылка на документ: " + documentName);
}
}
}
```

### Работа с составными типами

```java
// Обработка составных типов (несколько типов в одном реквизите)
AttributeType type = attribute.getType();

if (type.isComposite()) {
System.out.println("Составной тип содержит:");

for (TypeDescription desc : type.getTypeDescriptions()) {
System.out.println(" - " + desc.getTypeName() +
" (категория: " + desc.getCategory() + ")");
}
}
```

### Анализ типов по категориям

```java
import com.github._1c_syntax.bsl.mdo.support.TypeCategory;

// Группировка реквизитов по категориям типов
Map<TypeCategory, List<Attribute>> attributesByCategory =
catalog.getAllAttributes().stream()
.collect(Collectors.groupingBy(attr -> {
// Берем категорию первого типа (для простых типов)
return attr.getType().getTypeDescriptions().isEmpty()
? TypeCategory.PRIMITIVE
: attr.getType().getTypeDescriptions().get(0).getCategory();
}));

attributesByCategory.forEach((category, attributes) -> {
System.out.println("Категория " + category + ":");
attributes.forEach(attr ->
System.out.println(" " + attr.getName() + ": " +
attr.getType().getDisplayName()));
});
```

## Работа с формами

### Получение и анализ форм
Expand Down
10 changes: 10 additions & 0 deletions docs/ru/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
На данный момент поддерживается загрузка всех видов метаданных, существующих в версиях платформы 1С до 8.3.24. В заивисимости от типа объекта и потребностей, объем читаемой информации может различаться (реализация чтения дополнительной информации выполняется от задач).
Актуальное содержимое того или иного вида объекта метаданных можно всегда находится в классе его реализации в пакете [mdo](com.github._1c_syntax.bsl.mdo).

### Типы данных реквизитов

Библиотека поддерживает получение информации о типах данных реквизитов метаданных. Для любого реквизита можно получить:

- тип данных (примитивный, ссылочный, определяемый, составной)
- квалификаторы типа (длина строки, точность числа и т.д.)
- полную информацию о составных типах

Типы поддерживаются для всех объектов, содержащих реквизиты: справочники, документы, регистры, планы счетов и видов характеристик, задачи и др.

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

- в корне расположены классы видов объектов метаданных (Справочники, Документы, Перечисления и т.д.), базовые интерфейсы
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/github/_1c_syntax/bsl/mdo/Attribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package com.github._1c_syntax.bsl.mdo;

import com.github._1c_syntax.bsl.mdo.support.AttributeKind;
import com.github._1c_syntax.bsl.mdo.support.AttributeType;
import com.github._1c_syntax.bsl.mdo.support.IndexingType;

/**
Expand All @@ -43,4 +44,9 @@ public interface Attribute extends MDChild {
* Вариант индексирования реквизита
*/
IndexingType getIndexing();

/**
* Тип данных реквизита
*/
AttributeType getType();
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.github._1c_syntax.bsl.mdo.AccessRightsOwner;
import com.github._1c_syntax.bsl.mdo.Attribute;
import com.github._1c_syntax.bsl.mdo.support.AttributeKind;
import com.github._1c_syntax.bsl.mdo.support.AttributeType;
import com.github._1c_syntax.bsl.mdo.support.AttributeTypeImpl;
import com.github._1c_syntax.bsl.mdo.support.IndexingType;
import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString;
import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging;
Expand Down Expand Up @@ -69,6 +71,12 @@ public class AccountingFlag implements Attribute, AccessRightsOwner {
AttributeKind kind = AttributeKind.CUSTOM;
@Default
IndexingType indexing = IndexingType.DONT_INDEX;

/**
* Тип данных реквизита
*/
@Default
AttributeType type = AttributeTypeImpl.EMPTY;

/**
* Возвращает перечень возможных прав доступа
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.github._1c_syntax.bsl.mdo.AccessRightsOwner;
import com.github._1c_syntax.bsl.mdo.Attribute;
import com.github._1c_syntax.bsl.mdo.support.AttributeKind;
import com.github._1c_syntax.bsl.mdo.support.AttributeType;
import com.github._1c_syntax.bsl.mdo.support.AttributeTypeImpl;
import com.github._1c_syntax.bsl.mdo.support.IndexingType;
import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString;
import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging;
Expand Down Expand Up @@ -90,6 +92,12 @@ public class Dimension implements Attribute, AccessRightsOwner {
*/
boolean useInTotals = true;

/**
* Тип данных реквизита
*/
@Default
AttributeType type = AttributeTypeImpl.EMPTY;

/**
* Возвращает перечень возможных прав доступа
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import com.github._1c_syntax.bsl.mdo.Attribute;
import com.github._1c_syntax.bsl.mdo.support.AttributeKind;
import com.github._1c_syntax.bsl.mdo.support.AttributeType;
import com.github._1c_syntax.bsl.mdo.support.AttributeTypeImpl;
import com.github._1c_syntax.bsl.mdo.support.IndexingType;
import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString;
import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging;
Expand Down Expand Up @@ -65,4 +67,10 @@ public class DocumentJournalColumn implements Attribute {
AttributeKind kind = AttributeKind.CUSTOM;
@Default
IndexingType indexing = IndexingType.DONT_INDEX;

/**
* Тип данных реквизита
*/
@Default
AttributeType type = AttributeTypeImpl.EMPTY;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.github._1c_syntax.bsl.mdo.AccessRightsOwner;
import com.github._1c_syntax.bsl.mdo.Attribute;
import com.github._1c_syntax.bsl.mdo.support.AttributeKind;
import com.github._1c_syntax.bsl.mdo.support.AttributeType;
import com.github._1c_syntax.bsl.mdo.support.AttributeTypeImpl;
import com.github._1c_syntax.bsl.mdo.support.IndexingType;
import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString;
import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging;
Expand Down Expand Up @@ -69,6 +71,12 @@ public class ExtDimensionAccountingFlag implements Attribute, AccessRightsOwner
AttributeKind kind = AttributeKind.CUSTOM;
@Default
IndexingType indexing = IndexingType.DONT_INDEX;

/**
* Тип данных реквизита
*/
@Default
AttributeType type = AttributeTypeImpl.EMPTY;

/**
* Возвращает перечень возможных прав доступа
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.github._1c_syntax.bsl.mdo.AccessRightsOwner;
import com.github._1c_syntax.bsl.mdo.Attribute;
import com.github._1c_syntax.bsl.mdo.support.AttributeKind;
import com.github._1c_syntax.bsl.mdo.support.AttributeType;
import com.github._1c_syntax.bsl.mdo.support.AttributeTypeImpl;
import com.github._1c_syntax.bsl.mdo.support.IndexingType;
import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString;
import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging;
Expand Down Expand Up @@ -72,6 +74,12 @@ public class ExternalDataSourceTableField implements Attribute, AccessRightsOwne
@Default
IndexingType indexing = IndexingType.DONT_INDEX;

/**
* Тип данных реквизита
*/
@Default
AttributeType type = AttributeTypeImpl.EMPTY;

/**
* Возвращает перечень возможных прав доступа
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.github._1c_syntax.bsl.mdo.AccessRightsOwner;
import com.github._1c_syntax.bsl.mdo.Attribute;
import com.github._1c_syntax.bsl.mdo.support.AttributeKind;
import com.github._1c_syntax.bsl.mdo.support.AttributeType;
import com.github._1c_syntax.bsl.mdo.support.AttributeTypeImpl;
import com.github._1c_syntax.bsl.mdo.support.IndexingType;
import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString;
import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging;
Expand Down Expand Up @@ -114,6 +116,12 @@ public class ObjectAttribute implements Attribute, AccessRightsOwner {
*/
boolean fillFromFillingValue;

/**
* Тип данных реквизита
*/
@Default
AttributeType type = AttributeTypeImpl.EMPTY;

/**
* Возвращает перечень возможных прав доступа
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.github._1c_syntax.bsl.mdo.AccessRightsOwner;
import com.github._1c_syntax.bsl.mdo.Attribute;
import com.github._1c_syntax.bsl.mdo.support.AttributeKind;
import com.github._1c_syntax.bsl.mdo.support.AttributeType;
import com.github._1c_syntax.bsl.mdo.support.AttributeTypeImpl;
import com.github._1c_syntax.bsl.mdo.support.IndexingType;
import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString;
import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging;
Expand Down Expand Up @@ -74,6 +76,12 @@ public class Resource implements Attribute, AccessRightsOwner {
* Свое
*/

/**
* Тип данных реквизита
*/
@Default
AttributeType type = AttributeTypeImpl.EMPTY;

/**
* Возвращает перечень возможных прав доступа
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.github._1c_syntax.bsl.mdo.AccessRightsOwner;
import com.github._1c_syntax.bsl.mdo.Attribute;
import com.github._1c_syntax.bsl.mdo.support.AttributeKind;
import com.github._1c_syntax.bsl.mdo.support.AttributeType;
import com.github._1c_syntax.bsl.mdo.support.AttributeTypeImpl;
import com.github._1c_syntax.bsl.mdo.support.IndexingType;
import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString;
import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging;
Expand Down Expand Up @@ -69,6 +71,12 @@ public class TaskAddressingAttribute implements Attribute, AccessRightsOwner {
AttributeKind kind = AttributeKind.CUSTOM;
@Default
IndexingType indexing = IndexingType.DONT_INDEX;

/**
* Тип данных реквизита
*/
@Default
AttributeType type = AttributeTypeImpl.EMPTY;

/*
* Свое
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* This file is a part of MDClasses.
*
* Copyright (c) 2019 - 2025
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> 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.support;

import java.util.List;

/**
* Базовый интерфейс для типов реквизитов метаданных
*/
public interface AttributeType {

/**
* Возвращает список примитивных типов, составляющих данный тип
* Для примитивных типов - один элемент
* Для составных типов - несколько элементов
*/
List<TypeDescription> getTypeDescriptions();

/**
* Возвращает true, если тип является составным (содержит несколько типов)
*/
boolean isComposite();

/**
* Возвращает строковое представление типа
*/
String getDisplayName();
}
Loading
Loading