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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build/
bin/
.gradle/

/.idea/sonarlint/
Expand All @@ -20,3 +21,5 @@ Gradle_*.xml
**/ConfigDumpInfo.xml
**/.metadata/
benchmark-results/**

.vscode/
19 changes: 19 additions & 0 deletions src/main/java/com/github/_1c_syntax/bsl/mdo/Catalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.github._1c_syntax.bsl.mdo.children.ObjectCommand;
import com.github._1c_syntax.bsl.mdo.children.ObjectForm;
import com.github._1c_syntax.bsl.mdo.children.ObjectTemplate;
import com.github._1c_syntax.bsl.mdo.support.CodeSeries;
import com.github._1c_syntax.bsl.mdo.support.ObjectBelonging;
import com.github._1c_syntax.bsl.mdo.support.RoleRight;
import com.github._1c_syntax.bsl.mdo.utils.LazyLoader;
Expand Down Expand Up @@ -114,6 +115,24 @@ public class Catalog implements ReferenceObject, AccessRightsOwner {
@Singular("addOwners")
List<MdoReference> owners;

/**
* Проверять уникальность кода справочника.
* Определяет, нужно ли проверять уникальность кода справочника.
* Если значение равно false, то код справочника должен быть уникальным в пределах области,
* определяемой свойством {@link #codeSeries}.
*/
@Default
boolean checkUnique = false;

/**
* Серия кодов справочника.
* Определяет область действия уникальности кода справочника.
* Значение по умолчанию: {@link CodeSeries#WHOLE_CATALOG}.
* Для формата EDT: если поле отсутствует, автоматически устанавливается значение WHOLE_CATALOG.
*/
@Default
CodeSeries codeSeries = CodeSeries.WHOLE_CATALOG;

