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

Chatbot 630 documentary resources display && Chatbot 624 / 671 / 673 platform redesign #251

Open
wants to merge 21 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0f8c56e
[CHATBOT-630 Export documentary resources and create documentaryResou…
romaricspklee Sep 3, 2024
bd3916d
[CHATBOT-630 add type to AttachmentExport class]
romaricspklee Sep 3, 2024
703563b
[CHATBOT-630 simplify DocumentaryResourceExport class]
romaricspklee Sep 3, 2024
9f31d23
[CHATBOT-630 Export and init documentary resources and documentary re…
romaricspklee Sep 4, 2024
9a237d7
[CHATBOT-630 Platform layout update]
romaricspklee Sep 9, 2024
5ca20cf
[CHATBOT-630 Creating chatbot q&a and documentary resources display p…
romaricspklee Sep 9, 2024
1e33239
[CHATBOT-630 Small bug fix]
romaricspklee Sep 10, 2024
27cb093
[CHATBOT-630 Setting up changeable platform layout + layout changes]
romaricspklee Sep 10, 2024
acc249d
[CHATBOT-630 Small layout update]
romaricspklee Sep 11, 2024
0a1ba92
[CHATBOT-630 Small layout update]
romaricspklee Sep 12, 2024
48d196a
[CHATBOT-630 flexible platform refresh]
romaricspklee Sep 18, 2024
fc26ee8
[CHATBOT-630 small layout changes]
romaricspklee Sep 18, 2024
262f359
[CHATBOT-630 small layout changes]
romaricspklee Sep 19, 2024
35d1c0e
[CHATBOT-630 Export chatbotDisplay qAndADisplay and documentaryResour…
romaricspklee Sep 19, 2024
aee31a5
[CHATBOT-630 rename qAndADisplay param in ChatbotCustomConfigExport]
romaricspklee Sep 19, 2024
4202114
[CHATBOT-630 enable chatbot layout parameters]
romaricspklee Sep 24, 2024
bab00b2
[CHATBOT-630 small layout changes]
romaricspklee Sep 25, 2024
7602916
[CHATBOT-630 create services for chatbot.js]
romaricspklee Sep 27, 2024
6842a8b
[CHATBOT-630 delete text type of documentaryResources]
romaricspklee Sep 27, 2024
f8f5079
[CHATBOT-630 platform refresh on tab change]
romaricspklee Sep 30, 2024
fe72d4c
[CHATBOT-630 small changes]
romaricspklee Sep 30, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ create DtDefinition DtBotExport {
field confluenceSetting {domain: DoDtConfluenceSettingExport label: "Confluence setting" cardinality : "?"}
field jiraSetting {domain: DoDtJiraSettingExport label: "Jira setting" cardinality : "?"}
field jiraFieldSetting {domain: DoDtJiraFieldSettingExport label: "Jira fields setting" cardinality : "*"}
field questionAnswerList {domain: DoText label: "Questions answers List" cardinality : "1"}
field mapContext {domain: DoText label: "map Context" cardinality : "1"}
field questionAnswerList {domain: DoText label: "Questions answers List" cardinality : "1"}
field documentaryResources {domain: DoText label: "Documentary resources" cardinality : "1"}
field mapContext {domain: DoText label: "map Context" cardinality : "1"}
}

create DtDefinition DtTopicExport {
Expand Down Expand Up @@ -115,3 +116,15 @@ create DtDefinition DtQuestionAnswerExport {
field answer {domain: DoText label: "Answer" cardinality : "1"}
field catLabel {domain: DoLabel label: "Category" cardinality : "1"}
}

create DtDefinition DtDocumentaryResourceExport {
field title {domain: DoLabel label: "Title" cardinality : "1" }
field dreTypeCd {domain: DoLabel label: "Resource Type" cardinality : "1" }
cmazereau marked this conversation as resolved.
Show resolved Hide resolved
field text {domain: DoText label: "Text" }
field url {domain: DoText label: "Url" }
field fileData {domain: DoText label: "File data" }
cedricMarechal marked this conversation as resolved.
Show resolved Hide resolved
field fileName {domain: DoLabel label: "File name" }
field fileMimeType {domain: DoLabel label: "File mime type" }
field fileLength {domain: DoSize label: "File size" }
field fileUrn {domain: DoText label: "File urn" }
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
package io.vertigo.chatbot.designer.builder.services;

import java.io.IOException;
import java.io.InputStream;
import java.util.Base64;

import java.util.Optional;

import javax.inject.Inject;

import io.vertigo.account.authorization.annotations.Secured;
import io.vertigo.account.authorization.annotations.SecuredOperation;
import io.vertigo.chatbot.commons.LogsUtils;
import io.vertigo.chatbot.commons.domain.Attachment;
import io.vertigo.chatbot.commons.domain.AttachmentFileInfo;
import io.vertigo.chatbot.commons.domain.AttachmentTypeEnum;
import io.vertigo.chatbot.commons.domain.Chatbot;
import io.vertigo.chatbot.commons.domain.DocumentaryResourceExport;
import io.vertigo.chatbot.commons.multilingual.attachment.AttachmentMultilingualResources;
import io.vertigo.chatbot.designer.builder.services.bot.AttachmentServices;
import io.vertigo.chatbot.designer.commons.services.DesignerFileServices;
import io.vertigo.chatbot.designer.dao.DocumentaryResourceDAO;
import io.vertigo.chatbot.designer.domain.DocumentaryResource;
import io.vertigo.chatbot.designer.domain.DocumentaryResourceTypeEnum;
import io.vertigo.chatbot.domain.DtDefinitions;
import io.vertigo.commons.transaction.Transactional;
import io.vertigo.core.lang.VUserException;
import io.vertigo.core.node.component.Component;
import io.vertigo.datamodel.criteria.Criterions;
import io.vertigo.datamodel.structure.model.DtList;
import io.vertigo.datamodel.structure.model.DtListState;
import io.vertigo.datamodel.structure.util.VCollectors;
import io.vertigo.datastore.filestore.model.VFile;
import io.vertigo.vega.engines.webservice.json.JsonEngine;
import io.vertigo.datastore.filestore.model.FileInfoURI;

import static io.vertigo.chatbot.designer.utils.ListUtils.MAX_ELEMENTS_PLUS_ONE;
Expand All @@ -27,12 +40,18 @@
public class DocumentaryResourceServices implements Component {

@Inject
DocumentaryResourceDAO documentaryResourceDAO;
private DocumentaryResourceDAO documentaryResourceDAO;

@Inject
private AttachmentServices attachmentServices;

@Inject
private DesignerFileServices designerFileServices;

@Inject
AttachmentServices attachmentServices;
private JsonEngine jsonEngine;

public DocumentaryResource getDocResById(final Long dreId) {
public DocumentaryResource getDocResById(final Long dreId) {
return documentaryResourceDAO.get(dreId);
}

Expand Down Expand Up @@ -72,7 +91,7 @@ public void saveDocumentaryResource(@SecuredOperation("botAdm") final Chatbot bo
@Secured("BotUser")
public void deleteDocumentaryResource(@SecuredOperation("botAdm") final Chatbot bot, final DocumentaryResource documentaryResource) {
documentaryResourceDAO.delete(documentaryResource.getDreId());
if(documentaryResource.getAttId() != null){
if (documentaryResource.getAttId() != null) {
attachmentServices.delete(bot, documentaryResource.getAttId());
}
}
Expand All @@ -82,4 +101,41 @@ public DocumentaryResource getNewdocumentaryResource(final Long botId) {
documentaryResource.setBotId(botId);
return documentaryResource;
}

public String exportDocumentaryResourceByBot(@SecuredOperation("botAdm") final Chatbot bot, final StringBuilder logs) {
cedricMarechal marked this conversation as resolved.
Show resolved Hide resolved
LogsUtils.addLogs(logs, "Export documentary resources: ");
try {
return jsonEngine.toJson(getAllDocResByBot(bot).stream().map(documentaryResource -> {
documentaryResource.attachment().load();

final DocumentaryResourceExport documentaryResourceExport = new DocumentaryResourceExport();
documentaryResourceExport.setTitle(documentaryResource.getTitle());
documentaryResourceExport.setDreTypeCd(documentaryResource.getDreTypeCd());
documentaryResourceExport.setText(documentaryResource.getText());
documentaryResourceExport.setUrl(documentaryResource.getUrl());
if (documentaryResource.getAttId() != null) {
Attachment attachment = documentaryResource.attachment().get();
attachment.attachmentFileInfo().load();
AttachmentFileInfo attachmentFileInfo = attachment.attachmentFileInfo().get();
documentaryResourceExport.setFileName(attachmentFileInfo.getFileName());
documentaryResourceExport.setFileMimeType(attachmentFileInfo.getMimeType());
documentaryResourceExport.setFileLength(attachmentFileInfo.getLength());
final VFile file = designerFileServices.getAttachment(attachment.getAttFiId());
try (final InputStream inputStream = file.createInputStream()) {
documentaryResourceExport.setFileData(Base64.getEncoder().encodeToString(inputStream.readAllBytes()));
} catch (final IOException e) {
LogsUtils.logKO(logs);
LogsUtils.addLogs(logs, e);
}
}
return documentaryResourceExport;
}).collect(VCollectors.toDtList(DocumentaryResourceExport.class)));
Copy link
Collaborator

@cmazereau cmazereau Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il me semblerait plus efficace, plutôt que de peupler la liste des documentaryResourceExport en Java, en bouclant sur chaque ressource et en les chargeant une à une, de récupérer cette liste directement à l'aide d'une requête en base.
Le seul point bloquant pour cette requête était la récupération du contenu de l'éventuel fichier associé, récupération supprimée dans le commit 9f31d23


} catch (final Exception e) {
LogsUtils.logKO(logs);
LogsUtils.addLogs(logs, e);
throw new VUserException(AttachmentMultilingualResources.EXPORT_UNEXPECTED_ERROR, e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void delete (@SecuredOperation("botAdm") final Chatbot bot, final long at
public DtList<AttachmentExport> exportAttachmentByBot(@SecuredOperation("botAdm") final Chatbot bot, final StringBuilder logs) {
LogsUtils.addLogs(logs, "Export attachments : ");
try {
return findAllByBotId(bot.getBotId()).stream().map(attachment -> {
return findAllByBotIdAndType(bot.getBotId(), AttachmentTypeEnum.ATTACHMENT.name()).stream().map(attachment -> {
attachment.attachmentFileInfo().load();
final AttachmentFileInfo attachmentFileInfo = attachment.attachmentFileInfo().get();
final AttachmentExport attachmentExport = new AttachmentExport();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.vertigo.chatbot.commons.domain.JiraSettingExport;
import io.vertigo.chatbot.commons.domain.topic.KindTopicEnum;
import io.vertigo.chatbot.designer.builder.services.ConfluenceSettingServices;
import io.vertigo.chatbot.designer.builder.services.DocumentaryResourceServices;
import io.vertigo.chatbot.designer.builder.services.FontFamilyServices;
import io.vertigo.chatbot.designer.builder.services.JiraFieldSettingServices;
import io.vertigo.chatbot.designer.builder.services.JiraSettingServices;
Expand Down Expand Up @@ -58,6 +59,9 @@ public class BotExportServices implements Component {
@Inject
private QuestionAnswerServices questionAnswerServices;

@Inject
private DocumentaryResourceServices documentaryResourceServices;

@Inject
private FontFamilyServices fontFamilyServices;

Expand All @@ -76,6 +80,7 @@ public BotExport exportBot(final Chatbot bot, final StringBuilder logs) {
export.setMapContext(contextValueServices.exportContextValuesToMapByBot(bot, logs));
export.setJiraFieldSetting(jiraFieldSettingServices.exportJiraSetting(bot));
export.setQuestionAnswerList(questionAnswerServices.exportActiveQuestionsAnswers(bot, logs));
export.setDocumentaryResources(documentaryResourceServices.exportDocumentaryResourceByBot(bot, logs));
cmazereau marked this conversation as resolved.
Show resolved Hide resolved
return export;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public final class BotExport implements DtObject {
private io.vertigo.chatbot.commons.domain.JiraSettingExport jiraSetting;
private io.vertigo.datamodel.structure.model.DtList<io.vertigo.chatbot.commons.domain.JiraFieldSettingExport> jiraFieldSetting = new io.vertigo.datamodel.structure.model.DtList<>(io.vertigo.chatbot.commons.domain.JiraFieldSettingExport.class);
private String questionAnswerList;
private String documentaryResources;
private String mapContext;

/**
Expand Down Expand Up @@ -261,6 +262,25 @@ public void setQuestionAnswerList(final String questionAnswerList) {
this.questionAnswerList = questionAnswerList;
}

/**
* Champ : DATA.
* Récupère la valeur de la propriété 'Documentary resources'.
* @return String documentaryResources <b>Obligatoire</b>
*/
@Field(smartType = "STyText", cardinality = io.vertigo.core.lang.Cardinality.ONE, label = "Documentary resources")
public String getDocumentaryResources() {
return documentaryResources;
}

/**
* Champ : DATA.
* Définit la valeur de la propriété 'Documentary resources'.
* @param documentaryResources String <b>Obligatoire</b>
*/
public void setDocumentaryResources(final String documentaryResources) {
this.documentaryResources = documentaryResources;
}

/**
* Champ : DATA.
* Récupère la valeur de la propriété 'map Context'.
Expand Down
Loading