-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from silverbulleters/feature/RoleData
Добавлена поддержка прав доступа хранящихся в ролях
- Loading branch information
Showing
8 changed files
with
273 additions
and
2 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
src/main/java/com/github/_1c_syntax/mdclasses/mdo/ObjectRight.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* This file is a part of MDClasses. | ||
* | ||
* Copyright © 2019 - 2020 | ||
* 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.mdclasses.mdo; | ||
|
||
import com.thoughtworks.xstream.annotations.XStreamAlias; | ||
import com.thoughtworks.xstream.annotations.XStreamImplicit; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* POJO представление прав доступа объекта метаданных, содержащихся в конкретной роли | ||
*/ | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
public class ObjectRight { | ||
private String name = ""; | ||
|
||
@XStreamAlias("right") | ||
@XStreamImplicit | ||
List<Right> rights = Collections.emptyList(); | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/github/_1c_syntax/mdclasses/mdo/Right.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* This file is a part of MDClasses. | ||
* | ||
* Copyright © 2019 - 2020 | ||
* 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.mdclasses.mdo; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
/** | ||
* POJO представление конкретного права доступа, находящегося в роли | ||
*/ | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
public class Right { | ||
private String name = ""; | ||
private boolean value = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/com/github/_1c_syntax/mdclasses/mdo/RoleData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* This file is a part of MDClasses. | ||
* | ||
* Copyright © 2019 - 2020 | ||
* 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.mdclasses.mdo; | ||
|
||
import com.thoughtworks.xstream.annotations.XStreamAlias; | ||
import com.thoughtworks.xstream.annotations.XStreamImplicit; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
|
||
/** | ||
* POJO представление данных конкретной роли | ||
*/ | ||
@NoArgsConstructor | ||
@Getter | ||
@Setter | ||
public class RoleData { | ||
|
||
/** | ||
* Устанавливать права для новых объектов | ||
*/ | ||
@XStreamAlias("setForNewObjects") | ||
private boolean setForNewObjects = false; | ||
|
||
/** | ||
* Устанавливать права для реквизитов и табличных частей по умолчанию | ||
*/ | ||
@XStreamAlias("setForAttributesByDefault") | ||
private boolean setForAttributesByDefault = false; | ||
|
||
/** | ||
* Независимые права подчиненных объектов | ||
*/ | ||
@XStreamAlias("independentRightsOfChildObjects") | ||
private boolean independentRightsOfChildObjects = false; | ||
|
||
@XStreamAlias("object") | ||
@XStreamImplicit | ||
List<ObjectRight> objectRights = Collections.emptyList(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/test/java/com/github/_1c_syntax/mdclasses/mdo/RoleDataTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* This file is a part of MDClasses. | ||
* | ||
* Copyright © 2019 - 2020 | ||
* 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.mdclasses.mdo; | ||
|
||
import com.github._1c_syntax.mdclasses.metadata.additional.ConfigurationSource; | ||
import com.github._1c_syntax.mdclasses.metadata.additional.MDOType; | ||
import com.github._1c_syntax.mdclasses.utils.MDOFactory; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.nio.file.Paths; | ||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class RoleDataTest { | ||
|
||
private static final String SRC_EDT = "src/test/resources/metadata/edt/src"; | ||
private static final String SRC_DESIGNER = "src/test/resources/metadata/original"; | ||
|
||
@Test | ||
void testRoleDataEdt() { | ||
var mdo = MDOFactory.readMDObject(ConfigurationSource.EDT, | ||
MDOType.ROLE, Paths.get(SRC_EDT, "Roles/Роль1/Роль1.mdo")); | ||
assertThat(mdo).isPresent(); | ||
Role role = (Role) mdo.get(); | ||
testRole(role); | ||
} | ||
|
||
@Test | ||
void testRoleDataDesigner() { | ||
var mdo = MDOFactory.readMDObject(ConfigurationSource.DESIGNER, | ||
MDOType.ROLE, Paths.get(SRC_DESIGNER, "Roles/Роль1.xml")); | ||
assertThat(mdo).isPresent(); | ||
Role role = (Role) mdo.get(); | ||
testRole(role); | ||
} | ||
|
||
|
||
private void testRole(Role role) { | ||
|
||
RoleData roleData = role.getRoleData(); | ||
assertThat(roleData).isNotNull(); | ||
|
||
List<ObjectRight> objectRights = roleData.getObjectRights(); | ||
assertThat(objectRights).hasSize(3); | ||
|
||
ObjectRight confRights = objectRights.get(0); | ||
assertThat(confRights.getName()).isEqualTo("Configuration.Конфигурация"); | ||
assertThat(confRights.getRights()).hasSize(18); | ||
|
||
ObjectRight documentRights = objectRights.get(1); | ||
assertThat(documentRights.getName()).isEqualTo("Document.Документ1"); | ||
assertThat(documentRights.getRights()).hasSize(18); | ||
|
||
ObjectRight catalogRights = objectRights.get(2); | ||
assertThat(catalogRights.getName()).isEqualTo("Catalog.Справочник1"); | ||
assertThat(catalogRights.getRights()).hasSize(16); | ||
} | ||
} |