/**
* Возвращает перечень возможных прав доступа
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* 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.Locale;
import java.util.Map;

import com.github._1c_syntax.bsl.types.EnumWithName;
import com.github._1c_syntax.bsl.types.MultiName;

import lombok.Getter;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
* Серия кодов справочника.
* Определяет область действия уникальности кода справочника.
*/
@ToString(of = "fullName")
public enum CodeSeries implements EnumWithName {
/**
* Весь справочник - уникальность кода проверяется во всем справочнике
*/
WHOLE_CATALOG("WholeCatalog", "ВесьСправочник"),
/**
* В пределах подчинения - уникальность кода проверяется в пределах подчинения
*/
WITHIN_SUBORDINATION("WithinSubordination", "ВПределахПодчинения"),
/**
* В пределах подчинения владельцу - уникальность кода проверяется в пределах подчинения владельцу
*/
WITHIN_OWNER_SUBORDINATION("WithinOwnerSubordination", "ВПределахПодчиненияВладельцу");

private static final Map<String, CodeSeries> KEYS = EnumWithName.computeKeys(values());

/**
* Полное имя элемента перечисления (на русском и английском языках)
*/
@Getter
@Accessors(fluent = true)
private final MultiName fullName;

/**
* Конструктор элемента перечисления
*
* @param nameEn Английское имя элемента
* @param nameRu Русское имя элемента
*/
CodeSeries(String nameEn, String nameRu) {
this.fullName = MultiName.create(nameEn, nameRu);
}

/**
* Ищет элемент перечисления по именам (рус, анг).
* Поиск выполняется без учета регистра.
*
* @param string Имя искомого элемента
* @return Найденное значение, если не найден - то WHOLE_CATALOG
*/
public static CodeSeries valueByName(String string) {
return KEYS.getOrDefault(string.toLowerCase(Locale.ROOT), WHOLE_CATALOG);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.github._1c_syntax.bsl.mdo.storage.form.FormElementType;
import com.github._1c_syntax.bsl.mdo.support.ApplicationRunMode;
import com.github._1c_syntax.bsl.mdo.support.AutoRecordType;
import com.github._1c_syntax.bsl.mdo.support.CodeSeries;
import com.github._1c_syntax.bsl.mdo.support.ConfigurationExtensionPurpose;
import com.github._1c_syntax.bsl.mdo.support.DataLockControlMode;
import com.github._1c_syntax.bsl.mdo.support.DataSeparation;
Expand Down Expand Up @@ -273,6 +274,7 @@ protected void setupConverters() {
registerConverter(new EnumConverter<>(FormElementType.class));
registerConverter(new EnumConverter<>(InterfaceCompatibilityMode.class));
registerConverter(new EnumConverter<>(DateFractions.class));
registerConverter(new EnumConverter<>(CodeSeries.class));
}

private void init() {
Expand Down
36 changes: 25 additions & 11 deletions src/test/java/com/github/_1c_syntax/bsl/mdo/CatalogTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,30 @@ void testSSL(ArgumentsAccessor argumentsAccessor) {
assertThat(stdAttribute.getValueType().contains(PrimitiveValueType.STRING)).isTrue();
}

/**
* Проверяет, что для справочника "Заметки" поле checkUnique установлено в false.
* <p>
* В формате Designer: в XML файле явно указано {@code <CheckUnique>false</CheckUnique>}.
* В формате EDT: в XML файле поле отсутствует, используется значение по умолчанию false.
*
* @param argumentsAccessor параметры теста (формат, имя пакета, ссылка на MDO, постфикс фикстуры)
*/
@ParameterizedTest
@CsvSource({
"true, ssl_3_1, Catalogs.Заметки, _edt",
"false, ssl_3_1, Catalogs.Заметки"
})
void testCheckUniqueFalse(ArgumentsAccessor argumentsAccessor) {
var mdo = MDTestUtils.getMDWithSimpleTest(argumentsAccessor);
assertThat(mdo)
.isInstanceOf(Catalog.class);

var catalog = (Catalog) mdo;
assertThat(catalog.isCheckUnique())
.as("Поле checkUnique должно быть false для справочника Заметки")
.isFalse();
}

@ParameterizedTest
@CsvSource({
"true, ssl_3_1, Catalogs.ВерсииФайлов, _edt",
Expand All @@ -166,14 +190,4 @@ void testSSLFixture(ArgumentsAccessor argumentsAccessor) {
assertThat(mdo)
.isInstanceOf(Catalog.class);
}

// private void checkExtInfo(FormDataOLD formData) {
// var extInfo = (DynamicListExtInfo) formData.getAttributes().get(1).getExtInfo();
// assertThat(extInfo)
// .isNotNull()
// .isInstanceOf(DynamicListExtInfo.class);
//
// assertThat(extInfo.isCustomQuery()).isTrue();
// assertThat(extInfo.getQuery().getTextQuery()).isNotEmpty();
// }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,8 @@
"name": "Справочник1",
"objectBelonging": "OWN",
"owners": [],
"checkUnique": true,
"codeSeries": "WHOLE_CATALOG",
"possibleRights": [
{
"default": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,8 @@
"name": "Справочник1",
"objectBelonging": "OWN",
"owners": [],
"checkUnique": true,
"codeSeries": "WHOLE_CATALOG",
"possibleRights": [
{
"default": {
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/fixtures/mdclasses/Configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,8 @@
"explanation": {
"@reference": "/com.github._1c_syntax.bsl.mdclasses.Configuration/XDTOPackages/com.github._1c_syntax.bsl.mdo.XDTOPackage/synonym"
},
"checkUnique": true,
"codeSeries": "WHOLE_CATALOG",
"owners": []
}
],
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/fixtures/mdclasses/Configuration_edt.json
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,8 @@
"explanation": {
"@reference": "/com.github._1c_syntax.bsl.mdclasses.Configuration/XDTOPackages/com.github._1c_syntax.bsl.mdo.XDTOPackage/synonym"
},
"checkUnique": true,
"codeSeries": "WHOLE_CATALOG",
"owners": []
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,8 @@
"explanation": {
"@reference": "/com.github._1c_syntax.bsl.mdclasses.Configuration/XDTOPackages/com.github._1c_syntax.bsl.mdo.XDTOPackage/synonym"
},
"checkUnique": true,
"codeSeries": "WHOLE_CATALOG",
"owners": []
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2887,6 +2887,8 @@
"mdoRefRu": "Справочник.Файлы"
}
],
"checkUnique": true,
"codeSeries": "WITHIN_OWNER_SUBORDINATION",
"possibleRights": [
{
"default": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2887,6 +2887,8 @@
"mdoRefRu": "Справочник.Файлы"
}
],
"checkUnique": true,
"codeSeries": "WITHIN_OWNER_SUBORDINATION",
"possibleRights": [
{
"default": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2326,6 +2326,8 @@
"name": "Заметки",
"objectBelonging": "OWN",
"owners": [],
"checkUnique": false,
"codeSeries": "WHOLE_CATALOG",
"possibleRights": [
{
"default": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2298,6 +2298,8 @@
"name": "Заметки",
"objectBelonging": "OWN",
"owners": [],
"checkUnique": false,
"codeSeries": "WHOLE_CATALOG",
"possibleRights": [
{
"default": {
Expand Down
Loading