Skip to content

Commit

Permalink
feat: added disabled flag
Browse files Browse the repository at this point in the history
  • Loading branch information
JordenReuter committed Jul 12, 2024
1 parent 60b9e8a commit ec63a98
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ public Workspace loadByUrlProductsSlots(String url) {
var cq = cb.createQuery(Workspace.class);
var root = cq.from(Workspace.class);

cq.where(cb.like(cb.literal(url), cb.concat(root.get(BASE_URL), "%")));
cq.where(cb.and(cb.like(cb.literal(url), cb.concat(root.get(BASE_URL), "%")),
cb.or(cb.isNull(root.get(DISABLED)), cb.isFalse(root.get(DISABLED)))));

var workspaceQuery = this.getEntityManager().createQuery(cq);
workspaceQuery.setHint(HINT_LOAD_GRAPH,
this.getEntityManager().getEntityGraph(Workspace.WORKSPACE_PRODUCTS_SLOTS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ default List<Assignment> createAssignments(List<Role> roles, List<MenuItem> menu
return assignments;
}

@Mapping(target = "disabled", ignore = true)
@Mapping(target = "mandatory", constant = "true")
@Mapping(target = "id", ignore = true)
@Mapping(target = "theme", source = "themeName")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,10 @@ public class Workspace extends TraceableEntity {
*/
@Column(name = "OPERATOR")
private Boolean operator;

/**
* Flag to disable a workspace
*/
@Column(name = "DISABLED")
private Boolean disabled;
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ default Map<String, EximWorkspaceDTOV1> map(Map<String, Workspace> data, Map<Str
return map;
}

@Mapping(target = "disabled", ignore = true)
@Mapping(target = "mandatory", ignore = true)
@Mapping(target = "creationDate", ignore = true)
@Mapping(target = "creationUser", ignore = true)
Expand Down
10 changes: 10 additions & 0 deletions src/main/openapi/onecx-workspace-internal-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,8 @@ components:
type: string
address:
$ref: '#/components/schemas/WorkspaceAddress'
disabled:
type: boolean
UpdateWorkspaceRequest:
required:
- name
Expand Down Expand Up @@ -1195,6 +1197,8 @@ components:
type: string
address:
$ref: '#/components/schemas/WorkspaceAddress'
disabled:
type: boolean
Workspace:
required:
- name
Expand Down Expand Up @@ -1242,6 +1246,9 @@ components:
type: boolean
operator:
type: boolean
disabled:
type: boolean
default: false
WorkspaceAbstract:
required:
- name
Expand All @@ -1263,6 +1270,9 @@ components:
type: string
logoUrl:
type: string
disabled:
type: boolean
default: false
WorkspaceAddress:
type: object
properties:
Expand Down
8 changes: 8 additions & 0 deletions src/main/openapi/onecx-workspace-v1-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ components:
properties:
name:
type: string
displayName:
type: string
description:
type: string
theme:
Expand All @@ -188,6 +190,8 @@ components:
type: string
footerLabel:
type: string
disabled:
type: boolean
workspaceRoles:
type: array
uniqueItems: true
Expand Down Expand Up @@ -240,6 +244,10 @@ components:
properties:
name:
type: string
displayName:
type: string
disabled:
type: boolean
theme:
type: string
description:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/db/changeLog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
<include relativeToChangelogFile="true" file="v1/2024-05-28-workspace-operator.xml"/>
<include relativeToChangelogFile="true" file="v1/2024-06-12-update-image-constraint.xml"/>
<include relativeToChangelogFile="true" file="v1/2024-07-04-display-name-added.xml"/>
<include relativeToChangelogFile="true" file="v1/2024-07-12-disabled-flag.xml"/>
</databaseChangeLog>
13 changes: 13 additions & 0 deletions src/main/resources/db/v1/2024-07-12-disabled-flag.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"
objectQuotingStrategy="QUOTE_ONLY_RESERVED_WORDS">

<changeSet author="dev (generated)" id="1720772542567-1">
<addColumn tableName="workspace">
<column name="disabled" type="bool"/>
</addColumn>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ void getWorkspaceByUrlTest() {

assertThat(dto).isNotNull();
assertThat(dto.getCompanyName()).isNotNull().isNotEmpty().isEqualTo("Company44");
assertThat(dto.getDisabled()).isFalse();

// strange protocol
requestDTOV1.setUrl("asd://");
Expand Down Expand Up @@ -243,6 +244,17 @@ void loadWorkspaceByUrlTest() {
.then()
.statusCode(NOT_FOUND.getStatusCode());

// disabled workspace
requestDTOV1.setPath("/company3");
given()
.auth().oauth2(getKeycloakClientToken("testClient"))
.when()
.contentType(APPLICATION_JSON)
.body(requestDTOV1)
.post("/load")
.then()
.statusCode(NOT_FOUND.getStatusCode());

// existing workspace
requestDTOV1.setPath("/company1/admin/my/url");
var dto = given()
Expand Down
12 changes: 6 additions & 6 deletions src/test/resources/data/testdata-external.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<!-- Workspace -->
<WORKSPACE guid="11-111" optlock="0" company_name="Company1" theme="11-111" description="Company1 test" home_page="main_page" name="test01" phone_number="606450342" rss_feed_url="url.com" city="Poznan" country="Poland" base_url="/company1" postalcode="56-789" street="Kolorowa" streetno="6" tenant_id="tenant-100"/>
<WORKSPACE guid="11-222" optlock="0" company_name="Company2" theme="11-111" description="Company2 Test" home_page="main_page" name="test02" phone_number="3856382" rss_feed_url="url.com" city="Berlin" country="Germany" base_url="/company2" postalcode="12-345" street="Unter den Linden" streetno="23" tenant_id="tenant-100"/>
<WORKSPACE guid="22-111" optlock="0" company_name="Company3" theme="11-111" description="Company3 Test" home_page="main_page" name="test03" phone_number="123456789" rss_feed_url="url.com" city="Stuttgart" country="Germany" base_url="/company3" postalcode="45-341" street="Wilhelmstrasse" streetno="15" tenant_id="tenant-100"/>
<WORKSPACE guid="22-222" optlock="0" company_name="Company22" theme="cap" description="Company22 Test" home_page="main_page" name="test22" phone_number="123456789" rss_feed_url="url.com" city="Stuttgart" country="Germany" base_url="/de/cap/admin" postalcode="45-341" street="Wilhelmstrasse" streetno="15" tenant_id="tenant-100"/>
<WORKSPACE guid="22-333" optlock="0" company_name="Company33" theme="tkom" description="Company33 Test" home_page="main_page" name="test33" phone_number="123456789" rss_feed_url="url.com" city="Stuttgart" country="Germany" base_url="/de/tkom/admin" postalcode="45-341" street="Wilhelmstrasse" streetno="15" tenant_id="tenant-100"/>
<WORKSPACE guid="22-444" optlock="0" company_name="Company44" theme="germany" description="Company44 Test" home_page="main_page" name="test44" phone_number="123456789" rss_feed_url="url.com" city="Stuttgart" country="Germany" base_url="/de" postalcode="45-341" street="Wilhelmstrasse" streetno="15" tenant_id="tenant-100"/>
<WORKSPACE guid="33-111" optlock="0" company_name="Company4" theme="22-222" description="Company4 test" home_page="main_page" name="test04" phone_number="606450342" rss_feed_url="url.com" city="Poznan" country="Poland" base_url="/company4" postalcode="56-789" street="Kolorowa" streetno="6" tenant_id="tenant-200"/>
<WORKSPACE guid="33-222" optlock="0" company_name="Company5" theme="22-222" description="Company5 Test" home_page="main_page" name="test05" phone_number="3856382" rss_feed_url="url.com" city="Berlin" country="Germany" base_url="/company5" postalcode="12-345" street="Unter den Linden" streetno="23" tenant_id="tenant-200"/>
<WORKSPACE guid="22-111" optlock="0" company_name="Company3" theme="11-111" description="Company3 Test" home_page="main_page" name="test03" phone_number="123456789" rss_feed_url="url.com" city="Stuttgart" country="Germany" base_url="/company3" postalcode="45-341" street="Wilhelmstrasse" streetno="15" tenant_id="tenant-100" disabled="true"/>
<WORKSPACE guid="22-222" optlock="0" company_name="Company22" theme="cap" description="Company22 Test" home_page="main_page" name="test22" phone_number="123456789" rss_feed_url="url.com" city="Stuttgart" country="Germany" base_url="/de/cap/admin" postalcode="45-341" street="Wilhelmstrasse" streetno="15" tenant_id="tenant-100" disabled="false"/>
<WORKSPACE guid="22-333" optlock="0" company_name="Company33" theme="tkom" description="Company33 Test" home_page="main_page" name="test33" phone_number="123456789" rss_feed_url="url.com" city="Stuttgart" country="Germany" base_url="/de/tkom/admin" postalcode="45-341" street="Wilhelmstrasse" streetno="15" tenant_id="tenant-100" disabled="false"/>
<WORKSPACE guid="22-444" optlock="0" company_name="Company44" theme="germany" description="Company44 Test" home_page="main_page" name="test44" phone_number="123456789" rss_feed_url="url.com" city="Stuttgart" country="Germany" base_url="/de" postalcode="45-341" street="Wilhelmstrasse" streetno="15" tenant_id="tenant-100" disabled="false"/>
<WORKSPACE guid="33-111" optlock="0" company_name="Company4" theme="22-222" description="Company4 test" home_page="main_page" name="test04" phone_number="606450342" rss_feed_url="url.com" city="Poznan" country="Poland" base_url="/company4" postalcode="56-789" street="Kolorowa" streetno="6" tenant_id="tenant-200" disabled="false"/>
<WORKSPACE guid="33-222" optlock="0" company_name="Company5" theme="22-222" description="Company5 Test" home_page="main_page" name="test05" phone_number="3856382" rss_feed_url="url.com" city="Berlin" country="Germany" base_url="/company5" postalcode="12-345" street="Unter den Linden" streetno="23" tenant_id="tenant-200" disabled="false"/>

<!-- MENU_ITEM -->
<MENU_ITEM guid="33-1" optlock="0" disabled="FALSE" key="PORTAL_MAIN_MENU" name="Main Menu" external="FALSE" pos="0" scope="WORKSPACE" url="" workspace="11-111" application_id="" tenant_id="tenant-100"/>
Expand Down
6 changes: 3 additions & 3 deletions src/test/resources/data/testdata-internal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<dataset>

<!-- Workspace -->
<WORKSPACE guid="11-111" optlock="0" company_name="Company1" theme="11-111" description="Company1 test" home_page="main_page" name="test01" phone_number="606450342" rss_feed_url="url.com" city="Poznan" country="Poland" base_url="/company1" postalcode="56-789" street="Kolorowa" streetno="6" tenant_id="tenant-100" mandatory=""/>
<WORKSPACE guid="11-222" optlock="10" company_name="Company2" theme="11-111" description="Company2 Test" home_page="main_page" name="test02" phone_number="3856382" rss_feed_url="url.com" city="Berlin" country="Germany" base_url="/company2" postalcode="12-345" street="Unter den Linden" streetno="23" tenant_id="tenant-100" mandatory="true"/>
<WORKSPACE guid="22-111" optlock="0" company_name="Company3" theme="11-111" description="Company3 Test" home_page="main_page" name="test03" phone_number="123456789" rss_feed_url="url.com" city="Stuttgart" country="Germany" base_url="/company3" postalcode="45-341" street="Wilhelmstrasse" streetno="15" tenant_id="tenant-200"/>
<WORKSPACE guid="11-111" optlock="0" company_name="Company1" theme="11-111" description="Company1 test" home_page="main_page" name="test01" phone_number="606450342" rss_feed_url="url.com" city="Poznan" country="Poland" base_url="/company1" postalcode="56-789" street="Kolorowa" streetno="6" tenant_id="tenant-100" mandatory="" disabled="false"/>
<WORKSPACE guid="11-222" optlock="10" company_name="Company2" theme="11-111" description="Company2 Test" home_page="main_page" name="test02" phone_number="3856382" rss_feed_url="url.com" city="Berlin" country="Germany" base_url="/company2" postalcode="12-345" street="Unter den Linden" streetno="23" tenant_id="tenant-100" mandatory="true" disabled="false"/>
<WORKSPACE guid="22-111" optlock="0" company_name="Company3" theme="11-111" description="Company3 Test" home_page="main_page" name="test03" phone_number="123456789" rss_feed_url="url.com" city="Stuttgart" country="Germany" base_url="/company3" postalcode="45-341" street="Wilhelmstrasse" streetno="15" tenant_id="tenant-200" disabled="false"/>


<!-- MENU_ITEM -->
Expand Down

0 comments on commit ec63a98

Please sign in to comment.