Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/optimize #441

Merged
merged 3 commits into from
Jan 23, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ build/
/.idea/sonar*

/.idea/misc.xml
Gradle_*.xml
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ dependencies {
// прочее
implementation("commons-io", "commons-io", "2.8.0")
implementation("com.github.1c-syntax", "utils", "0.5.1")
implementation("io.github.1c-syntax", "bsl-common-library", "0.5.0")
implementation("io.github.1c-syntax", "supportconf", "0.12.1") {
implementation("io.github.1c-syntax", "bsl-common-library", "0.5.1")
implementation("io.github.1c-syntax", "supportconf", "0.13.1") {
exclude("io.github.1c-syntax", "bsl-common-library")
}

Expand Down
50 changes: 26 additions & 24 deletions src/main/java/com/github/_1c_syntax/bsl/mdo/storage/RoleData.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
/*
* This file is a part of MDClasses.
*
* Copyright (c) 2019 - 2024
* 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.storage;
/*
* This file is a part of MDClasses.
*
* Copyright (c) 2019 - 2024
* 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.storage;

import com.github._1c_syntax.bsl.mdo.support.RoleRight;
import com.github._1c_syntax.bsl.reader.MDOReader;
import com.github._1c_syntax.utils.GenericInterner;
import lombok.Builder;
import lombok.Builder.Default;
import lombok.EqualsAndHashCode;
Expand All @@ -46,6 +47,7 @@
public class RoleData {

public static final RoleData EMPTY = RoleData.builder().build();
public static final GenericInterner<Right> RIGHT_INTERNER = new GenericInterner<>();

/**
* Устанавливать права для новых объектов
Expand Down Expand Up @@ -97,8 +99,8 @@ public static class ObjectRight {
}

@Value
@ToString(of = {"name"})
@EqualsAndHashCode(of = {"name"})
@ToString(of = {"name", "value"})
@EqualsAndHashCode(of = {"name", "value"})
@Builder
public static class Right {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
/*
* This file is a part of MDClasses.
*
* Copyright (c) 2019 - 2024
* 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;
/*
* This file is a part of MDClasses.
*
* Copyright (c) 2019 - 2024
* 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 lombok.AllArgsConstructor;
import com.github._1c_syntax.utils.StringInterner;
import lombok.NonNull;
import lombok.Value;

Expand All @@ -34,22 +34,30 @@
* Используется для хранения текстовой строки на разных языках
*/
@Value
@AllArgsConstructor
public class MultiLanguageString {

/**
* Ссылка на пустой элемент
*/
public static final MultiLanguageString EMPTY = new MultiLanguageString(Collections.emptyMap());

private static final StringInterner stringInterner = new StringInterner();

/**
* Содержимое описания для каждого языка
*/
Map<String, String> content;

public MultiLanguageString(Map<String, String> source) {
Map<String, String> newContent = new HashMap<>();
source.forEach(
(langKey, text) -> newContent.put(stringInterner.intern(langKey), text));
content = newContent;
}

public MultiLanguageString(@NonNull MultiLanguageString first, @NonNull MultiLanguageString second) {
var fullContent = new HashMap<>(first.getContent());
fullContent.putAll(second.getContent());
putContent(fullContent, second);
content = fullContent;
}

Expand All @@ -68,7 +76,7 @@ public static MultiLanguageString of(@NonNull List<MultiLanguageString> strings)
return strings.get(0);
} else {
Map<String, String> content = new HashMap<>();
strings.forEach(string -> content.putAll(string.getContent()));
strings.forEach(string -> putContent(content, string));
return new MultiLanguageString(content);
}
}
Expand Down Expand Up @@ -103,4 +111,9 @@ public static MultiLanguageString of(@NonNull List<MultiLanguageString> strings)
public boolean isEmpty() {
return this == EMPTY;
}

private static void putContent(Map<String, String> destination, MultiLanguageString source) {
source.getContent().forEach(
(langKey, text) -> destination.put(stringInterner.intern(langKey), text));
}
}
50 changes: 27 additions & 23 deletions src/main/java/com/github/_1c_syntax/bsl/mdo/support/RoleRight.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 - 2024
* 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;
/*
* This file is a part of MDClasses.
*
* Copyright (c) 2019 - 2024
* 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 lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down Expand Up @@ -96,7 +96,11 @@ public enum RoleRight implements EnumWithValue {
INTERACTIVE_EXECUTE("InteractiveExecute"),
TECHNICAL_SPECIALIST_MODE("TechnicalSpecialistMode"),
INTERACTIVE_START("InteractiveStart"),
START("Start");
START("Start"),
STANDARD_AUTHENTICATION_CHANGE("StandardAuthenticationChange"),
SESSION_STANDARD_AUTHENTICATION_CHANGE("SessionStandardAuthenticationChange"),
SESSION_OS_AUTHENTICATION_CHANGE("SessionOSAuthenticationChange")
;

@Accessors(fluent = true)
private final String value;
Expand Down
44 changes: 22 additions & 22 deletions src/main/java/com/github/_1c_syntax/bsl/reader/FakeReader.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 - 2024
* 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.reader;
/*
* This file is a part of MDClasses.
*
* Copyright (c) 2019 - 2024
* 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.reader;

import com.github._1c_syntax.bsl.mdclasses.MDClass;
import com.github._1c_syntax.bsl.mdclasses.MDClasses;
Expand Down
45 changes: 22 additions & 23 deletions src/main/java/com/github/_1c_syntax/bsl/reader/MDReader.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 - 2024
* 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.reader;
/*
* This file is a part of MDClasses.
*
* Copyright (c) 2019 - 2024
* 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.reader;

import com.github._1c_syntax.bsl.mdclasses.MDClass;
import com.github._1c_syntax.bsl.reader.common.xstream.ExtendXStream;
Expand Down Expand Up @@ -65,5 +65,4 @@ default Converter getReflectionConverter() {
MDClass readConfiguration();

MDClass readExternalSource();

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private static <T extends Enum<T> & EnumWithValue> T fromValue(Class<T> clazz, S
return item;
}
}
throw new IllegalArgumentException(value);
throw new IllegalArgumentException(clazz.getName() + " " + value);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.github._1c_syntax.bsl.mdo.storage.RoleData;
import com.github._1c_syntax.bsl.reader.common.TransformationUtils;
import com.github._1c_syntax.bsl.reader.common.xstream.ReadConverter;
import com.github._1c_syntax.utils.GenericInterner;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;

Expand Down Expand Up @@ -89,7 +90,8 @@ private static RoleData.Right readRight(HierarchicalStreamReader reader, Unmarsh
TransformationUtils.setValue(builder, name, value);
reader.moveUp();
}
return builder.build();

return RoleData.RIGHT_INTERNER.intern(builder.build());
}

@Override
Expand Down
Loading