Skip to content

Commit

Permalink
Feature/p002271 6960 clean up exim (#43)
Browse files Browse the repository at this point in the history
* feat: removed subject links and image urls

* feat: clean-up and included products in exim

* fix: removed redundant brackets
  • Loading branch information
JordenReuter authored Mar 21, 2024
1 parent 5afef42 commit e9d8cd2
Show file tree
Hide file tree
Showing 18 changed files with 154 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public interface WorkspaceDataImportMapperV1 {
@Mapping(target = "modificationCount", ignore = true)
@Mapping(target = "persisted", ignore = true)
@Mapping(target = "tenantId", ignore = true)
@Mapping(target = "subjectLink", source = "subjectLinks")
@Mapping(target = "imageUrl", source = "imageUrls")
Workspace createWorkspace(WorkspaceImportDTOV1 workspaceDTO);

@AfterMapping
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import static jakarta.persistence.FetchType.LAZY;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import jakarta.persistence.*;

Expand All @@ -21,8 +19,7 @@
@UniqueConstraint(name = "WORKSPACE_NAME_TENANT_ID", columnNames = { "NAME", "TENANT_ID" }),
@UniqueConstraint(name = "WORKSPACE_BASE_URL_TENANT_ID", columnNames = { "BASE_URL", "TENANT_ID" })
})
@NamedEntityGraph(name = Workspace.WORKSPACE_FULL, attributeNodes = { @NamedAttributeNode("subjectLink"),
@NamedAttributeNode("imageUrl"), @NamedAttributeNode(value = "products") })
@NamedEntityGraph(name = Workspace.WORKSPACE_FULL, attributeNodes = { @NamedAttributeNode(value = "products") })
@SuppressWarnings("squid:S2160")
public class Workspace extends TraceableEntity {

Expand Down Expand Up @@ -62,21 +59,10 @@ public class Workspace extends TraceableEntity {
@Column(name = "FOOTER_LABEL")
private String footerLabel;

@ElementCollection(fetch = LAZY)
@CollectionTable(name = "SUBJECT_LINK")
@AttributeOverride(name = "label", column = @Column(name = "link_label"))
@AttributeOverride(name = "url", column = @Column(name = "link_url"))
private Set<SubjectLink> subjectLink = new HashSet<>();

@Column(name = "ROLES")
@OneToMany(mappedBy = "workspace", fetch = LAZY, cascade = { CascadeType.REMOVE, CascadeType.PERSIST })
private List<Role> roles;

@ElementCollection(fetch = LAZY)
@CollectionTable(name = "IMAGE_URL")
@Column(name = "IMAGE_URL")
private Set<String> imageUrl = new HashSet<>();

@Column(name = "LOGO_URL")
private String logoUrl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
import org.jboss.resteasy.reactive.server.ServerExceptionMapper;
import org.tkit.onecx.workspace.domain.criteria.MenuItemLoadCriteria;
import org.tkit.onecx.workspace.domain.criteria.WorkspaceSearchCriteria;
import org.tkit.onecx.workspace.domain.daos.AssignmentDAO;
import org.tkit.onecx.workspace.domain.daos.MenuItemDAO;
import org.tkit.onecx.workspace.domain.daos.RoleDAO;
import org.tkit.onecx.workspace.domain.daos.WorkspaceDAO;
import org.tkit.onecx.workspace.domain.daos.*;
import org.tkit.onecx.workspace.domain.models.*;
import org.tkit.onecx.workspace.domain.services.MenuService;
import org.tkit.onecx.workspace.rs.exim.v1.mappers.ExportImportExceptionMapperV1;
Expand Down Expand Up @@ -55,6 +52,9 @@ class ExportImportRestControllerV1 implements WorkspaceExportImportApi {
@Inject
RoleDAO roleDAO;

@Inject
ProductDAO productDAO;

@Override
public Response exportMenuByWorkspaceName(String name) {
var workspace = dao.findByName(name);
Expand Down Expand Up @@ -138,6 +138,10 @@ public Response importWorkspaces(WorkspaceSnapshotDTOV1 request) {
workspace = mapper.create(dto);
workspace.setName(name);
dao.create(workspace);
if (dto.getProducts() != null) {
var products = mapper.create(dto.getProducts(), workspace);
productDAO.create(products);
}
items.put(name, ImportResponseStatusDTOV1.CREATED);
} else {
items.put(name, ImportResponseStatusDTOV1.SKIPPED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import java.util.*;

import org.mapstruct.*;
import org.tkit.onecx.workspace.domain.models.MenuItem;
import org.tkit.onecx.workspace.domain.models.Role;
import org.tkit.onecx.workspace.domain.models.Workspace;
import org.tkit.onecx.workspace.domain.models.*;
import org.tkit.quarkus.rs.mappers.OffsetDateTimeMapper;

import gen.org.tkit.onecx.workspace.rs.exim.v1.model.*;
Expand Down Expand Up @@ -36,8 +34,6 @@ default WorkspaceSnapshotDTOV1 create(Map<String, Workspace> workspaces) {
@Mapping(target = "products", ignore = true)
@Mapping(target = "modificationCount", ignore = true)
@Mapping(target = "id", ignore = true)
@Mapping(target = "subjectLink", source = "subjectLinks")
@Mapping(target = "imageUrl", source = "imageUrls")
Workspace create(EximWorkspaceDTOV1 workspaceDTO);

@Mapping(target = "modificationCount", ignore = true)
Expand Down Expand Up @@ -70,13 +66,16 @@ default void afterWorkspace(EximWorkspaceDTOV1 dto, @MappingTarget Workspace wor
ImportWorkspaceResponseDTOV1 create(WorkspaceSnapshotDTOV1 request,
Map<String, ImportResponseStatusDTOV1> workspaces);

@Mapping(target = "removeSubjectLinksItem", ignore = true)
@Mapping(target = "removeImageUrlsItem", ignore = true)
@Mapping(target = "subjectLinks", source = "subjectLink")
@Mapping(target = "imageUrls", source = "imageUrl")
@Mapping(target = "removeProductsItem", ignore = true)
@Mapping(target = "removeRolesItem", ignore = true)
EximWorkspaceDTOV1 map(Workspace workspace);

@Mapping(target = "removeMicrofrontendsItem", ignore = true)
EximProductDTOV1 map(Product product);

@Mapping(target = "appId", source = "mfeId")
EximMicrofrontendDTOV1 map(Microfrontend microfrontend);

default MenuSnapshotDTOV1 create(List<MenuItem> menuStructure) {
MenuSnapshotDTOV1 snapshot = new MenuSnapshotDTOV1();
snapshot.setCreated(OffsetDateTime.now());
Expand Down Expand Up @@ -205,4 +204,27 @@ default MenuSnapshotDTOV1 mapTree(Collection<MenuItem> entities, Map<String, Set
return dto;
}

default List<Product> create(List<EximProductDTOV1> products, Workspace workspace) {
List<Product> newProducts = new ArrayList<>();
products.forEach(productDTOV1 -> newProducts.add(map(productDTOV1, workspace)));
return newProducts;
}

@Mapping(target = "workspaceId", ignore = true)
@Mapping(target = "workspace", source = "workspace")
@Mapping(target = "tenantId", ignore = true)
@Mapping(target = "persisted", ignore = true)
@Mapping(target = "modificationUser", ignore = true)
@Mapping(target = "modificationDate", ignore = true)
@Mapping(target = "modificationCount", ignore = true)
@Mapping(target = "id", ignore = true)
@Mapping(target = "creationUser", ignore = true)
@Mapping(target = "creationDate", ignore = true)
@Mapping(target = "controlTraceabilityManual", ignore = true)
@Mapping(target = "baseUrl", source = "productDTOV1.baseUrl")
Product map(EximProductDTOV1 productDTOV1, Workspace workspace);

@Mapping(target = "mfeId", source = "appId")
@Mapping(target = "id", ignore = true)
Microfrontend map(EximMicrofrontendDTOV1 eximMicrofrontendDTOV1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ default WorkspaceAbstractDTOV1 mapAbstract(Workspace workspace) {
@Mapping(target = "names", ignore = true)
WorkspaceSearchCriteria map(WorkspaceSearchCriteriaDTOV1 criteria);

@Mapping(target = "subjectLinks", ignore = true)
@Mapping(target = "workspaceRoles", source = "roles")
@Mapping(target = "removeSubjectLinksItem", ignore = true)
@Mapping(target = "imageUrls", ignore = true)
@Mapping(target = "removeImageUrlsItem", ignore = true)
@Mapping(target = "removeWorkspaceRolesItem", ignore = true)
WorkspaceDTOV1 map(Workspace workspace);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ public interface WorkspaceMapper {
@Mapping(target = "removeStreamItem", ignore = true)
WorkspacePageResultDTO mapPageResult(PageResult<Workspace> page);

@Mapping(target = "removeSubjectLinksItem", ignore = true)
@Mapping(target = "removeImageUrlsItem", ignore = true)
@Mapping(target = "subjectLinks", source = "subjectLink")
@Mapping(target = "imageUrls", source = "imageUrl")
WorkspaceDTO map(Workspace data);

}
11 changes: 0 additions & 11 deletions src/main/openapi/di-workspace-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,11 @@ components:
type: string
footerLabel:
type: string
subjectLinks:
maxItems: 3
uniqueItems: true
type: array
items:
$ref: '#/components/schemas/SubjectLink'
products:
type: array
uniqueItems: true
items:
$ref: "#/components/schemas/Product"
imageUrls:
uniqueItems: true
type: array
items:
type: string
workspaceRoles:
type: array
uniqueItems: true
Expand Down
32 changes: 18 additions & 14 deletions src/main/openapi/onecx-workspace-exim-v1-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,28 @@ components:
type: array
items:
$ref: '#/components/schemas/EximWorkspaceRole'
subjectLinks:
uniqueItems: true
maxItems: 3
products:
type: array
items:
$ref: '#/components/schemas/EximSubjectLink'
imageUrls:
uniqueItems: true
$ref: '#/components/schemas/EximProduct'
EximProduct:
type: object
properties:
productName:
type: string
baseUrl:
type: string
microfrontends:
type: array
items:
type: string
$ref: '#/components/schemas/EximMicrofrontend'
EximMicrofrontend:
type: object
properties:
appId:
type: string
basePath:
type: string
EximWorkspaceRole:
type: object
properties:
Expand All @@ -208,13 +219,6 @@ components:
type: string
postalCode:
type: string
EximSubjectLink:
type: object
properties:
label:
type: string
url:
type: string
MenuSnapshot:
type: object
properties:
Expand Down
33 changes: 0 additions & 33 deletions src/main/openapi/onecx-workspace-internal-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -963,17 +963,6 @@ components:
type: string
address:
$ref: '#/components/schemas/WorkspaceAddress'
subjectLink:
uniqueItems: true
maxItems: 3
type: array
items:
$ref: '#/components/schemas/SubjectLink'
imageUrl:
uniqueItems: true
type: array
items:
type: string
UpdateWorkspaceRequest:
required:
- name
Expand Down Expand Up @@ -1005,17 +994,6 @@ components:
type: string
address:
$ref: '#/components/schemas/WorkspaceAddress'
subjectLink:
uniqueItems: true
maxItems: 3
type: array
items:
$ref: '#/components/schemas/SubjectLink'
imageUrl:
uniqueItems: true
type: array
items:
type: string
Workspace:
required:
- name
Expand Down Expand Up @@ -1056,17 +1034,6 @@ components:
type: string
address:
$ref: '#/components/schemas/WorkspaceAddress'
subjectLinks:
uniqueItems: true
maxItems: 3
type: array
items:
$ref: '#/components/schemas/SubjectLink'
imageUrls:
uniqueItems: true
type: array
items:
type: string
WorkspaceAbstract:
required:
- name
Expand Down
11 changes: 0 additions & 11 deletions src/main/openapi/onecx-workspace-v1-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,6 @@ components:
type: string
address:
$ref: '#/components/schemas/WorkspaceAddress'
subjectLinks:
uniqueItems: true
maxItems: 3
type: array
items:
$ref: '#/components/schemas/SubjectLink'
imageUrls:
uniqueItems: true
type: array
items:
type: string
WorkspaceAddress:
type: object
properties:
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 @@ -7,4 +7,5 @@
<include relativeToChangelogFile="true" file="v1/2023-11-09-data-import-log.xml"/>
<include relativeToChangelogFile="true" file="v1/2024-02-22-create-table-image.xml"/>
<include relativeToChangelogFile="true" file="v1/2024-03-19-update-assignment-constraints.xml"/>
<include relativeToChangelogFile="true" file="v1/2024-03-20-drop-image-urls-subject-links.xml"/>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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="1710944924844-1">
<dropForeignKeyConstraint baseTableName="image_url" constraintName="image_url_workspace_guid"/>
<dropForeignKeyConstraint baseTableName="subject_link" constraintName="subject_link_workspace_guid"/>
<dropTable tableName="image_url"/>
<dropTable tableName="subject_link"/>
</changeSet>
</databaseChangeLog>
Loading

0 comments on commit e9d8cd2

Please sign in to comment.