Skip to content

Commit

Permalink
Merge branch 'release/v0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
bia-tech committed Feb 13, 2023
2 parents b6d9046 + 6de5a21 commit e86a8c3
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 44 deletions.
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ plugins {
`java-library`
`maven-publish`
jacoco
id("org.sonarqube") version "3.4.0.2513"
id("org.sonarqube") version "3.5.0.2730"
id("org.cadixdev.licenser") version "0.6.1"
id("com.github.gradle-git-version-calculator") version "1.1.0"
id("io.freefair.lombok") version "6.5.0.2"
id("io.freefair.javadoc-links") version "6.5.0.2"
id("io.freefair.javadoc-utf-8") version "6.5.0.2"
id("io.freefair.lombok") version "6.6.1"
id("io.freefair.javadoc-links") version "6.6.1"
id("io.freefair.javadoc-utf-8") version "6.6.1"
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is a part of BSL Common library.
*
* Copyright (c) 2021 - 2022
* Copyright (c) 2021 - 2023
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is a part of BSL Common library.
*
* Copyright (c) 2021 - 2022
* Copyright (c) 2021 - 2023
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is a part of BSL Common library.
*
* Copyright (c) 2021 - 2022
* Copyright (c) 2021 - 2023
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
Expand Down
54 changes: 30 additions & 24 deletions src/main/java/com/github/_1c_syntax/bsl/types/MDOType.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/*
* This file is a part of BSL Common library.
*
* Copyright (c) 2021 - 2022
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* BSL Common library 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.
*
* BSL Common library 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 BSL Common library.
*/
package com.github._1c_syntax.bsl.types;
/*
* This file is a part of BSL Common library.
*
* Copyright (c) 2021 - 2023
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* BSL Common library 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.
*
* BSL Common library 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 BSL Common library.
*/
package com.github._1c_syntax.bsl.types;

import lombok.Getter;
import org.apache.commons.collections4.map.CaseInsensitiveMap;
Expand Down Expand Up @@ -91,7 +91,9 @@ public enum MDOType {
COMMAND("Command", "Commands", "Команда", "Команды"),
TEMPLATE("Template", "Templates", "Макет", "Макеты"),
ATTRIBUTE("Attribute", "Attributes", "Реквизит", "Реквизиты"),
STANDARD_ATTRIBUTE("StandardAttribute", "StandardAttributes", "СтандартныйРеквизит", "СтандартныеРеквизиты"),
TABULAR_SECTION("TabularSection", "TabularSections", "ТабличнаяЧасть", "ТабличныеЧасти"),
STANDARD_TABULAR_SECTION("StandardTabularSection", "StandardTabularSections", "СтандартнаяТабличнаяЧасть", "СтандартныеТабличныеЧасти"),
RECALCULATION("Recalculation", "Recalculations", "Перерасчет", "Перерасчеты"),
WS_OPERATION("Operation", "Operations", "Операция", "Операции"),
WS_OPERATION_PARAMETER("Parameter", "Parameters", "Параметр", "Параметры"),
Expand All @@ -105,6 +107,9 @@ public enum MDOType {
COLUMN("Column", "Columns", "Колонка", "Колонки"),
ACCOUNTING_FLAG("AccountingFlag", "AccountingFlags", "ПризнакУчета", "ПризнакиУчета"),
EXT_DIMENSION_ACCOUNTING_FLAG("ExtDimensionAccountingFlag", "ExtDimensionAccountingFlags", "ПризнакУчетаСубконто", "ПризнакиУчетаСубконто"),

EXTERNAL_DATA_SOURCE_TABLE("Table", "Tables", "Таблица", "Таблицы"),
EXTERNAL_DATA_SOURCE_TABLE_FILED("Field", "Fields", "Поле", "Поля"),
UNKNOWN("", "", "", "");

private static final Map<String, MDOType> MAP_TYPES = computeMapTypes();
Expand Down Expand Up @@ -148,7 +153,7 @@ public enum MDOType {
*/
public static List<MDOType> valuesWithoutChildren() {
return Arrays.stream(values()).filter(mdoType ->
!CHILD_TYPES.contains(mdoType) && mdoType != UNKNOWN)
!CHILD_TYPES.contains(mdoType) && mdoType != UNKNOWN)
.collect(Collectors.toList());
}

Expand Down Expand Up @@ -178,6 +183,7 @@ private static Set<MDOType> computeChildTypes() {
return Set.of(FORM, COMMAND, TEMPLATE, ATTRIBUTE, TABULAR_SECTION, RECALCULATION, WS_OPERATION,
WS_OPERATION_PARAMETER, HTTP_SERVICE_URL_TEMPLATE, HTTP_SERVICE_METHOD, INTEGRATION_SERVICE_CHANNEL,
TASK_ADDRESSING_ATTRIBUTE, DIMENSION, RESOURCE, ENUM_VALUE, COLUMN,
ACCOUNTING_FLAG, EXT_DIMENSION_ACCOUNTING_FLAG);
ACCOUNTING_FLAG, EXT_DIMENSION_ACCOUNTING_FLAG, STANDARD_ATTRIBUTE, STANDARD_TABULAR_SECTION,
EXTERNAL_DATA_SOURCE_TABLE, EXTERNAL_DATA_SOURCE_TABLE_FILED);
}
}
24 changes: 19 additions & 5 deletions src/main/java/com/github/_1c_syntax/bsl/types/MdoReference.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is a part of BSL Common library.
*
* Copyright (c) 2021 - 2022
* Copyright (c) 2021 - 2023
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
Expand All @@ -27,6 +27,7 @@
import lombok.ToString;
import lombok.Value;

import javax.annotation.Nullable;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentSkipListMap;
Expand Down Expand Up @@ -76,6 +77,15 @@ private MdoReference(MDOType type, String mdoRef, String mdoRefRu) {
this.mdoRefRu = mdoRefRu;
}

/**
* Возвращает признак пустоты текущей ссылки
*
* @return Признак пустоты
*/
public boolean isEmpty() {
return this == EMPTY;
}

/**
* Создает ссылку, сохраняя ее в кэш.
* Ответственность за корректность сформированных представлений ссылки ложится на вызывающую сторону
Expand Down Expand Up @@ -111,13 +121,17 @@ public static MdoReference create(@NonNull MDOType mdoType, @NonNull String name
* @param name Имя дочернего элемента
* @return Ссылка на элемент
*/
public static MdoReference create(@NonNull MdoReference mdoReferenceOwner,
public static MdoReference create(@Nullable MdoReference mdoReferenceOwner,
@NonNull MDOType mdoType,
@NonNull String name) {
var mdoRef = stringInterner.intern(mdoReferenceOwner.getMdoRef() + "." + mdoType.getName() + "." + name);
var mdoRefRu = stringInterner.intern(mdoReferenceOwner.getMdoRefRu() + "." + mdoType.getNameRu() + "." + name);
if (mdoReferenceOwner == null || mdoReferenceOwner.isEmpty()) {
return create(mdoType, name);
} else {
var mdoRef = stringInterner.intern(mdoReferenceOwner.getMdoRef() + "." + mdoType.getName() + "." + name);
var mdoRefRu = stringInterner.intern(mdoReferenceOwner.getMdoRefRu() + "." + mdoType.getNameRu() + "." + name);

return getOrCompute(mdoType, mdoRef, mdoRefRu);
return getOrCompute(mdoType, mdoRef, mdoRefRu);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is a part of BSL Common library.
*
* Copyright (c) 2021 - 2022
* Copyright (c) 2021 - 2023
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
Expand Down Expand Up @@ -89,6 +89,7 @@ private static Map<MDOType, Set<ModuleType>> moduleTypesForMDOTypes() {
case ACCUMULATION_REGISTER:
case CALCULATION_REGISTER:
case INFORMATION_REGISTER:
case EXTERNAL_DATA_SOURCE_TABLE:
types.add(ManagerModule);
types.add(RecordSetModule);
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is a part of BSL Common library.
*
* Copyright (c) 2021 - 2022
* Copyright (c) 2021 - 2023
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is a part of BSL Common library.
*
* Copyright (c) 2021 - 2022
* Copyright (c) 2021 - 2023
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is a part of BSL Common library.
*
* Copyright (c) 2021 - 2022
* Copyright (c) 2021 - 2023
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is a part of BSL Common library.
*
* Copyright (c) 2021 - 2022
* Copyright (c) 2021 - 2023
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is a part of BSL Common library.
*
* Copyright (c) 2021 - 2022
* Copyright (c) 2021 - 2023
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
Expand All @@ -24,7 +24,7 @@
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertThrows;

class MdoReferenceTest {

Expand Down Expand Up @@ -124,4 +124,30 @@ void testCreateCascade() {
assertThat(mdoRefParent0.get().getMdoRef()).isEqualTo("Catalog.test12");
assertThat(mdoRefParent0.get().getType()).isEqualTo(MDOType.CATALOG);
}

@Test
void testEmpty() {
assertThat(MdoReference.EMPTY.isEmpty()).isTrue();

var mdoRef = MdoReference.create("catalogs.test");
assertThat(mdoRef).isNotNull();
assertThat(mdoRef.isEmpty()).isFalse();
}

@Test
void testCreateWithEmptyParent() {
var mdoRef = MdoReference.create(MDOType.CATALOG, "test10");
assertThat(mdoRef).isNotNull();
assertThat(mdoRef.isEmpty()).isFalse();

var mdoRef2 = MdoReference.create(MdoReference.EMPTY, MDOType.CATALOG, "test10");
assertThat(mdoRef2).isNotNull();
assertThat(mdoRef2.isEmpty()).isFalse();
assertThat(mdoRef2).isEqualTo(mdoRef);

var mdoRef3 = MdoReference.create(null, MDOType.CATALOG, "test10");
assertThat(mdoRef3).isNotNull();
assertThat(mdoRef3.isEmpty()).isFalse();
assertThat(mdoRef3).isEqualTo(mdoRef);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is a part of BSL Common library.
*
* Copyright (c) 2021 - 2022
* Copyright (c) 2021 - 2023
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
Expand Down

0 comments on commit e86a8c3

Please sign in to comment.