Skip to content

Commit d77a503

Browse files
authored
Оптимизации (#467)
* Оптимизация хранения данных элементов форм * Оптимизация писка дочерних объектов конфигурации
1 parent d2dd7df commit d77a503

File tree

152 files changed

+5896
-4802
lines changed

Some content is hidden

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

152 files changed

+5896
-4802
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ dependencies {
5656
// прочее
5757
implementation("commons-io", "commons-io", "2.8.0")
5858
implementation("io.github.1c-syntax", "utils", "0.6.1")
59-
implementation("io.github.1c-syntax", "bsl-common-library", "0.6.0")
59+
implementation("io.github.1c-syntax", "bsl-common-library", "0.7.0")
6060
implementation("io.github.1c-syntax", "supportconf", "0.14.0") {
6161
exclude("io.github.1c-syntax", "bsl-common-library")
6262
}

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222
package com.github._1c_syntax.bsl.mdclasses;
2323

24+
import com.github._1c_syntax.bsl.mdo.CommonModule;
2425
import com.github._1c_syntax.bsl.mdo.MD;
2526
import com.github._1c_syntax.bsl.mdo.Module;
2627
import com.github._1c_syntax.bsl.mdo.ModuleOwner;
@@ -90,6 +91,16 @@ public interface CF extends MDClass, ConfigurationTree, CFAccess {
9091
*/
9192
Map<URI, Module> getModulesByURI();
9293

94+
/**
95+
* Возвращает соответствие имени общего модуля к нему самому
96+
*/
97+
Map<String, CommonModule> getCommonModulesByName();
98+
99+
/**
100+
* Возвращает соответствие ссылки на дочерний объект к нему самому
101+
*/
102+
Map<MdoReference, MD> getChildrenByMdoRef();
103+
93104
/**
94105
* Возвращает соответствие типов модулей их путям к файлам для дочернего объекта
95106
*/
@@ -158,4 +169,14 @@ default Optional<Module> getModuleByUri(URI uri) {
158169
default Optional<MD> findChild(URI uri) {
159170
return Optional.ofNullable(getModulesByObject().get(uri));
160171
}
172+
173+
@Override
174+
default Optional<MD> findChild(MdoReference ref) {
175+
return Optional.ofNullable(getChildrenByMdoRef().get(ref));
176+
}
177+
178+
@Override
179+
default Optional<CommonModule> findCommonModule(String name) {
180+
return Optional.ofNullable(getCommonModulesByName().get(name));
181+
}
161182
}

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ public class Configuration implements CF {
257257
Lazy<Map<URI, ModuleType>> modulesByType = new Lazy<>(this::computeModulesByType);
258258
Lazy<Map<URI, Module>> modulesByURI = new Lazy<>(this::computeModulesByURI);
259259
Lazy<Map<URI, MD>> modulesByObject = new Lazy<>(this::computeModulesByObject);
260+
Lazy<Map<String, CommonModule>> commonModulesByName = new Lazy<>(this::computeCommonModulesByName);
261+
Lazy<Map<MdoReference, MD>> childrenByMdoRef = new Lazy<>(this::computeChildrenByMdoRef);
260262

261263
/*
262264
* Свое
@@ -345,6 +347,16 @@ public Map<URI, Module> getModulesByURI() {
345347
return modulesByURI.getOrCompute();
346348
}
347349

350+
@Override
351+
public Map<String, CommonModule> getCommonModulesByName() {
352+
return commonModulesByName.getOrCompute();
353+
}
354+
355+
@Override
356+
public Map<MdoReference, MD> getChildrenByMdoRef() {
357+
return childrenByMdoRef.getOrCompute();
358+
}
359+
348360
/**
349361
* Возвращает перечень возможных прав доступа
350362
*/
@@ -372,6 +384,14 @@ private Map<URI, Module> computeModulesByURI() {
372384
return LazyLoader.computeModulesByURI(this);
373385
}
374386

387+
private Map<String, CommonModule> computeCommonModulesByName() {
388+
return LazyLoader.computeCommonModulesByName(this);
389+
}
390+
391+
private Map<MdoReference, MD> computeChildrenByMdoRef() {
392+
return LazyLoader.computeChildrenByMdoRef(this);
393+
}
394+
375395
private static Configuration createEmptyConfiguration() {
376396
var emptyString = "empty";
377397

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ public class ConfigurationExtension implements CF {
248248
Lazy<Map<URI, ModuleType>> modulesByType = new Lazy<>(this::computeModulesByType);
249249
Lazy<Map<URI, MD>> modulesByObject = new Lazy<>(this::computeModulesByObject);
250250
Lazy<Map<URI, Module>> modulesByURI = new Lazy<>(this::computeModulesByURI);
251+
Lazy<Map<String, CommonModule>> commonModulesByName = new Lazy<>(this::computeCommonModulesByName);
252+
Lazy<Map<MdoReference, MD>> childrenByMdoRef = new Lazy<>(this::computeChildrenByMdoRef);
251253

252254
/*
253255
* Свое
@@ -290,6 +292,16 @@ public Map<URI, Module> getModulesByURI() {
290292
return modulesByURI.getOrCompute();
291293
}
292294

295+
@Override
296+
public Map<String, CommonModule> getCommonModulesByName() {
297+
return commonModulesByName.getOrCompute();
298+
}
299+
300+
@Override
301+
public Map<MdoReference, MD> getChildrenByMdoRef() {
302+
return childrenByMdoRef.getOrCompute();
303+
}
304+
293305
/**
294306
* Возвращает перечень возможных прав доступа
295307
*/
@@ -317,4 +329,12 @@ private Map<URI, Module> computeModulesByURI() {
317329
return LazyLoader.computeModulesByURI(this);
318330
}
319331

332+
private Map<String, CommonModule> computeCommonModulesByName() {
333+
return LazyLoader.computeCommonModulesByName(this);
334+
}
335+
336+
private Map<MdoReference, MD> computeChildrenByMdoRef() {
337+
return LazyLoader.computeChildrenByMdoRef(this);
338+
}
339+
320340
}

src/main/java/com/github/_1c_syntax/bsl/mdclasses/helpers/Rights.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private static boolean rightAccess(CF cf, MdoReference mdoReference, RoleRight r
144144
.filter(roleData -> !roleData.equals(RoleData.EMPTY))
145145
.map(RoleData::getObjectRights)
146146
.flatMap(Collection::stream)
147-
.filter(objectRight -> objectRight.getName().equals(mdoReference.getMdoRef()))
147+
.filter(objectRight -> objectRight.getName().equals(mdoReference))
148148
.map(RoleData.ObjectRight::getRights)
149149
.flatMap(Collection::stream)
150150
.anyMatch(right -> roleRight == right.getName() && right.isValue());
@@ -155,11 +155,10 @@ private static List<Role> rolesAccess(CF cf, MdoReference mdoReference, RoleRigh
155155
return Collections.emptyList();
156156
}
157157

158-
var mdoRef = mdoReference.getMdoRef();
159158
List<Role> roles = new ArrayList<>();
160159
cf.getRoles().forEach((Role role) -> {
161160
var hasAcccess = role.getData().getObjectRights().stream()
162-
.filter(objectRight -> objectRight.getName().equals(mdoRef))
161+
.filter(objectRight -> objectRight.getName().equals(mdoReference))
163162
.map(RoleData.ObjectRight::getRights)
164163
.flatMap(Collection::stream)
165164
.anyMatch(right -> roleRight == right.getName() && right.isValue());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public class CommonForm implements MDObject, Form, AccessRightsOwner {
7676
FormType formType = FormType.MANAGED;
7777

7878
@Default
79-
FormData data = EmptyFormData.getEmpty();
79+
FormData data = EmptyFormData.EMPTY;
8080

8181
/*
8282
* Свое

src/main/java/com/github/_1c_syntax/bsl/mdo/children/ObjectForm.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public class ObjectForm implements Form, MDChild {
7373
FormType formType = FormType.MANAGED;
7474

7575
@Default
76-
FormData data = EmptyFormData.getEmpty();
76+
FormData data = EmptyFormData.EMPTY;
7777

7878
/*
7979
* Для MDChild

src/main/java/com/github/_1c_syntax/bsl/mdo/storage/EmptyFormData.java

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,49 @@
2121
*/
2222
package com.github._1c_syntax.bsl.mdo.storage;
2323

24+
import com.github._1c_syntax.bsl.mdo.storage.form.FormAttribute;
25+
import com.github._1c_syntax.bsl.mdo.storage.form.FormHandler;
26+
import com.github._1c_syntax.bsl.mdo.storage.form.FormItem;
27+
import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString;
28+
29+
import java.util.Collections;
30+
import java.util.List;
31+
2432
/**
2533
* Реализация содержимого пустой формы
2634
*/
27-
public class EmptyFormData implements FormData {
28-
29-
private static final EmptyFormData EMPTY = new EmptyFormData();
35+
public final class EmptyFormData implements FormData {
3036

3137
/**
3238
* Возвращает ссылку на пустое содержимое формы
33-
*
34-
* @return Пустое содержимое формы
3539
*/
36-
public static EmptyFormData getEmpty() {
37-
return EMPTY;
40+
public static final EmptyFormData EMPTY = new EmptyFormData();
41+
42+
private EmptyFormData() {
43+
}
44+
45+
@Override
46+
public MultiLanguageString getTitle() {
47+
return MultiLanguageString.EMPTY;
48+
}
49+
50+
@Override
51+
public List<FormHandler> getHandlers() {
52+
return Collections.emptyList();
53+
}
54+
55+
@Override
56+
public List<FormItem> getItems() {
57+
return Collections.emptyList();
58+
}
59+
60+
@Override
61+
public List<FormItem> getPlainItems() {
62+
return Collections.emptyList();
3863
}
3964

4065
@Override
41-
public boolean isEmpty() {
42-
return true;
66+
public List<FormAttribute> getAttributes() {
67+
return Collections.emptyList();
4368
}
4469
}

src/main/java/com/github/_1c_syntax/bsl/mdo/storage/EmptyTemplateData.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
*/
2222
package com.github._1c_syntax.bsl.mdo.storage;
2323

24-
import lombok.Value;
25-
2624
/**
2725
* Реализация пустого содержимого макета
2826
*/
29-
@Value
30-
public class EmptyTemplateData implements TemplateData {
27+
public final class EmptyTemplateData implements TemplateData {
3128
private static final EmptyTemplateData EMPTY = new EmptyTemplateData();
3229

30+
private EmptyTemplateData() {
31+
}
32+
3333
/**
3434
* Возвращает ссылку на пустое содержимое макета
3535
*
Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
1-
/*
2-
* This file is a part of MDClasses.
3-
*
4-
* Copyright (c) 2019 - 2024
5-
* Tymko Oleg <olegtymko@yandex.ru>, Maximov Valery <maximovvalery@gmail.com> 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.storage;
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2024
5+
* Tymko Oleg <olegtymko@yandex.ru>, Maximov Valery <maximovvalery@gmail.com> 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.storage;
2323

2424
import com.github._1c_syntax.bsl.mdo.storage.form.FormAttribute;
2525
import com.github._1c_syntax.bsl.mdo.storage.form.FormHandler;
2626
import com.github._1c_syntax.bsl.mdo.storage.form.FormItem;
2727
import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString;
2828

29-
import java.util.ArrayList;
30-
import java.util.Collections;
3129
import java.util.List;
3230

3331
/**
@@ -37,42 +35,32 @@ public interface FormData {
3735
/**
3836
* Признак пустого содержимого
3937
*/
40-
boolean isEmpty();
38+
default boolean isEmpty() {
39+
return this == EmptyFormData.EMPTY;
40+
}
4141

4242
/**
4343
* Заголовок формы
4444
*/
45-
default MultiLanguageString getTitle() {
46-
return MultiLanguageString.EMPTY;
47-
}
45+
MultiLanguageString getTitle();
4846

4947
/**
5048
* Обработчики событий формы
5149
*/
52-
default List<FormHandler> getHandlers() {
53-
return Collections.emptyList();
54-
}
50+
List<FormHandler> getHandlers();
5551

5652
/**
5753
* Список визуальных элементов формы первого уровня (т.е. с родителем - форма)
5854
*/
59-
default List<FormItem> getItems() {
60-
return Collections.emptyList();
61-
}
55+
List<FormItem> getItems();
6256

6357
/**
6458
* Список всех визуальных элементов формы
6559
*/
66-
default List<FormItem> getPlainItems() {
67-
List<FormItem> allItems = new ArrayList<>(getItems());
68-
getItems().forEach(formItem -> allItems.addAll(formItem.getPlainItems()));
69-
return allItems;
70-
}
60+
List<FormItem> getPlainItems();
7161

7262
/**
7363
* Список реквизитов формы
7464
*/
75-
default List<FormAttribute> getAttributes() {
76-
return Collections.emptyList();
77-
}
65+
List<FormAttribute> getAttributes();
7866
}

0 commit comments

Comments
 (0)