From e88cbb6b925bcb916a02be5577332f82e57bb280 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Wed, 19 Oct 2022 10:39:33 +0800 Subject: [PATCH 01/81] =?UTF-8?q?feature(be-runtime)=EF=BC=9A=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E5=B7=A5=E7=A8=8B=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增工程基础配置 --- .gitignore | 757 ++++++++++++++++++++++++++++++++++++++ pom.xml | 165 +++++++++ style/ubml_checkstyle.xml | 135 +++++++ 3 files changed, 1057 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 style/ubml_checkstyle.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fc20259 --- /dev/null +++ b/.gitignore @@ -0,0 +1,757 @@ +.scratch/ +.mvn/repository + +# Created by https://www.gitignore.io/api/vim,node,java,linux,macos,emacs,nanoc,eclipse,windows,java-web,visualstudio,jetbrains+iml,visualstudiocode,maven,gradle + +### Eclipse ### + +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# CDT- autotools +.autotools + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Annotation Processing +.apt_generated/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + +### Eclipse Patch ### +# Eclipse Core +.project + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# Annotation Processing +.apt_generated + +### Emacs ### +# -*- mode: gitignore; -*- +*~ +\#*\# +/.emacs.desktop +/.emacs.desktop.lock +*.elc +auto-save-list +tramp +.\#* + +# Org-mode +.org-id-locations +*_archive + +# flymake-mode +*_flymake.* + +# eshell files +/eshell/history +/eshell/lastdir + +# elpa packages +/elpa/ + +# reftex files +*.rel + +# AUCTeX auto folder +/auto/ + +# cask packages +.cask/ +dist/ + +# Flycheck +flycheck_*.el + +# server auth directory +/server/ + +# projectiles files +.projectile + +# directory configuration +.dir-locals.el + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### Java-Web ### +## ignoring target file +target/ + +### JetBrains+iml ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +### JetBrains+iml Patch ### +# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 + +*.iml +modules.xml +.idea/misc.xml +*.ipr +.idea/workspace.xml + +### Linux ### + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Maven ### +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +.mvn/wrapper/maven-wrapper.jar +.mvn/settings.xml + +### Nanoc ### +# For projects using Nanoc (http://nanoc.ws/) + +# Default location for output (needs to match output_dir's value found in nanoc.yaml) +output/ + +# Temporary file directory +tmp/nanoc/ + +# Crash Log +crash.log + +### Node ### +# Logs +logs +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# next.js build output +.next + +# nuxt.js build output +.nuxt + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +### VisualStudioCode ### +.vscode/* +# !.vscode/settings.json +# !.vscode/tasks.json +# !.vscode/launch.json +# !.vscode/extensions.json + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +### Gradle ### +.gradle +/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties + +### VisualStudio ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp_proj +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + + +# End of https://www.gitignore.io/api/vim,node,java,linux,macos,emacs,nanoc,eclipse,windows,java-web,visualstudio,jetbrains+iml,visualstudiocode,maven,gradle + +!charts/*/charts/*.tgz \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..bca0dce --- /dev/null +++ b/pom.xml @@ -0,0 +1,165 @@ + + + + + 4.0.0 + + + io.iec.edp + caf-boot-parent + 0.2.6 + + + com.inspur.edp + bff-framework + pom + 0.1.1 + + bff-framework-api + bff-framework-entity + bff-framework-spi + bff-framework-core + + + + 0.1.12 + 0.2.3 + 0.1.3 + 0.1.1 + 0.2.49 + 0.2.84 + 0.2.38 + 0.1.19 + + + + + com.inspur.edp + cef-spi + ${cef.version} + + + com.inspur.edp + cm-spi + ${cm.version} + + + com.inspur.edp + cef-gencommon + ${cef.gencommon.version} + + + com.inspur.edp + cef-api + ${cef.version} + + + com.inspur.edp + cef-entity + ${cef.version} + + + com.inspur.edp + cef-core + ${cef.version} + + + com.inspur.edp + bff-entity + ${project.version} + compile + + + com.inspur.edp + bff-api + ${project.version} + compile + + + com.inspur.edp + cm-api + ${cm.version} + compile + + + com.inspur.edp + cm-core + ${cm.version} + compile + + + com.inspur.edp + bef-api + ${bef.version} + + + com.inspur.edp + bef-core + ${bef.version} + + + com.inspur.edp + bef-spi + ${bef.version} + + + com.inspur.edp + bef-entity + ${bef.version} + compile + + + com.inspur.edp + web-help-api + ${web.help.api.version} + + + com.inspur.edp + cef-variable-api + ${cef.variable.version} + + + com.inspur.edp + caf-cef-rt-api + ${caf.cef.version} + + + com.inspur.edp + lcm-metadata-api + ${lcm.metadata..version} + + + io.iec.edp + caf-boot-commons-json + 0.3.4 + + + + + + gsp-snapshots-repo + https://repos.iec.io/repository/maven-gsp-snapshots/ + + + gsp-releases-repo + https://repos.iec.io/repository/maven-gsp-releases/ + + + + diff --git a/style/ubml_checkstyle.xml b/style/ubml_checkstyle.xml new file mode 100644 index 0000000..c63db71 --- /dev/null +++ b/style/ubml_checkstyle.xml @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- Gitee From 4acef0fa57dc25ca23a8a0bda873f4c7e4a200b3 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Mon, 24 Oct 2022 18:13:32 +0800 Subject: [PATCH 02/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E5=B7=A5=E7=A8=8B=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增工程基础配置 --- bff-framework-api/pom.xml | 82 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 bff-framework-api/pom.xml diff --git a/bff-framework-api/pom.xml b/bff-framework-api/pom.xml new file mode 100644 index 0000000..2802fdd --- /dev/null +++ b/bff-framework-api/pom.xml @@ -0,0 +1,82 @@ + + + 4.0.0 + + com.inspur.edp + bff-framework-api + 0.1.1 + + + + + maven-source-plugin + + + attach-sources + + jar + + + + + + + + + + + io.iec.edp + caf-boot-starter-rest-server + + + + io.iec.edp + caf-boot-starter-rest-client + + + org.projectlombok + lombok + provided + + + com.inspur.edp + cef-entity + + + com.inspur.edp + cef-api + + + com.inspur.edp + cm-api + + + com.inspur.edp + bef-api + + + com.inspur.edp + bff-entity + ${project.version} + compile + + + com.inspur.edp + web-help-api + + + com.inspur.edp + cef-variable-api + + + com.inspur.edp + cef-spi + + + com.inspur.edp + cm-spi + + + -- Gitee From d5eddfb79fd1e1dedbc7402b386ad62698763660 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Mon, 24 Oct 2022 18:19:18 +0800 Subject: [PATCH 03/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增查询操作 --- .../edp/bff/api/manager/QueryResult.java | 54 ++++++ .../bff/api/manager/context/QueryContext.java | 155 ++++++++++++++++++ 2 files changed, 209 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/QueryResult.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/QueryContext.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/QueryResult.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/QueryResult.java new file mode 100644 index 0000000..fe41f72 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/QueryResult.java @@ -0,0 +1,54 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager; + +import com.inspur.edp.cef.entity.dependenceTemp.Pagination; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.List; + +public class QueryResult { + + private List result; + + /** + * 根据过滤条件查询出来的主表数据结果集 + * @return + */ + public final List getResult() + { + return result; + } + public final void setResult(List value) + { + result = value; + } + private Pagination pagination; + + /** + * 根据过滤条件查询出来的主表数据分页信息 + * @return + */ + public final Pagination getPagination() + { + return pagination; + } + public final void setPagination(Pagination value) + { + pagination = value; + } +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/QueryContext.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/QueryContext.java new file mode 100644 index 0000000..ca61ea3 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/QueryContext.java @@ -0,0 +1,155 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.context; + +import com.inspur.edp.bef.api.lcp.AuthInfo; +import com.inspur.edp.cef.entity.condition.EntityFilter; +import com.inspur.edp.cef.entity.dependenceTemp.Pagination; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.ArrayList; + +/** + * 查询上下文 + * 查询前,查询,查询后扩展动作共用一个查询上下文 + * 扩展动作执行顺序可参考:点击这里查看。 + */ +public class QueryContext { + + private EntityFilter filter; + /** + * 获取外部设置的过滤条件 + * + * @return + * + * @see EntityFilter + */ + public final EntityFilter getFilter() + { + return filter; + } + /** + * 设置过滤条件 + */ + public final void setFilter(EntityFilter value) + { + filter = value; + } + + + private ArrayList queryResult= new ArrayList(); + /** + * 获取查询结果,这里的数据时经过数据Mapping转换之后的vo数据集 + */ + public final ArrayList getQueryResult() + { + return queryResult; + } + + /** + * 设置查询数据结果集 + * + * @param value + */ + public final void setQueryResult(ArrayList value) + { + queryResult = value; + } + + + private IEntityData param; + + /** + * 获取QO传入实体数据 + * + * @return + * + * @see IEntityData + */ + public final IEntityData getParam() + { + return param; + } + + /** + * QO设置实体数据 + * + * @param value + */ + public final void setParam(IEntityData value) + { + param = value; + } + + + private Pagination pagination; + + /** + * 获取分页信息 + * @return + * + * @see Pagination + */ + public final Pagination getPageInfo() + { + return pagination; + } + + /** + * 设置分页信息 + * @param value + */ + public final void setPageInfo(Pagination value) + { + pagination = value; + } + + + private String extendCond; + public final String getExtendCond() + { + return extendCond; + } + public final void setExtendCond(String value) + { + extendCond = value; + } + + private boolean useCustomAuth=false; + public boolean getUseCustomAuth(){return useCustomAuth;} + public void setUseCustomAuth(boolean value){useCustomAuth=value;} + + private AuthInfo authInfo; + + /** + * 获取权限信息 + * @return + * + * @see AuthInfo + */ + public AuthInfo getAuthInfo() + {return authInfo;} + + /** + * 设置权限信息 + * @param value + */ + public void setAuthInfo(AuthInfo value) + { + authInfo=value; + } +} -- Gitee From 226440986e22b53a0dce85558eba2b92d8b2f7cf Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Mon, 24 Oct 2022 18:25:20 +0800 Subject: [PATCH 04/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改上下文 --- .../api/manager/context/ModifyContext.java | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/ModifyContext.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/ModifyContext.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/ModifyContext.java new file mode 100644 index 0000000..e7234f5 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/ModifyContext.java @@ -0,0 +1,96 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.context; + +import com.inspur.edp.cef.entity.changeset.IChangeDetail; + +import java.util.ArrayList; +import java.util.HashMap; + +/** + * 修改上下文 + * 修改前,修改,修改后扩展动作共用一个修改上下文 + * 扩展动作执行顺序可参考:点击这里查看。 + */ +public class ModifyContext { + + private ArrayList sourceChange = new ArrayList(); + + /** + * 源变更集(外部传入) + */ + public final ArrayList getSourceChange() + { + return sourceChange; + } + public final void setSourceChange(ArrayList value) + { + sourceChange = value; + } + + + + private HashMap> mappedChange = new HashMap>(); + + /** + * 映射后的变更集集合 + * Key:数据源编号,内部默认Key值使用Default,开发时请注意不要使用该Key值,以免出现未知问题。 + * Value:数据源对应变更集 + */ + public final HashMap> getMappedChange() + { + return mappedChange; + } + public final void setMappedChange(HashMap> value) + { + mappedChange = value; + } + + + + private HashMap> innerChange= new HashMap>(); + /** + * 内部变更集合,执行完变更操作后,将内部变更集写入 + * Key:数据源编号,内部默认Key值使用Default,开发时请注意不要使用该Key值,以免出现未知问题。 + * Value:数据源对应内部变更集 + */ + public final HashMap> getInnerChange() + { + return innerChange; + } + public final void setInnerChange(HashMap> value) + { + innerChange = value; + } + + + + private ArrayList targetChange = new ArrayList(); + + /** + * vo内部变更集:通过{@link #innerChange}反向映射合并后的结果 + */ + public final ArrayList getTargetChange() + { + return targetChange; + } + public final void setTargetChange(ArrayList value) + { + targetChange = value; + } + +} -- Gitee From 9ea075b54751ce0459c26eda8c2389f219925067 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Tue, 25 Oct 2022 09:30:43 +0800 Subject: [PATCH 05/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E6=A3=80?= =?UTF-8?q?=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增检索操作 --- .../api/manager/context/RetrieveContext.java | 102 +++++++++++++++++ .../context/RetrieveDefaultContext.java | 108 ++++++++++++++++++ .../RetrieveChildParamDeserializer.java | 46 ++++++++ .../param/retrieve/RetrieveChildResult.java | 50 ++++++++ .../bff/api/param/retrieve/RetrieveParam.java | 41 +++++++ .../api/param/retrieve/RetrieveResult.java | 50 ++++++++ 6 files changed, 397 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/RetrieveContext.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/RetrieveDefaultContext.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/param/retrieve/RetrieveChildParamDeserializer.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/param/retrieve/RetrieveChildResult.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/param/retrieve/RetrieveParam.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/param/retrieve/RetrieveResult.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/RetrieveContext.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/RetrieveContext.java new file mode 100644 index 0000000..2699499 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/RetrieveContext.java @@ -0,0 +1,102 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.context; + + +import com.inspur.edp.bef.api.parameter.retrieve.RetrieveParam; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.ArrayList; +import java.util.HashMap; + +/** + * 检索上下文 + * 检索前,检索,检索后扩展动作共用一个检索上下文 + * 扩展动作执行顺序可参考:点击这里查看。 + */ +public class RetrieveContext { + /** + * 要检索的数据ID + * + */ + private ArrayList dataIds = new ArrayList(); + public final ArrayList getDataIds() + { + return dataIds; + } + public final void setDataIds(ArrayList value) + { + dataIds = value; + } + + + + private RetrieveParam param; + + /** + * 检索的参数 + * @return + * + * @see RetrieveParam + */ + public final RetrieveParam getParam() + { + return param; + } + public final void setParam(RetrieveParam value) + { + param = value; + } + + + private HashMap> retrieveData = new HashMap>(); + /** + * 数据源检索结果集 + * Key:数据源编号,内部默认Key值使用Default,开发时请注意不要使用该Key值,以免出现未知问题。 + * Value:数据源检索集 + */ + public final HashMap> getRetrieveData() + { + return retrieveData; + } + public final void setRetrieveData(HashMap> value) + { + retrieveData = value; + } + + + + private ArrayList retrieveResult = new ArrayList(); + /** + * Vo检索结果,该结果是经过数据Mapping转换之后的vo数据结构 + * + */ + public final ArrayList getRetrieveResult() + { + return retrieveResult; + } + + /** + * Vo检索结果 + * + */ + public final void setRetrieveResult(ArrayList value) + { + retrieveResult = value; + } + +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/RetrieveDefaultContext.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/RetrieveDefaultContext.java new file mode 100644 index 0000000..ec88e10 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/RetrieveDefaultContext.java @@ -0,0 +1,108 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.context; + +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.ArrayList; +import java.util.HashMap; + +/** + * 新增上下文 + * 新增前,新增,新增后扩展动作共用一个新增上下文 + * 扩展动作执行顺序可参考:点击这里查看 + */ +public class RetrieveDefaultContext { + /** + * 获取新增的Vo数据,这里的数据指的是经过数据Mapping转换之后得到的vo数据集 + */ + private IEntityData retrieveDefaultResult; + public final IEntityData getRetrieveDefaultResult() + { + return retrieveDefaultResult; + } + public final void setRetrieveDefaultResult(IEntityData value) + { + retrieveDefaultResult = value; + } + + + private HashMap> retrieveDefaultData = new HashMap>(); + + /** + * 数据源新增结果集 + * Key:数据源编号,内部默认Key值使用Default,开发时请注意不要使用该Key值,以免出现未知问题。 + * Value:数据源新增数据 + */ + public final HashMap> getRetrieveDefaultData() + { + return retrieveDefaultData; + } + public final void setRetrieveDefaultData(HashMap> value) + { + retrieveDefaultData = value; + } + + + private VoDefaultValue voDefaultValue; + + /** + * 获取新增时设置的默认值 + * + * @return + * + * @see VoDefaultValue + */ + public final VoDefaultValue getVoDefaultValue() + { + return voDefaultValue; + } + + /** + * 新增时设置默认值,可参考{@link IFSManager#retrieveDefault(VoDefaultValue)}中的参数设置 + * + * @return + * + * @see VoDefaultValue + */ + public final void setVoDefaultValue(VoDefaultValue value) + { + voDefaultValue = value; + } + + private String dataId; + + /** + * 获取新增时设置的数据id + * @return + */ + public final String getDataId() + { + return dataId; + } + + /** + * 设置新增数据id + * @param value + */ + public final void setDataId(String value) + { + dataId = value; + } +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/param/retrieve/RetrieveChildParamDeserializer.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/param/retrieve/RetrieveChildParamDeserializer.java new file mode 100644 index 0000000..4ab67a8 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/param/retrieve/RetrieveChildParamDeserializer.java @@ -0,0 +1,46 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.param.retrieve; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; + +import java.io.IOException; + +public class RetrieveChildParamDeserializer extends JsonDeserializer { + + @Override + public RetrieveParam deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { + if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) { + throw new RuntimeException("json结构异常"); + } else { + RetrieveParam param=new RetrieveParam(); + + jsonParser.nextToken(); + jsonParser.nextToken(); + Boolean isNeedLock = jsonParser.getBooleanValue(); + // IChangeDetail detail = this.createChangeDetail(p, changeType, ctxt); + jsonParser.getCurrentToken(); + jsonParser.nextToken(); + return null; + } + } +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/param/retrieve/RetrieveChildResult.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/param/retrieve/RetrieveChildResult.java new file mode 100644 index 0000000..ea06e42 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/param/retrieve/RetrieveChildResult.java @@ -0,0 +1,50 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.param.retrieve; + +import com.inspur.edp.cef.entity.dependenceTemp.Pagination; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.ArrayList; + +public class RetrieveChildResult { + /** + * 当前分页中子表所有数据 + */ + private ArrayList result; + /** + * 当前子表分页的分页信息 + */ + private Pagination pagination; + + public ArrayList getResult() { + return result; + } + + public void setResult(ArrayList result) { + this.result = result; + } + + public Pagination getPagination() { + return pagination; + } + + public void setPagination(Pagination pagination) { + this.pagination = pagination; + } + +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/param/retrieve/RetrieveParam.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/param/retrieve/RetrieveParam.java new file mode 100644 index 0000000..3801874 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/param/retrieve/RetrieveParam.java @@ -0,0 +1,41 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.param.retrieve; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.inspur.edp.cef.entity.condition.EntityFilter; +import lombok.Data; + +import java.util.HashMap; +import java.util.List; + +@Data +//@JsonDeserialize(using = RetrieveChildParamDeserializer.class) +public class RetrieveParam { + /** + * 是否加锁 + */ + private boolean needLock; + /** + * 子表分页信息,Key:子表NodeCode、Pagination:分页信息 + */ + private HashMap filters = new HashMap<>(); + + private HashMap parentIds =new HashMap<>(); + +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/param/retrieve/RetrieveResult.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/param/retrieve/RetrieveResult.java new file mode 100644 index 0000000..252311c --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/param/retrieve/RetrieveResult.java @@ -0,0 +1,50 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.param.retrieve; + +import com.inspur.edp.cef.entity.dependenceTemp.Pagination; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.HashMap; + +public class RetrieveResult { + public IEntityData getResult() { + return result; + } + + public void setResult(IEntityData result) { + this.result = result; + } + + public HashMap getPagination() { + return pagination; + } + + public void setPagination(HashMap pagination) { + this.pagination = pagination; + } + + /** + * Be实体信息 + */ + private IEntityData result; + /** + * 表分页信息,Key :子表NodeCode、Value:分页信息 + */ + public HashMap pagination = new HashMap<>(); + +} -- Gitee From 0eacf009684238d03339ed786263f23c7de35652 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Tue, 25 Oct 2022 09:35:32 +0800 Subject: [PATCH 06/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E4=BF=9D?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增保存上下文 --- .../bff/api/manager/context/SaveContext.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/SaveContext.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/SaveContext.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/SaveContext.java new file mode 100644 index 0000000..5c6120f --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/SaveContext.java @@ -0,0 +1,25 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.context; + +/** + * 保存上下文 + * 保存前,保存后扩展动作共用一个保存上下文 + * 目前保存上下文中未封装其他相关信息,后续支持 + */ +public class SaveContext { +} -- Gitee From 1949dd0e68a4cbcdd043b5bb03e8a272a55ef271 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Tue, 25 Oct 2022 09:46:48 +0800 Subject: [PATCH 07/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9AVO=E6=9D=A5?= =?UTF-8?q?=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增Vo来源枚举类 --- .../edp/bff/api/manager/SourceType.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/SourceType.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/SourceType.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/SourceType.java new file mode 100644 index 0000000..baf8cdb --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/SourceType.java @@ -0,0 +1,21 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager; + +public enum SourceType { + Be,Qo +} -- Gitee From a6308c0f4a1057e4525f7a456559bf0fbb93ca7a Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Tue, 25 Oct 2022 10:01:26 +0800 Subject: [PATCH 08/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9AFSManager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增FSManager --- .../edp/bff/api/manager/IFSManager.java | 696 ++++++++++++++++++ .../bff/api/manager/IFSManagerContext.java | 315 ++++++++ .../bff/api/manager/IFSManagerFactory.java | 104 +++ 3 files changed, 1115 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/IFSManager.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/IFSManagerContext.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/IFSManagerFactory.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/IFSManager.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/IFSManager.java new file mode 100644 index 0000000..a376985 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/IFSManager.java @@ -0,0 +1,696 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager; + +import com.inspur.edp.bef.api.lcp.AuthInfo; +import com.inspur.edp.bef.api.lcp.IStandardLcp; +import com.inspur.edp.bef.api.parameter.retrieve.RespectiveRetrieveResult; +import com.inspur.edp.bef.api.parameter.retrieve.RetrieveParam; +import com.inspur.edp.bff.api.manager.context.TimeStampContext; +import com.inspur.edp.bff.api.param.retrieve.RetrieveChildResult; +import com.inspur.edp.bff.api.param.retrieve.RetrieveResult; +import com.inspur.edp.bff.entity.RetrieveDefaultParam; +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; +import com.inspur.edp.cef.api.action.EditResult; +import com.inspur.edp.cef.api.manager.serialize.CefSerializeContext; +import com.inspur.edp.cef.api.request.RequestInfo; +import com.inspur.edp.cef.api.response.ResponseContext; +import com.inspur.edp.cef.api.response.ResponseInfo; +import com.inspur.edp.cef.api.rootManager.ICefRootManager; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import com.inspur.edp.cef.entity.condition.EntityFilter; +import com.inspur.edp.cef.entity.dependenceTemp.Pagination; +import com.inspur.edp.cef.entity.entity.IEntityData; +import com.inspur.edp.cef.spi.entity.resourceInfo.ModelResInfo; +import com.inspur.edp.cef.variable.api.manager.IVariableManager; +import com.inspur.edp.commonmodel.api.ICMManager; +import com.inspur.edp.web.help.api.LookupQueryParam; +import com.inspur.edp.web.help.api.LookupResult; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; + +/** + * 标准的本地消费者代理,提供了外部程序调用的基本的操作接口,比如CRUD + * 继承自{@link com.inspur.edp.commonmodel.api.ICMManager} 以及{@link com.inspur.edp.cef.api.rootManager.ICefRootManager} + *

创建本类实例请使用{@link IFSManagerFactory} + */ +public interface IFSManager extends ICefRootManager, ICMManager { + /** + * 功能连接 + * @param parentSessionID 功能sessionID + * @return + */ + String connect(String parentSessionID); + + /** + * 尝试功能连接 + */ + void tryConnect(); + + /** + * 关闭当前session + */ + void close(); + + /** + * 1.取消当前业务实体上已提交到缓存、但未保存到持久化中的变更集; + *

+ * 2.释放当前业务实体下所有的数据锁; + * 取消内部实现调用{@link IStandardLcp#cancel()},详情请看{@link IStandardLcp} + */ + void cancel(); + /** + * 返回给请求的响应数据,包括返回给前端的消息以及后台产生的变更集数据。 + * @return + * + * @see ResponseContext + */ + ResponseContext getResponseContext(); + + /** + * 获取当前视图对象的FSManager上下文 + * @return + * @see IFSManagerContext + */ + IFSManagerContext getBffContext(); + /** + * 新增一条视图对象主表数据,实体数据中带有默认值。关于默认值的说明可以参考{@link #retrieveDefault(VoDefaultValue)}。 + * + * @return 实体数据 + * + * @see IEntityData + */ + IEntityData retrieveDefault(); + + /** 新增一条特定ID的视图对象主表数据,实体数据中字段带有默认值。实体数据默认值可参考{@link #retrieveDefault(VoDefaultValue)}。*/ + IEntityData retrieveDefault(String dataId); + /** + * 新增一条视图对象主表数据,实体数据中带有传入的默认值。默认值的来源有: + *

  • 字段类型固有默认值(通常为{@code null},如果在WebIde上将字段的“默认为空”属性设置为false,则使用字段的非{@code null}默认值, + * 如整数类型({@link Integer})为0,浮点类型({@link BigDecimal})为0.0,文本类型({@link String})为""等); + *
  • 通过WebIde设计器中给字段设置的默认值; + *
  • 通过{@code defaultValues}参数传入的默认值; + *
  • 字段上设置的新增时生成的编号规则; + *
  • 通过新增后联动计算设置的默认值;
+ * 以上默认值规则按顺序从上至下进行,上面的默认值与下面的默认值如有重复,下面将覆盖上面。 + * + * @param defaultValue 传入的默认值,默认值中不能包含主键字段,默认值参数设置参考{@link VoDefaultValue} + * @return 新增的主表实体数据 + * + * @see IEntityData + * + */ + + IEntityData retrieveDefault(VoDefaultValue defaultValue); + + /** + * 根据默认值参数新增一组视图对象主表数据,生成的数据条数由传入参数defaultParam上的getVoDefaultValues()个数决定 + * @param defaultParam + * @return 视图对象主表数据列表 + * @see ArrayList + * @see RetrieveDefaultParam + */ + + ArrayList retrieveDefaultBatch(RetrieveDefaultParam defaultParam); + /** + * 新增一条视图对象的从(从)表数据。默认值规则与{@link #retrieveDefault(VoDefaultValue)}一致。 + * 新增从(从)表数据时,必须提供一个上级数据的Id,且这个Id所代表的上级数据必须存在。上级数据的Id将被赋值到从(从)表数据的ParentId字段上。 + * 如果上级数据不存在,将会引发编号为{@code GSP_ADP_BEF_2004}的{@link com.inspur.edp.bef.api.exceptions.BefException}异常。 + *
  • 1. 新增从表数据时,{@code nodeCodes}中要包含从表实体编号,{@code hierachyIds}中要包含主表数据的唯一标识; + *
  • 2.该方法不只支持新增从表数据,同样的也可以新增从从表数据。新增从从表数据时,{@code nodeCodes}中要包含从从表所属的从表实体编号, + * 以及从从表的实体编号,{@code hierachyIds}中要包括对应主表数据的唯一标识、子表数据的唯一标识。
+ *

+ * 下面通过一个例子说明{@code nodeCodes}和{@code hierachyIds}两个参数如何构造。 + *

+ * 假设有一个业务实体,其主表为A,节点编号为A,A下有从表B,节点编号为B,B下有从从表C,节点编号为C。 + *

+ * 如果需要新增一条B(从表)实体数据,此时两个参数分别应为: + *

  • {@code nodeCodes}:{@code ArrayList nodeCodes=new ArrayList();nodeCodes.add("B");} + *
  • {@code hierachyIds}:{@code ArrayList hierachyIds=new ArrayList();hierachyIds.add("A实体数据Id");}
+ *

+ * 如果需要新增一条C(从从表)实体数据,此时两个参数分别应为: + *

  • {@code nodeCodes}:{@code ArrayList nodeCodes=new ArrayList();nodeCodes.add("B");nodeCodes.add("C");} + *
  • {@code hierachyIds}:{@code ArrayList hierachyIds=new ArrayList();hierachyIds.add("A实体数据Id");hierachyIds.add("B实体数据Id");}
+ * 再下层的,以此类推 + * 此外,如果是生成型的VO元数据,在WebIde中点击生成代码菜单后,在生成的I{VO编号}Service接口中会针对每个从(从)表 + * 生成对应的新增方法。上述例子中,将在IAService接口中自动生成如下几个方法(实现也是自动生成的): + *
  • retrieveDefaultB(String aId); + *
  • retrieveDefaultB(String aId, String bId);
+ * 可以看到,使用这些生成的方法,参数更加清晰、使用不易犯错,因此对于生成型VO推荐使用自动生成的新增从(从)表方法。 + * + * @param nodeCodes 新增数据的从(从)表的实体编号列表 + * @param lierachyIds 新增从(从)表数据的所属实体数据的唯一标识列表 + * @return 新增的视图对象从(从)表数据 + * + * @see IEntityData + */ + IEntityData retrieveDefaultChild(java.util.ArrayList nodeCodes, java.util.ArrayList lierachyIds); + + /** + * 根据指定的id新增一组视图对象的从(从)表数据。 + * 用法与{@link #retrieveDefaultChild(ArrayList, ArrayList)}基本一致,唯一的区别是{@link #retrieveDefaultChild(ArrayList, ArrayList)} + * 新增的数据的ID是自动生成的,而使用此方法可以通过第三个参数指定ID。需要注意指定的ID必须与已存在数据不同。 + * + * @param nodeCodes 要新增数据的从(从)表的实体编号列表 + * @param lierachyIds 新增从(从)表数据的所属实体数据的唯一标识列表 + * @param ids 新增从(从)表数据的所属实体数据的唯一标识列表 + * + * @return 新增的从(从)表实体数据列表 + * + * @see #retrieveDefaultChild(ArrayList, ArrayList) + * @see IEntityData + */ + ArrayList retrieveDefaultChild(java.util.ArrayList nodeCodes, java.util.ArrayList lierachyIds,ArrayList ids); + /** + * 使用指定的默认值新增一条视图对象的从(从)表数据。 + * 除了第三个参数外,其他用法与{@link #retrieveDefaultChild(ArrayList, ArrayList)}一致。 + * + * @param nodeCodes 要新增数据的从(从)表的实体编号 + * @param lierachyIds 新增从(从)表数据的所属实体数据的唯一标识 + * @param defaultValue 从(从)表新增数据使用的默认值, 其中不包含主键,详细信息可参考{@link #retrieveDefault(VoDefaultValue)} + * @return 新增的从(从)表实体数据 + * + * @see #retrieveDefaultChild(ArrayList, ArrayList) + * @see IEntityData + */ + IEntityData retrieveDefaultChild(java.util.ArrayList nodeCodes, java.util.ArrayList lierachyIds, VoDefaultValue defaultValue); + + + /** + * 使用指定的默认值新增一组视图对象的从(从)表数据。 + * 除了第三个参数外,其他用法与{@link #retrieveDefaultChild(ArrayList, ArrayList)}一致。 + * + * @param nodeCodes 要新增数据的从(从)表的实体编号 + * @param lierachyIds 新增从(从)表数据的所属实体数据的唯一标识 + * @param defaultValue 从(从)表新增数据使用的默认值, 其中不包含主键,详细信息可参考{@link #retrieveDefault(VoDefaultValue)} + * @return 新增的从(从)表实体数据 + * + * @see #retrieveDefaultChild(ArrayList, ArrayList) + * @see IEntityData + */ + ArrayList retrieveDefaultChilds(java.util.ArrayList nodeCodes, java.util.ArrayList lierachyIds, ArrayList defaultValue); + + /** + * 使用指定的默认值批量新增视图对象的从(从)表数据。 + * 除了第三个参数外,其他用法与{@link #retrieveDefaultChild(ArrayList, ArrayList)}一致。 + * + * @param nodeCodes 新增数据的从(从)表的实体编号列表 + * @param lierachyIds 新增从(从)表数据的所属实体数据的唯一标识列表 + * @param param 从(从)表新增数据使用的默认值, 其中不包含主键,详细信息可参考{@link #retrieveDefaultBatch(RetrieveDefaultParam)} + * @return 新增的从(从)表视图对象实体数据列表 + * + * @see #retrieveDefaultChild(ArrayList, ArrayList) + * @see IEntityData + */ + ArrayList retrieveDefaultChild(java.util.ArrayList nodeCodes, java.util.ArrayList lierachyIds, + RetrieveDefaultParam param); + /** + * 使用不加锁的方式检索指定ID的实体数据,检索出来的数据带着所有的子表数据。 + *

注意,通过此方法检索得到的数据不应进行任何修改,强行修改可能导致异常,如需修改请使用{@link #modify(IChangeDetail)}。 + *

如需对检索行为进行更精细化的控制,请使用{@link #retrieve(String, RetrieveParam)} + * + * @param dataID 实体数据的唯一标识 + * @return 检索的返回结果,包含实体数据和加锁是否成功等,实体数据中带着所有子表数据信息,子表数据信息可从{@link IEntityData#getChilds()}的方法中获取 + * + * @see #retrieve(String, RetrieveParam) + */ + IEntityData retrieve(String dataID); + + /** + * 加锁并检索数据。如果加锁失败会抛出异常。 + * @param dataId + * @return 检索结果 + */ + EditResult edit(String dataId); + + /** + * 检索指定ID的视图对象主表数据,可指定是否加锁 + *

注意,如果加锁失败,此方法不会抛出异常,而是通过将返回值上的{@link RespectiveRetrieveResult#getLockFailed()}置为false代表加锁失败。 + *

注意,通过此方法检索得到的数据不应进行任何修改,强行修改可能导致异常,如需修改请使用{@link #modify(IChangeDetail)}。 + *

如果希望在加锁失败后抛出异常以中止后续代码逻辑,应使用{@link #edit(String)}方法,或增加逻辑进行判断。 + *

在自定义动作中执行实体动作前通常需要先进行检索,如果实体动作中可能修改数据, + * 那么推荐使用{@link #edit(String)}方法进行加锁并检索,而不是retrieve方法。 + * 因为{@code retrieve}方法默认不进行加锁这一点容易被开发人员忽略,同时也不容易通过测试发现问题。 + * + * @param dataId 实体数据的唯一标识 + * @param retrieveParam 检索参数 + * @return 检索的返回结果 + * + * @see #edit(String) + */ + IEntityData retrieve(String dataId, RetrieveParam retrieveParam); + + /** + * 检索一组指定ID的视图对象主表数据,加锁的方式可指定,检索参数可参考{@link #retrieve(String, RetrieveParam)} + *

注意,通过此方法检索得到的数据不应进行任何修改,强行修改可能导致异常,如需修改请使用{@link #modify(IChangeDetail)}。 + * + * @param dataIds 一组实体数据的唯一标识 + * @param retrieveParam 检索参数 + * @return 检索的返回结果 + */ + java.util.List retrieve(java.util.ArrayList dataIds,RetrieveParam retrieveParam); + + /** + * 检索指定ID的视图对象主表数据,加锁的方式可指定检索,检索参数可参考{@link #retrieve(String, RetrieveParam)} + *

注意,通过此方法检索得到的数据不应进行任何修改,强行修改可能导致异常,如需修改请使用{@link #modify(IChangeDetail)}。 + * + * 下面通过一个例子说明{@code nodeCodes}和{@code hierachyIds}两个参数如何构造。 + *

+ * 假设有一个业务实体,其主表为A,节点编号为A,A下有从表B,节点编号为B,B下有从从表C,节点编号为C。 + *

+ * 如果需要检索一条B(从表)实体数据,此时两个参数分别应为: + *

  • {@code nodeCodes}:{@code ArrayList nodeCodes=new ArrayList();nodeCodes.add("B");} + *
  • {@code lierachyIds}:{@code ArrayList lierachyIds=new ArrayList();lierachyIds.add("A实体数据Id");}
+ *

+ * 如果需要检索一条C(从从表)实体数据,此时两个参数分别应为: + *

  • {@code nodeCodes}:{@code ArrayList nodeCodes=new ArrayList();nodeCodes.add("B");nodeCodes.add("C");} + *
  • {@code IdsachyIds}:{@code ArrayList lierachyIds=new ArrayList();lierachyIds.add("A实体数据Id");lierachyIds.add("B实体数据Id");}
+ * 再下层的,以此类推 + * @param nodeCodes 检索数据的从(从)表的实体编号列表 + * @param lierachyIds 检索从(从)表数据的所属实体数据的唯一标识列表 + * @param retrieveParam 检索参数 + * @return 检索的返回结果 + */ + IEntityData retrieveChild(java.util.ArrayList nodeCodes, java.util.ArrayList lierachyIds, RetrieveParam retrieveParam); + + /** + * 检索一组指定ID的视图对象主表数据,根据参数{@code ids}参数确认个数,可指定加锁方式 + * + *其余参数可参考{@link #retrieveChild(ArrayList, ArrayList, RetrieveParam)} + * + * @param nodeCodes 检索数据的从(从)表的实体编号列表 + * @param lierachyIds 检索从(从)表数据的所属实体数据的唯一标识列表 + * @param ids 要检索数据从表或从从表的数据id列表 + * @param retrieveParam 检索参数 + * @return + */ + ArrayList retrieveChild(java.util.ArrayList nodeCodes, java.util.ArrayList lierachyIds, ArrayList ids,RetrieveParam retrieveParam); + + /** + * 将业务实体数据的变更集提交到内存。若想将变更集提交到数据库,需要在调用Modify方法之后,再调用Save方法。 + *

使用变更集既可以修改主表数据,也可以修改从(从)表数据。 + *

变更集的构造方法可以点击这里查看。 + * + * @param change 实体数据的变更集 + */ + void modify(IChangeDetail change); + + /** + * 根据过滤条件查询视图对象主表数据。 + * + *

该方法不会对数据进行加锁(相比{@link #retrieve(String, RetrieveParam)})。 + *

返回结果不包含任何子表数据,也不包含未持久化的修改。 + *

数据量过大时可能导致性能问题,建议使用带过滤条件的{@link #query(EntityFilter)}方法进行查询。 + *

对查询结果进行任何修改都{@code 不会}被持久化,如需修改数据请使用{@link #modify(IChangeDetail)}。 + * + * @return 业务实体主表数据集合,不含任何子表 + * + * @see QueryResult + */ + QueryResult query(EntityFilter filter); + /** + * 根据过滤条件查询视图对象子表数据。 + * + *

该方法不会对数据进行加锁(相比{@link #retrieve(String, RetrieveParam)})。 + *

返回结果不包含任何子表数据,也不包含未持久化的修改。 + *

数据量过大时可能导致性能问题,建议设置滤条件进行查询。 + *

对查询结果进行任何修改都{@code 不会}被持久化,如需修改数据请使用{@link #modify(IChangeDetail)}。 + * + * @param nodeCodes 节点编号列表,此处传值可参考{@link #retrieveChild(ArrayList, ArrayList, RetrieveParam)} + * @param filter 查询条件 + * @return 业务实体子表本身数据集合 + * + * @see QueryResult + */ + QueryResult queryChild(List nodeCodes,EntityFilter filter); + + /** + * 根据过滤条件查询视图对象子表数据。 + * + *

该方法不会对数据进行加锁(相比{@link #retrieve(String, RetrieveParam)})。 + *

返回结果不包含任何子表数据,也不包含未持久化的修改。 + *

数据量过大时可能导致性能问题,建议设置滤条件进行查询。 + *

对查询结果进行任何修改都{@code 不会}被持久化,如需修改数据请使用{@link #modify(IChangeDetail)}。 + * + * @param nodeCode 要查询的从表或者从从表等的节点编号 + * @param filter 查询条件 + * + * @return 业务实体子表本身数据集合 + * + * @see QueryResult + */ + QueryResult queryChild(String nodeCode,EntityFilter filter); + + QueryResult queryWithAuthInfo(EntityFilter filter, AuthInfo authInfo); + + /** + *暂未支持 + * @param param + * @param pageInfo + * @param extendCond + * @return + */ + java.util.List query(String param, Pagination pageInfo, String extendCond); + + /** + * 将指定ID的业务实体数据的删除变更集提交到内存。若需要将该删除变更集提交到数据库,需要在调用{@link #delete(String)}方法后,再调用{@link #save()}方法。 + * + * @param dataID 实体数据的唯一标识 + */ + void delete(String dataID); + + /** + * 批量将指定ID的业务实体数据的删除变更集提交到内存。若需要将该删除变更集提交到数据库,需要在调用{@link #delete(String)}方法后,再调用{@link #save()}方法。 + * + * @param dataIds 实体数据的唯一标识的集合 + */ + void delete(java.util.ArrayList dataIds); + + /** + * 将指定ID的业务实体数据的删除变更集提交到内存,并调用用{@link #save()}方法,将该删除变更集提交到数据库。 + * + * @param dataID 实体数据的唯一标识 + */ + void deleteAndSave(String dataID); + + /** + * 删除从(从)表数据 + * + * 参数nodeCodes、hierachyIdLis设置可参考{@link #retrieveChild(ArrayList, ArrayList, RetrieveParam)}方法中的nodeCodes以及lierachyIds参数设置 + * @param nodeCodes 要删除数据的从(从)表的实体编号列表 + * @param hierachyIdList 要删除数据的从(从)表的所属实体数据的唯一标识列表 + * @param ids 要删除的从(从)表数据的唯一标识列表 + */ + void deleteChild(java.util.List nodeCodes, java.util.List hierachyIdList, java.util.List ids); + + /** + * 保存数据:将服务器端的变更数据保存到数据库中。 + */ + void save(); + + /** + * 创建视图对象的主对象数据实例 + * + * @return 创建的视图对象的主表数据实例 + * + * @see IEntityData + */ + IEntityData createData(); + + /** + * 创建新的视图对象的子对象数据实例。 + * + * @param childCode 子表对象节点编号 + * @return 创建的视图对象的子对象数据实例。 + * + * @see IEntityData + */ + IEntityData createData(String childCode); + + /** + * 根据指定的帮助查询参数获取帮助数据 + * + * @param codeName 设有帮助字段的视图对象的节点编号 + * @param labelId 帮助字段标签 + * @param queryParam 帮助查询参数 + * @return 查询获取到的帮助数据。 + * + * @see LookupResult + */ + LookupResult getElementHelp(String codeName, String labelId, String queryParam); + + /** + * 根据指定的帮助查询参数获取帮助数据 + * + * @param codeName 设有帮助字段的视图对象的节点编号 + * @param labelId 帮助字段标签 + * @param queryParam 帮助查询参数 + * @return 查询获取到的帮助数据 + * + * @see LookupResult + */ + LookupResult getElementHelp(String codeName, String labelId, LookupQueryParam queryParam); + + /** + * 获取默认值类类型 + */ + java.lang.Class getDefaultValueType(); + + /** + * 获取变更集类类型 + */ + java.lang.Class getChangeInfoType(); + + /** + * 获取请求类类型 + */ + java.lang.Class getRequsetType(); + + + /** + * 将客户端发起的请求json反序列化RequestInfo对象 + * + * @param requestStr 客户端发起的请求json串 + * @param contex 序列化反序列化上下文 + * @return 反序列化后的请求实体 + * + * @see RequestInfo + */ + RequestInfo buildRequest(String requestStr, CefSerializeContext contex); + /** + * 对于客户端的请求,创建相应的响应信息对象 + * + * @return 返回响应的信息 + * + * @see ResponseInfo + */ + ResponseInfo createResponse(); + + /** + * 处理客户端发起的请求 + * @param request 客户端发起的请求{@link ResponseInfo}对象 + */ + void dealRequest(RequestInfo request); + + /** + * 处理视图对象上设置的变量的变更集 + * + * @param change 变量变更信息 + *

变更集的构造方法可以点击这里查看。 + * @see IChangeDetail + */ + void dealVariable(IChangeDetail change); + + /** + * 构造响应信息 + * + * @param returnValue 服务端返回的响应信息 + * @return 服务端响应实体信息 + * + * @see ResponseInfo + */ + ResponseInfo buildResponse(Object returnValue); + + /** + * 创建变量管理类 + * + * @return 变量管理接口实例 + * + * @see IVariableManager + */ + IVariableManager createVariableManager(); + + /** + * 国际化资源 + * + *

可以通过{@link ModelResInfo}拿到想要的国际化资源项 + * @return 国际化资源信息 + * + * @see ModelResInfo + * */ + ModelResInfo getModelInfo(); + + /** + * 根据检索条件获取到指定数据Id的数据 + * + * @param dataId 要检索的数据id + * @parm param 检索参数 + * @return 根据检索条件获取到的指定 + */ + RetrieveResult retrieveWithChildPagination(String dataId, com.inspur.edp.bff.api.param.retrieve.RetrieveParam param); + + /** + * 按索引检索子表 + * + * @param nodeCodes + * @param hierachyIds + * @param pagination + * @return + */ + RetrieveChildResult retrieveChildByIndex(ArrayList nodeCodes, ArrayList hierachyIds, Pagination pagination); + + /** + * 执行自定义动作 + * + * @param actionCode 动作编号 + * @param params 参数以及参数值字典,带有顺序 + * @return 返回执行动作后的值 + */ + Object executeCustomAction(String actionCode, LinkedHashMap params); + + /** + * 创建并保存一条数据,数据直接保存到数据库,并重新检索到缓存中。 + * + * @param data 空的视图对象实体数据 + * @return 新增保存后的新数据 + *

内部重新调用{@link #retrieve(String)}方法,将数据从数据库检索出来,返回的{@link IEntityData}和数据库中保持一致。 + * @see IEntityData + */ + IEntityData createAndSave(IEntityData data); + + /** + * 修改并保存一条数据,数据直接保存到数据库,并重新检索到缓存中。 + * + * @param data 要修改的实体数据 + * @return 修改保存后的新数据 + *

内部重新调用{@link #retrieve(String)}方法,将数据从数据库检索出来,返回的{@link IEntityData}和数据库中保持一致。 + * @see IEntityData + */ + IEntityData modifyAndSave(IEntityData data); + + /** + * 批量删除数据,并保存 + * @param dataIds 要删除保存数据的集合 + */ + void deleteAndSave(ArrayList dataIds); + + /** + * 是否是解析型 + * @return 解析型的标识 + */ + boolean isEngine(); + + /** + * 序列化服务端响应 + * @param responseInf 服务端响应对象 + * @param contex 序列化反序列化上下文 + * @return 服务端响应的json结构 + */ + String serializeResponseInfo(ResponseInfo responseInf, CefSerializeContext contex); + + + /** + * 获取Headers + * @return + */ + List getAcceptHeaderNames(); + + /** + * 给Header赋值 + * @param name + * @param value + */ + void setHeader(String name, String value); + + /** + * 将vo变更集转换为be变更集 + * @param voChanges vo上的变更集 + * @return 转换后的be变更集集合 + */ + ArrayList convertChangefromVo(ArrayList voChanges); + + /** + * 将be变更集转换为vo变更集 + * @param sourceChanges be变更集 + * @return 转换后的vo变更集 + */ + ArrayList convertChange2Vo(ArrayList sourceChanges); + + /** + * 客户端发起请求,给当前session枷锁 + */ + void onBeforeRequest(); + + /** + * 释放当前session的锁 + */ + void onFinallyRequest(); + + /** + * 默认值集合{@link ArrayList}的反序列化 + * + *

返回后的默认值,详情可参考{@link #retrieveDefault(VoDefaultValue)}方法中的{@link VoDefaultValue} + * @param nodeCodes 视图对象的节点编号集合 + * @param nodeJson 默认值json结构 + * @return 反序列化后的默认值集合 + */ + ArrayList deserializeVoDefaultValues(List nodeCodes,String nodeJson); + + /** + * 单个{@link VoDefaultValue}默认值的反序列化 + * @param nodeCodes 视图对象的节点编号集合 + * @param nodeJson 默认值json结构 + * @return + */ + VoDefaultValue deserializeVoDefaultValue(List nodeCodes,String nodeJson); + + /** + * 视图对象主表默认值参数{@link RetrieveDefaultParam}的反序列化 + * + * @param nodeJson 默认值参数{@link RetrieveDefaultParam}json结构 + * @return 反序列化后的视图对象主表默认值参数 + * + * @see RetrieveDefaultParam + */ + RetrieveDefaultParam deserializerRetrieveDefaultParam(String nodeJson); + + /** + *视图对象从(从)表默认值参数{@link RetrieveDefaultParam}的反序列化 + * + * @param nodeCodes 视图对象的节点编号集合,该参数的设置规则可参考{@link #retrieveChild(ArrayList, ArrayList, RetrieveParam)}中的第一个参数设置 + * @param nodeJson 默认值参数{@link RetrieveDefaultParam}json结构 + * @return 反序列化后的视图对象从(从)表默认值参数 + * + * @see RetrieveDefaultParam + */ + RetrieveDefaultParam deserializerRetrieveDefaultParam(List nodeCodes,String nodeJson); + + /** + * 获取时间戳上下文 + * @return + */ + TimeStampContext getTimeStampContext(); + + /** + * 给时间戳上下文赋值 + * @param value + */ + void setTimeStampContext(TimeStampContext value); + + /** + * 分级码去重,支持权限过滤 + * @param fjnPropertyName 分级码字段标签 + * @param filter 过滤条件 + * @param parentLayer 父级级数 + * @param authInfo 权限信息 + * @return + */ + List getDistinctFJM(String fjnPropertyName, EntityFilter filter, Integer parentLayer,AuthInfo authInfo); +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/IFSManagerContext.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/IFSManagerContext.java new file mode 100644 index 0000000..2e9c14f --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/IFSManagerContext.java @@ -0,0 +1,315 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager; + +import com.inspur.edp.bef.api.lcp.IStandardLcp; +import com.inspur.edp.bff.api.dataprocessor.IChangeConvertor; +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.api.dataprocessor.IDefaultValueConvertor; +import com.inspur.edp.bff.api.dataprocessor.IEntityPropertyMapper; +import com.inspur.edp.bff.api.dataprocessor.IFilterFieldConvertor; +import com.inspur.edp.bff.api.manager.assembler.IAssemblerManager; +import com.inspur.edp.bff.api.manager.assembler.IChangeMapperAssembler; +import com.inspur.edp.bff.api.manager.assembler.IDataMapperAssembler; +import com.inspur.edp.bff.api.manager.assembler.IExtendDeleteAssembler; +import com.inspur.edp.bff.api.manager.assembler.IExtendModifyAssembler; +import com.inspur.edp.bff.api.manager.assembler.IExtendQueryAssembler; +import com.inspur.edp.bff.api.manager.assembler.IExtendRetrieveAssembler; +import com.inspur.edp.bff.api.manager.assembler.IExtendRetrieveDefaultAssembler; +import com.inspur.edp.bff.api.manager.assembler.IExtendSaveAssembler; +import com.inspur.edp.cef.spi.entity.resourceInfo.ModelResInfo; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import com.inspur.edp.cef.entity.entity.ICefData; +import com.inspur.edp.cef.entity.entity.IEntityData; +import com.inspur.edp.bff.api.extend.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.List; + +/** + * FSManager管理类上下文接口 + */ +public interface IFSManagerContext { + /** + * 获取当前的FSManager管理类实例 + * + * @return FSManager管理类实例 + * @see IFSManager + */ + IFSManager getBffManager(); + + /** + * 获取当前视图对象主表的数据源类型:{@link SourceType#Be},{@link SourceType#Qo}。 + * + * @return 当前视图对象主表的数据源类型 + * + * @see SourceType + */ + SourceType getMainSourceType(); + + /** + * 获取扩展动作管理类实例 + * + *

  • vo上扩展动作目前有:新增前,新增,新增后,检索前,检索,检索后,查询前,查询,查询后,修改前,修改,修改后,数据Mapping,数据反向mapping,变更集Mapping,变更集反向Mapping, + * 删除前/批量删除前,删除/批量删除,删除后/批量删除后,保存前,保存后等);分为8大类:新增,检索,查询,修改,数据Mapping,变更集Mapping,删除,保存等,23个动作。 + *
  • 新增管理类{@link IExtendRetrieveDefaultAssembler}; + *
  • 检索管理类{@link IExtendRetrieveAssembler}; + *
  • 查询管理类{@link IExtendQueryAssembler}; + *
  • 修改管理类{@link IExtendModifyAssembler} + *
  • 删除管理类{@link IExtendDeleteAssembler}; + *
  • 变更集管理类{@link IChangeMapperAssembler}; + *
  • 数据映射管理类{@link IDataMapperAssembler};
+ * @return 返回扩展动的管理器实例 + * + * @see IAssemblerManager + */ + + IAssemblerManager getAssemblerManager(); + + /** + * 判断保存状态,是否是保存前状态 + * @return + */ + boolean getIsBeforeSaving(); + + /** + * 获取BEF 的Lcp(Local Consumer Proxy,本地消费者代理),通常说的{@link IStandardLcp} + *

这里说的lcp指的是根据后端BE创建的VO才会获取到,虚拟VO是没有其对应的lcp的,虚拟VO的逻辑需要开发人员按照VO上的扩展动作实现其CURD + * + * @return 得到的BE的LCP + */ + IStandardLcp getLcp(); + + /** + * 获取一组lcp的实例,key对应的是be的功能标识:configid,详情可参考{@link IFSManagerFactory}介绍;value对应的是vo对应的be的本地服务代理lcp:{@link IStandardLcp}。 + *

通常该方法会在组合vo中应用,组合vo中由多个vo组装而成,每个vo对应的be是不同的,因此在这种情况,会根据不同的vo取对应的be实现CURD。 + * @return + */ + HashMap getLcps(); + + /** + * 是否启用权限 + * @param useAuth 启用权限参数 + */ + void setUseAuth(boolean useAuth); + + /** + * 获取一组数据源的配置信息,数据源类型包括:{@link SourceType#Be},{@link SourceType#Qo} + * @return 一组数据源的配置信息 + */ + ArrayList getSourceConfigs(); + + /** + * 获取变更集转换器,将vo变更集转换为be变更集 + * + * @return 得到的变更转换器实例。 + * + * @see IChangeDetail + */ + IChangeConvertor getChangeConvertor(); + + /** + * + * @return + */ + IEntityPropertyMapper getRootEntityPropertyMapper(); + + /** + * 获取数据转换器,将vo数据转换为be数据。 + * @return 得到的数据转换器 + * + * @see IDataConvertor + */ + IDataConvertor getDataConvertor(); + + /** + * 过滤条件转换器 + * + * @return 当前vo上的过滤条件转换器 + * + * @see IFilterFieldConvertor + */ + IFilterFieldConvertor getFilterConvertor(); + /** + * 获取默认值转换器 + + * @return 当前vo上的默认值转换器 + * + * @see IDefaultValueConvertor + */ + IDefaultValueConvertor getDefaultValueConvertor(); + /** + * 执行自定义操作,返回操作执行结果。 + * + * @param action 要执行的操作实例 + * @return 得到的操作执行结果 + */ + TResult executeAction(IFSAction action); + + /** + * 执行自定义操作,返回操作执行结果。 + * @param action 执行的动作类实例 + * @param actionId 动作id + * @param actionCode 动作编号 + * @param parameters 参数 + * @param autoSave 是否自动保存 + * @param 得到的操作执行结果 + * @return + */ + TResult executeAction(IFSAction action ,String actionId, String actionCode + , Map parameters,boolean autoSave); + /** + * 执行自定义操作,返回操作执行结果。 + * @param action 执行的动作类实例 + * @param actionId 动作id + * @param actionCode 动作编号 + * @param parameters 参数 + * @param 得到的操作执行结果 + * @return + */ + TResult executeAction(IFSAction action ,String actionId, String actionCode + , Map parameters); + + void processResponse(); + /** + * 创建新的视图对象主对象实体数据实例。 + * + * @return 新的视图对象实体数据实例 + * + * @see IEntityData + */ + IEntityData createData(); + + /** + * 新的视图对象子对象实体数据实例 + * @param objectCode 子对象编号 + * + @return 得到的视图对象子对象实体数据实例 + */ + IEntityData createData(String objectCode); + + /** + * 获取与BE对应的VM对象编号。 + * + * @param beObjectCode BE对象编号 + * @return 得到的VM对象编号 + */ + String getVMCodeFromBE(String beObjectCode); + + /** + * 获取与VM对应的BE对象编号 + * + * @param vmObjectCode VM对象编号 + * @return 对应的BE对象编号 + */ + String getBECodeFromVM(String vmObjectCode); + + /** + * 获取vo元数据id + * @return + */ + String getVoId(); + + /** + * + * @param value + */ + void setVoId(String value); + + /** + * 获取变量实体数据 + * @return 当前vo上的变量实体数据 + * + * @see ICefData + */ + ICefData getVariableData(); + + /** + * 获取变量内部变更 + * @return + * + * @see IChangeDetail + */ + IChangeDetail getVariableInnerChange(); + + /** + * 获取与VM对应的前端编号 + * @param frontVoCode + * @return 得到的VM对象编号 + */ + String getVoCode(String frontVoCode); + + /** + * 国际化资源项 + * + * @return + * + * @see ModelResInfo + */ + ModelResInfo getModelResourceInfo(); + + /** + *翻译后的实体名称 + * + * @param nodeCode 视图对象节点编号 + * @return 国际化实体名称 + */ + String getEntityI18NName(String nodeCode); + /** + * 翻译后的属性名称 + * + * @param nodeCode 视图对象节点编号 + * @param labelID 属性字段的标签 + * @return 国际化属性名称 + */ + String getPropertyI18NName(String nodeCode, String labelID); + /** + * 翻译后的关联带出字段名称 + * + * @param nodeCode 视图对象节点编号 + * @param labelID 属性字段的标签 + * @param refLabelID 关联属性字段的标签 + * @return 国际化关联带出字段名称 + */ + String getRefPropertyI18NName(String nodeCode, String labelID, String refLabelID); + /** + * 翻译后的枚举显示值 + * + * @param nodeCode 视图对象节点编号 + * @param labelID 属性字段的标签 + * @param enumKey 枚举值 + * @return 国际化枚举值 + */ + String getEnumValueI18NDisplayName(String nodeCode, String labelID, String enumKey); + /** + * 翻译后的唯一性约束提示信息 + * @param conCode 视图对象节点编号 + * @param nodeCode 唯一性约束编号 + * @return + */ + String getUniqueConstraintMessage(String nodeCode, String conCode); + + /** + * 获取VO运行时定制扩展接口类 + * + * @return + * + * @see IBffManagerExtend + */ + List getExtList(); +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/IFSManagerFactory.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/IFSManagerFactory.java new file mode 100644 index 0000000..cc46b39 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/IFSManagerFactory.java @@ -0,0 +1,104 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager; + +/** + * FSManager工厂接口,提供了创建FSManager的几种方式。 + *

此接口中的方法大部分需要提供configId参数。下面简单介绍一下configId: + *

  • configId是一个VO元数据的唯一标识,除一些非常早期版本的VO元数据外,一般为元数据命名空间+元数据编号的形式,如com.inspur.gs.xxx.vo.xxx; + *
  • VO元数据作为一个元数据,本身也有一个UUID形式的元数据ID,这个ID也是唯一的,configId与元数据ID的主要区别在于configId更具可读性, + * 此接口中也有一些成对的方法,功能一致但参数分别为元数据Id和configId; + *
  • 如果你需要创建一个不是你开发的VO的Lcp方法时,需要提供的configId或元数据Id应向VO元数据的开发人员索要; + *
  • 如果你是VO的开发人员,你被询问VO元数据的configId是什么时,VO设计器上提供了属性显示当前BE的configId,你可以从中复制出来发给对方。
+ *

下面是此接口的一个常见用法: + *

+ *     IFsManager manager = SpringBeanUtils.getBean(IFSManagerFactory.class).getFSManager("xxx");
+ *     manager.retrieve("xxx");
+ * 
+ *

如果此类的方法报错,大部分原因都是因为所调用的VO未正确部署,详细的排查方法可以点击这里查看 + */ +public interface IFSManagerFactory { + + /** + * 根据功能标识configid创建FSManager。 + *

+ * 功能与{@link #getFSManagerByVOId(String)}一致,仅参数不同。 + * + * @param fsType VO的配置标识:configid + * @return 本地消费代理接口 + * + * @see IFSManager + * @see #getFSManagerByVOId(String) + */ + IFSManager getFSManager(String fsType); + + /** + * 根据元数据ID创建FSManager。 + *

+ * 功能与{@link #getFSManager(String)}一致,仅参数不同。 + * + * @param voId VO元数据ID + * @return 本地消费代理接口 + * + * @see IFSManager + * @see #getFSManager(String) + */ + IFSManager getFSManagerByVOId(String voId); + + /** + * 根据元数据ID创建FSManager。 + *

+ * 功能与{@link #getFSManager(String)}一致,仅参数不同。 + * + * @param voId VO元数据ID + * @return 本地消费代理接口 + * + * 目前仅适用于业务流FSManager的创建 + * @see IFSManager + * @see #getFSManager(String) + */ + IFSManager getFSManagerByVOIDIgnoreProcessCode(String voId); + /** + 连接,创建功能Session实例。 + + @param fsType VO功能标识:configid + @param parentFuncSessionID 父功能SessionID + @return 得到的新功能SessionID + */ + String connect(String fsType, String parentFuncSessionID); + /** + 连接,创建功能Session实例。 + + @param fsType VO功能标识:configid + @return 得到的新功能SessionID + */ + String connect(String fsType); + //void tryConnect(); + + /** + * 根据配置Id和sessionId创建Lcp + * @deprecated 应使用 {@link #getFSManager(String)} (String)}或 {@link #getFSManagerByVOId(String)} (String)} + * + * @param fsType VO的配置标识:configid + * @param funcSessionID 功能sessionId + * @return 本地消费代理接口 + * + * @see #getFSManager(String) (String) + * @see #getFSManagerByVOId(String) (String) + */ + IFSManager getFSManager(String fsType, String funcSessionID); +} -- Gitee From 73510d3f66ffadc8cfdf8ae02a06791e90f372a3 Mon Sep 17 00:00:00 2001 From: Jakeem Date: Tue, 25 Oct 2022 17:28:22 +0800 Subject: [PATCH 09/81] =?UTF-8?q?=E5=88=9B=E5=BB=BAbff-framework-spi?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bff-framework-spi/bff-framework-spi.iml | 192 ++++++++++++++++++++++++ bff-framework-spi/pom.xml | 85 +++++++++++ 2 files changed, 277 insertions(+) create mode 100644 bff-framework-spi/bff-framework-spi.iml create mode 100644 bff-framework-spi/pom.xml diff --git a/bff-framework-spi/bff-framework-spi.iml b/bff-framework-spi/bff-framework-spi.iml new file mode 100644 index 0000000..5fc4aec --- /dev/null +++ b/bff-framework-spi/bff-framework-spi.iml @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bff-framework-spi/pom.xml b/bff-framework-spi/pom.xml new file mode 100644 index 0000000..55885f7 --- /dev/null +++ b/bff-framework-spi/pom.xml @@ -0,0 +1,85 @@ + + + 4.0.0 + + com.inspur.edp + bff-framework-spi + 0.1.1 + + + + + maven-source-plugin + + + attach-sources + + jar + + + + + + + + + com.inspur.edp + bff-api + ${project.version} + + + + org.springframework + spring-core + 5.1.8.RELEASE + + + com.inspur.edp + bff-entity + ${project.version} + compile + + + com.inspur.edp + cef-spi + + + com.inspur.edp + cef-gencommon + + + com.inspur.edp + cef-variable-api + + + com.inspur.edp + lcm-metadata-api + + + io.iec.edp + caf-boot-commons-json + 0.3.4 + + + com.inspur.edp + cef-designtime-api + 0.2.14 + + + com.inspur.edp + bef-spi + + + com.inspur.edp + formserver-viewmodel + 0.2.13 + + + com.inspur.edp + debugtool-api + 0.1.4 + + + -- Gitee From 6e6e0ae990c78827b9b04ac524147486d9d313f5 Mon Sep 17 00:00:00 2001 From: Jakeem Date: Wed, 26 Oct 2022 07:49:22 +0800 Subject: [PATCH 10/81] =?UTF-8?q?1.=20=E6=B7=BB=E5=8A=A0=E4=BA=86changeMap?= =?UTF-8?q?ping=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../changemapping/ChangeMappingAction.java | 34 ++++++ .../ChangeReversalMappingAction.java | 34 ++++++ .../changemapping/DefaultChangeMapAction.java | 87 +++++++++++++++ .../DefaultChangeReversalAction.java | 55 ++++++++++ .../DefaultMessageMapAction.java | 100 ++++++++++++++++++ .../changemapping/MessageMappingAction.java | 35 ++++++ 6 files changed, 345 insertions(+) create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/ChangeMappingAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/ChangeReversalMappingAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/DefaultChangeMapAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/DefaultChangeReversalAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/DefaultMessageMapAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/MessageMappingAction.java diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/ChangeMappingAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/ChangeMappingAction.java new file mode 100644 index 0000000..db15ce2 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/ChangeMappingAction.java @@ -0,0 +1,34 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.changemapping; + +import com.inspur.edp.bff.api.manager.context.ChangeMapperContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class ChangeMappingAction extends AbstractFSAction { + private ChangeMapperContext mapContext; + protected final ChangeMapperContext getMapContext() + { + return mapContext; + } + + protected ChangeMappingAction(ChangeMapperContext context) + { + mapContext = context; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/ChangeReversalMappingAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/ChangeReversalMappingAction.java new file mode 100644 index 0000000..0d8e5fd --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/ChangeReversalMappingAction.java @@ -0,0 +1,34 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.changemapping; + +import com.inspur.edp.bff.api.manager.context.ChangeMapperContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class ChangeReversalMappingAction extends AbstractFSAction { + private ChangeMapperContext mapperContext; + protected final ChangeMapperContext getMapContext() + { + return mapperContext; + } + + protected ChangeReversalMappingAction(ChangeMapperContext context) + { + mapperContext = context; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/DefaultChangeMapAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/DefaultChangeMapAction.java new file mode 100644 index 0000000..b831570 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/DefaultChangeMapAction.java @@ -0,0 +1,87 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.changemapping; + +import com.inspur.edp.bef.api.lcp.IStandardLcp; +import com.inspur.edp.bff.api.dataprocessor.IChangeConvertor; +import com.inspur.edp.bff.api.manager.context.ChangeMapperContext; +import com.inspur.edp.bff.spi.utils.BffActionNames; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import com.inspur.edp.cef.entity.changeset.ModifyChangeDetail; +import lombok.var; + +import java.util.ArrayList; +import java.util.HashMap; + +public class DefaultChangeMapAction extends ChangeMappingAction { + + public DefaultChangeMapAction(ChangeMapperContext context) { + super(context); + } + + @Override + protected void execute() { + if (getMapContext().getInnerChange() == null || getMapContext().getInnerChange().size() < 1) { + return; + } + java.util.ArrayList defaultChanges = null; + if (getMapContext().getInnerChange().containsKey(BffActionNames.DefaultName)) { + defaultChanges = getMapContext().getInnerChange().get(BffActionNames.DefaultName); + } else { + for (ArrayList changes : getMapContext().getInnerChange().values()) { + defaultChanges = changes; + break; + } + } + + //TODO 临时处理 + + HashMap lcps = getContext().getLcps(); + java.util.ArrayList dataIds = new java.util.ArrayList(); + if (lcps != null && lcps.size() > 0) { + + for (IStandardLcp lcp : lcps.values()) { + dataIds.addAll(lcp.getDataIds()); + } + } + + if (defaultChanges == null) { + return; + } + + IChangeConvertor changeConvertor = getContext().getChangeConvertor(); + + for (IChangeDetail defaultChange : defaultChanges) { + if (dataIds.size() > 0 && dataIds.contains(defaultChange.getDataID())) { + + IChangeDetail voChange = changeConvertor.convertFromBEChange(defaultChange); + getMapContext().getTargetChange().add(voChange); + + dealExtendMapping(voChange, defaultChange); + } + } + } + + private void dealExtendMapping(IChangeDetail voChange, IChangeDetail beChange){ + var extList = getContext().getExtList(); + if(extList == null || extList.size() < 1) + return ; + for (var ext : extList){ + ext.mapChange2Vo((ModifyChangeDetail)voChange, (ModifyChangeDetail)beChange); + } + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/DefaultChangeReversalAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/DefaultChangeReversalAction.java new file mode 100644 index 0000000..7838e38 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/DefaultChangeReversalAction.java @@ -0,0 +1,55 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.changemapping; + +import com.inspur.edp.bff.api.dataprocessor.IChangeConvertor; +import com.inspur.edp.bff.api.manager.context.ChangeMapperContext; +import com.inspur.edp.bff.spi.utils.BffActionNames; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import com.inspur.edp.cef.entity.changeset.ModifyChangeDetail; +import lombok.var; + +public class DefaultChangeReversalAction extends ChangeReversalMappingAction{ + + public DefaultChangeReversalAction(ChangeMapperContext context) + { + super(context); + } + + @Override + protected void execute() + { + + IChangeConvertor changeConvertor = getContext().getChangeConvertor(); + if(changeConvertor == null){ + throw new RuntimeException("未找到变更集转换器,请确认是否需要设置扩展变更集反向映射操作。"); + } + IChangeDetail voChange = getMapContext().getSourceChange().get(0); + IChangeDetail beChange = changeConvertor.convertFromVMChange(voChange); + dealExtendMapping(voChange, beChange); + getMapContext().getMappedChange().put(BffActionNames.DefaultName, new java.util.ArrayList(java.util.Arrays.asList(new IChangeDetail[] { beChange }))); + } + + private void dealExtendMapping(IChangeDetail voChange, IChangeDetail beChange){ + var extList = getContext().getExtList(); + if(extList == null || extList.size() < 1) + return ; + for (var ext : extList){ + ext.mapChangeFromVo((ModifyChangeDetail)voChange, (ModifyChangeDetail)beChange); + } + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/DefaultMessageMapAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/DefaultMessageMapAction.java new file mode 100644 index 0000000..28c98ae --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/DefaultMessageMapAction.java @@ -0,0 +1,100 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.changemapping; + +import com.inspur.edp.bef.api.lcp.IStandardLcp; +import com.inspur.edp.bff.api.dataprocessor.IChangeConvertor; +import com.inspur.edp.bff.api.dataprocessor.IEntityPropertyMapper; +import com.inspur.edp.bff.api.manager.context.MessageMapperContext; +import com.inspur.edp.cef.api.message.BizMessage; +import com.inspur.edp.cef.api.message.IBizMessage; +import com.inspur.edp.cef.api.message.MessageLocation; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class DefaultMessageMapAction extends MessageMappingAction { + + public DefaultMessageMapAction(MessageMapperContext context) { + super(context); + } + + @Override + protected void execute() { + if (getMapContext().getSourceMessage() == null) { + return; + } + IEntityPropertyMapper rootMapper = getContext().getRootEntityPropertyMapper(); + if (rootMapper == null) { + return; + } + + List defaultMessages = null; + for (Map.Entry> pair : getMapContext().getSourceMessage() + .entrySet()) { + if (pair.getValue() == null || pair.getValue().isEmpty()) { + continue; + } + + final String beType = + "Default".equals(pair.getKey()) ? rootMapper.getBEInfo().getBEType() : pair.getKey(); + + for (IBizMessage msg : pair.getValue()) { + if (msg.getLocation() == null) { + getMapContext().getTargetMessage().add(msg); + continue; + } + + IEntityPropertyMapper mapper = rootMapper + .getMapperByBECode(beType, msg.getLocation().getNodeCode()); + if (mapper == null) { + continue; + } + BizMessage targetMsg = new BizMessage() {{ + setLevel(msg.getLevel()); + setMessageFormat(msg.getMessageFormat()); + setMessageParams(msg.getMessageParams()); + setException(msg.getException()); + setLocation(new MessageLocation()); + }}; + targetMsg.getLocation().setNodeCode(mapper.getVOCode()); + if (msg.getLocation().getDataIds() != null) { + targetMsg.getLocation().setDataIds(new ArrayList<>(msg.getLocation().getDataIds())); + } + if (msg.getLocation().getColumnNames() != null) { + targetMsg.getLocation().setColumnNames(msg.getLocation().getColumnNames().stream() + .map(col -> mapper.getVOPropertyNameFromBE(beType, col)).collect( + Collectors.toList())); + } + //TODO: 运行时定制暂不支持 + //dealExtendMapping(voChange, defaultChange); + getMapContext().getTargetMessage().add(targetMsg); + } + } + } + +// private void dealExtendMapping(IChangeDetail voChange, IChangeDetail beChange){ +// var extList = getContext().getExtList(); +// if(extList == null || extList.size() < 1) +// return ; +// for (var ext : extList){ +// ext.mapChange2Vo((ModifyChangeDetail)voChange, (ModifyChangeDetail)beChange); +// } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/MessageMappingAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/MessageMappingAction.java new file mode 100644 index 0000000..80537d7 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/changemapping/MessageMappingAction.java @@ -0,0 +1,35 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.changemapping; + +import com.inspur.edp.bff.api.manager.context.ChangeMapperContext; +import com.inspur.edp.bff.api.manager.context.MessageMapperContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class MessageMappingAction extends AbstractFSAction { + private MessageMapperContext mapContext; + protected final MessageMapperContext getMapContext() + { + return mapContext; + } + + protected MessageMappingAction(MessageMapperContext context) + { + mapContext = context; + } +} -- Gitee From 0f3703c1438ed0b86802d0f632ce2cb0799419ea Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Wed, 26 Oct 2022 08:56:58 +0800 Subject: [PATCH 11/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增新增默认值转换器接口 --- .../DefaultValueConvertorAttribute.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/DefaultValueConvertorAttribute.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/DefaultValueConvertorAttribute.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/DefaultValueConvertorAttribute.java new file mode 100644 index 0000000..f4b7daf --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/DefaultValueConvertorAttribute.java @@ -0,0 +1,38 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.attribute; + +import com.inspur.edp.bff.api.dataprocessor.IDefaultValueConvertor; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +public @interface DefaultValueConvertorAttribute { + /** + 转换器所属的类型,该类型必须实现{@link IDefaultValueConvertor}接口。 + + */ + Class convertorType(); + /** + 变更集类型 + + */ + Class entityType(); +} -- Gitee From 418f1f9db40d9c6109e0af3f066c2583d4226a4b Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Wed, 26 Oct 2022 09:52:20 +0800 Subject: [PATCH 12/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增查询服务接口 --- .../assembler/IExtendQueryAssembler.java | 34 +++++++++++++++++++ .../edp/bff/api/service/IQueryService.java | 24 +++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendQueryAssembler.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/service/IQueryService.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendQueryAssembler.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendQueryAssembler.java new file mode 100644 index 0000000..1045aa5 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendQueryAssembler.java @@ -0,0 +1,34 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.assembler; + +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.context.QueryContext; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.ArrayList; +import java.util.HashMap; + +public interface IExtendQueryAssembler { + + void doBeforeQuery(IFSManagerContext context, QueryContext queryContext); + + HashMap> doQuery(IFSManagerContext context, QueryContext queryContext); + + void doAfterQuery(IFSManagerContext context, QueryContext queryContext); + +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/service/IQueryService.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/service/IQueryService.java new file mode 100644 index 0000000..7cfab2a --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/service/IQueryService.java @@ -0,0 +1,24 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.service; + +import com.inspur.edp.cef.entity.condition.EntityFilter; +import com.inspur.edp.cef.entity.entity.IEntityData; + +public interface IQueryService { + java.util.List Query(EntityFilter filter); +} -- Gitee From 94984a0362b2947f8ae49816f3b3c7ffe4fd7211 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Wed, 26 Oct 2022 10:33:35 +0800 Subject: [PATCH 13/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=98=A0=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增数据影视接口 --- .../api/dataprocessor/MapperBEEntityInfo.java | 38 +++++++++++++++++++ .../dataprocessor/MapperBEPropertyInfo.java | 37 ++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/MapperBEEntityInfo.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/MapperBEPropertyInfo.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/MapperBEEntityInfo.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/MapperBEEntityInfo.java new file mode 100644 index 0000000..1635567 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/MapperBEEntityInfo.java @@ -0,0 +1,38 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.dataprocessor; + + +public class MapperBEEntityInfo { + + public MapperBEEntityInfo(String beType, String beEntityCode) { + this.beType = beType; + this.beEntityCode = beEntityCode; + } + + private String beType; + + public String getBEType() { + return beType; + } + + private String beEntityCode; + + public String getBEEntityCode() { + return beEntityCode; + } +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/MapperBEPropertyInfo.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/MapperBEPropertyInfo.java new file mode 100644 index 0000000..7cae995 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/MapperBEPropertyInfo.java @@ -0,0 +1,37 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.dataprocessor; + +public class MapperBEPropertyInfo { + + public MapperBEPropertyInfo(String beType, String bePropertyName) { + this.beType = beType; + this.bePropertyName = bePropertyName; + } + + private String beType; + + public String getBEType() { + return beType; + } + + private String bePropertyName; + + public String getBEEntityCode() { + return bePropertyName; + } +} -- Gitee From c604745dccf5f8448bcf2d55aa57454d69e8e9e7 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Wed, 26 Oct 2022 14:28:53 +0800 Subject: [PATCH 14/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=98=A0=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增数据影视上下文接口 --- .../manager/context/DataMapperContext.java | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/DataMapperContext.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/DataMapperContext.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/DataMapperContext.java new file mode 100644 index 0000000..62c298c --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/DataMapperContext.java @@ -0,0 +1,112 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.context; + +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.ArrayList; +import java.util.HashMap; + +/** + * 数据Mapping以及数据反向Mapping上下文 + * 数据Mapping:将be数据结构转换为vo数据结构 + * 数据反向Mapping:将vo数据结构转换为be数据结构 + * 扩展动作执行顺序可参考:点击这里查看。 + */ +public class DataMapperContext { + + private HashMap> sourceData = new HashMap>(); + /** + * 数据源(Be,Qo等)数据集合 + * Key是数据源编号,内部默认Key值使用Default,开发时请注意不要使用该Key值,以免出现未知问题。 + * Value是数据源数据 + */ + public final HashMap> getSourceData() + { + return sourceData; + } + public final void setSourceData(HashMap> value) + { + sourceData = value; + } + + + + private HashMap> mappedData= new HashMap>(); + /** + * 映射结果集合 + * Key是数据源编号,内部默认Key值使用Default,开发时请注意不要使用该Key值,以免出现未知问题。 + * Value是数据源数据 + * + */ + public final HashMap> getMappedData() + { + return mappedData; + } + public final void setMappedData(HashMap> value) + { + mappedData = value; + } + + + private ArrayList targetResult = new ArrayList(); + /** + * Vo数据集,这里的数据指的是:经过数据映射之后,将{@link #getSourceData()}方法中获取的源数据转换为vo结构的数据集 + * + */ + public final ArrayList getTargetResult() + { + return targetResult; + } + public final void setTargetResult(ArrayList value) + { + targetResult = value; + } + + + private boolean privateIsNew= false; + + /** + * 判断数据是否是新增状态 + * @return + */ + public final boolean getIsNew() + { + return privateIsNew; + } + public final void setIsNew(boolean value) + { + privateIsNew = value; + } + + + private VoDefaultValue voDefaultValue; + + /** + * 获取外部以及实体上设置的默认值 + * @return + */ + public final VoDefaultValue getVoDefaultValue() + { + return voDefaultValue; + } + public final void setVoDefaultValue(VoDefaultValue value) + { + voDefaultValue = value; + } +} -- Gitee From adfa228849b05d09a10798896a8ae0173c141ded Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Wed, 26 Oct 2022 14:58:47 +0800 Subject: [PATCH 15/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E5=88=A0?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增删除上下文 --- .../api/manager/context/DeleteContext.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/DeleteContext.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/DeleteContext.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/DeleteContext.java new file mode 100644 index 0000000..9ec1b30 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/DeleteContext.java @@ -0,0 +1,45 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.context; + + +import lombok.Data; +import lombok.Value; + +import java.util.ArrayList; +import java.util.List; + +import java.util.ArrayList; + +/** + * 删除上下文 + * 在删除扩展动作中可以获取到删除的数据id集合 + * 扩展动作执行顺序可参考:点击这里查看。 + */ +@Data +public class DeleteContext { + private String dataId; + + private ArrayList dataIds; + + /** + * 获取删除的数据id集合 + * @return + */ + public ArrayList getDataIds(){return dataIds;} + public void setDataIds(ArrayList value){this.dataIds=value;} +} -- Gitee From 05d27502cc6c436aa1d0e2f070cfb91a9d9f8ad2 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Wed, 26 Oct 2022 15:15:37 +0800 Subject: [PATCH 16/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增变更集接口 --- .../api/dataprocessor/IChangeConvertor.java | 37 +++++++++++++++++++ .../assembler/IChangeMapperAssembler.java | 27 ++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IChangeConvertor.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IChangeMapperAssembler.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IChangeConvertor.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IChangeConvertor.java new file mode 100644 index 0000000..a10e99c --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IChangeConvertor.java @@ -0,0 +1,37 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.dataprocessor; + +import com.inspur.edp.cef.entity.changeset.IChangeDetail; + +public interface IChangeConvertor { + + /** + * 将BE变更集数据转换成VM变更集数据 + * + * @param beChanges BM变更集数据 + * @return 转换之后的VM变更集数据 + */ + IChangeDetail convertFromBEChange(IChangeDetail beChanges); + /** + * 将VM变更集数据转换成BE变更集数据 + * + * @param vmChanges VM变更集数据 + * @return 转换之后的BE变更集数据 + */ + IChangeDetail convertFromVMChange(IChangeDetail vmChanges); +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IChangeMapperAssembler.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IChangeMapperAssembler.java new file mode 100644 index 0000000..eb91909 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IChangeMapperAssembler.java @@ -0,0 +1,27 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.assembler; + +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.context.ChangeMapperContext; + +public interface IChangeMapperAssembler { + + void doChangeMappingFromVo(IFSManagerContext context, ChangeMapperContext mappingContext); + + void doChangeMapping2Vo(IFSManagerContext context, ChangeMapperContext mappingContext); +} -- Gitee From 17d9c49f177efbd0daa282df62971e18229c92c1 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Wed, 26 Oct 2022 17:01:23 +0800 Subject: [PATCH 17/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增数据转换接口 --- .../bff/api/dataprocessor/IDataConvertor.java | 51 +++++++++++++++++++ .../assembler/IDataMapperAssembler.java | 30 +++++++++++ 2 files changed, 81 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IDataConvertor.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IDataMapperAssembler.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IDataConvertor.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IDataConvertor.java new file mode 100644 index 0000000..24a83c5 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IDataConvertor.java @@ -0,0 +1,51 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.dataprocessor; + +import com.inspur.edp.cef.entity.entity.ICefData; +import com.inspur.edp.cef.entity.entity.IEntityData; + +public interface IDataConvertor { + + /** + * 将BE数据转换成VM数据 + * @param beData BE数据 + * @param vmData VM数据 + */ + void convertFromBEData(IEntityData beData, IEntityData vmData); + /** + * 将VM数据转换成BE数据 + * @param vmData VM数据 + * @param beData BE数据 + */ + void convertFromVMData(IEntityData vmData, IEntityData beData); + + /** + * 将BE数据转换成VM数据 + * @param sourceData BE数据 + * @param vmData VM数据 + */ + void convertFromSourceData(ICefData sourceData, IEntityData vmData); + /** + * 将VM数据转换成BE数据 + * @param vmData VM数据 + * @param sourceData BE数据 + */ + void convert2SourceData(IEntityData vmData, ICefData sourceData); + + IDataConvertor getChildConvertor(String childCode); +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IDataMapperAssembler.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IDataMapperAssembler.java new file mode 100644 index 0000000..b9865b6 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IDataMapperAssembler.java @@ -0,0 +1,30 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.assembler; + +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.context.DataMapperContext; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.ArrayList; + +public interface IDataMapperAssembler { + + void doDataMappingFromVo(IFSManagerContext context, DataMapperContext mappingContext); + + ArrayList doDataMapping2Vo(IFSManagerContext context, DataMapperContext mappingContext); +} -- Gitee From 3f7d6563c550e16c8f91d63802f652bc86a1e6d7 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Wed, 26 Oct 2022 17:08:31 +0800 Subject: [PATCH 18/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E5=8A=A8?= =?UTF-8?q?=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增动作接口 --- .../inspur/edp/bff/api/manager/IFSAction.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/IFSAction.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/IFSAction.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/IFSAction.java new file mode 100644 index 0000000..a467718 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/IFSAction.java @@ -0,0 +1,28 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager; + +import com.inspur.edp.bef.api.action.VoidActionResult; + +/** + * FormServer操作接口,所有的FormServer操作,都需要实现该接口。 + * 设置操作的返回值类型。 + * 如果操作没有返回值,则指定返回值类型为{@link VoidActionResult} + */ +public interface IFSAction { + +} -- Gitee From 6852eb13810330ea7d78a153185303de71338338 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Wed, 26 Oct 2022 17:15:06 +0800 Subject: [PATCH 19/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E5=88=A0?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增删除操作接口 --- .../assembler/IExtendDeleteAssembler.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendDeleteAssembler.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendDeleteAssembler.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendDeleteAssembler.java new file mode 100644 index 0000000..98a653e --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendDeleteAssembler.java @@ -0,0 +1,33 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.assembler; + +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.context.DeleteContext; + +public interface IExtendDeleteAssembler { + void doBeforeDelete(IFSManagerContext context, DeleteContext delContext); + + void doDelete(IFSManagerContext context, DeleteContext delContext); + + void doAfterDelete(IFSManagerContext context, DeleteContext delContext); + void doBeforeMultiDelete(IFSManagerContext context, DeleteContext delContext); + + void doMultiDelete(IFSManagerContext context, DeleteContext delContext); + + void doAfterMultiDelete(IFSManagerContext context, DeleteContext delContext); +} -- Gitee From 6d8e9b159fd68be8851a787eba08696d523f4d61 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Thu, 27 Oct 2022 09:20:59 +0800 Subject: [PATCH 20/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增修改扩展操作 --- .../assembler/IExtendModifyAssembler.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendModifyAssembler.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendModifyAssembler.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendModifyAssembler.java new file mode 100644 index 0000000..4e06f8f --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendModifyAssembler.java @@ -0,0 +1,30 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.assembler; + +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.context.ModifyContext; + +public interface IExtendModifyAssembler { + + void doBeforeModify(IFSManagerContext context, ModifyContext modifyContext); + + void doModify(IFSManagerContext context, ModifyContext modifyContext); + + void doAfterModify(IFSManagerContext context, ModifyContext modifyContext); + +} -- Gitee From 604030f60f9b65cea8fcdd824976d960094d3477 Mon Sep 17 00:00:00 2001 From: qinxinyuan Date: Thu, 27 Oct 2022 09:36:08 +0800 Subject: [PATCH 21/81] =?UTF-8?q?=E6=89=A7=E8=A1=8C=E5=8A=A8=E4=BD=9C?= =?UTF-8?q?=E7=B1=BB=E4=B8=8E=E5=AE=A1=E8=AE=A1=E6=97=A5=E5=BF=97=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=B1=BB=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bff/core/cache/AuditLogConfigCache.java | 53 ++++ .../edp/bff/core/manager/ActionExecutor.java | 240 ++++++++++++++++++ 2 files changed, 293 insertions(+) create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/cache/AuditLogConfigCache.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/manager/ActionExecutor.java diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/cache/AuditLogConfigCache.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/cache/AuditLogConfigCache.java new file mode 100644 index 0000000..24bfd15 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/cache/AuditLogConfigCache.java @@ -0,0 +1,53 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.cache; + +import com.inspur.edp.bef.auditconfig.entity.BefAuditConfig; + +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class AuditLogConfigCache { + private static ConcurrentHashMap befAuditConfigMap = new ConcurrentHashMap<>(); + + public static BefAuditConfig getBefAuditConfig(String id) { + if (!befAuditConfigMap.containsKey(id)) { + return null; + } + return befAuditConfigMap.get(id); + } + + private static Map> voIdAuditConfigMap = new ConcurrentHashMap<>(); + public static void clearVoIdCache() { + voIdAuditConfigMap.clear(); + } + public static boolean containsVoId(String voId) { + return voIdAuditConfigMap.containsKey(voId); + } + + public static List getCacheByVoId(String voId) { + if (!voIdAuditConfigMap.containsKey(voId)) { + throw new RuntimeException("审计日志配置中,voId索引缓存中不包含当前查找项,voId=" + voId); + } + return voIdAuditConfigMap.get(voId); + } + + public static void setCacheByVoId(String voId, List configs) { + voIdAuditConfigMap.put(voId, configs); + } +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/manager/ActionExecutor.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/manager/ActionExecutor.java new file mode 100644 index 0000000..0e01a0b --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/manager/ActionExecutor.java @@ -0,0 +1,240 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.manager; + +import com.inspur.edp.bef.api.lcp.IResponseContext; +import com.inspur.edp.bef.api.lcp.IStandardLcp; +import com.inspur.edp.bef.core.session.FuncSession; +import com.inspur.edp.bef.core.session.FuncSessionManager; +import com.inspur.edp.bff.api.attribute.AbstractSourceConfig; +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.SourceType; +import com.inspur.edp.bff.api.manager.assembler.IExtendQueryAssembler; +import com.inspur.edp.bff.api.manager.assembler.IMessageMapperAssembler; +import com.inspur.edp.bff.api.manager.context.ChangeMapperContext; +import com.inspur.edp.bff.api.manager.context.MessageMapperContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.bff.spi.action.actionstatck.VoActionContext; +import com.inspur.edp.bff.spi.assembler.AbstractAssemblerManager; +import com.inspur.edp.cef.api.RefObject; +import com.inspur.edp.cef.api.message.IBizMessage; +import com.inspur.edp.cef.api.response.ResponseContext; +import com.inspur.edp.cef.core.entityaction.CefActionStack; +import com.inspur.edp.cef.entity.changeset.ChangeDetailMerger; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import com.inspur.edp.commonmodel.core.session.distributed.SessionEditToken; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +abstract class ActionExecutor { + + public abstract IExtendQueryAssembler getAssembler(); + public static TResult executeAction(AbstractFSAction action, FSManager manager, IFSManagerContext context) + { + SessionEditToken editor = null; + FuncSession session = FuncSessionManager.getCurrentSession(); + if(session != null) { + //manager.getBefSessionMgr().beginEdit(); + //TODO:先不加锁, 否则aif生单场景导致死锁 + editor = FuncSessionManager.getCurrent().beginEdit(session, false); + } + TResult result; + try { + result = action.deal(context); + } finally { + if(editor != null) + FuncSessionManager.getCurrent().endEdit(editor); //manager.getBefSessionMgr().endEdit(editor); + } + processResponse(manager, context); + return result; + } + + public static TResult executeAction(AbstractFSAction action, FSManager manager, IFSManagerContext context + ,String actionId,String actionCode,Map parameters,boolean autoSave) { + pushStatck(action,manager,context,actionId,actionCode,parameters); + SessionEditToken editor = null; + FuncSession session = FuncSessionManager.getCurrentSession(); + if(session != null) { + //manager.getBefSessionMgr().beginEdit(); + //TODO:先不加锁, 否则aif生单场景导致死锁 + editor = FuncSessionManager.getCurrent().beginEdit(session, false); + } + try { + final RefObject resultWrapper = new RefObject<>(null); + Runnable r = () -> { + resultWrapper.argvalue = action.deal(context); + processResponse(manager, context); + if(autoSave) + manager.save(); + }; + if (autoSave + && manager.getOutSourceConfigs() != null + && manager.getOutSourceConfigs().getSourceConfigs() != null + && manager.getOutSourceConfigs().getSourceConfigs().size() == 1 + && manager.getOutSourceConfigs().getSourceConfigs().get(0).getSourceType() == SourceType.Be) { + IStandardLcp lcp = manager.getBffContext().getLcp(); + lcp.atomicallyInvoke(r); + } + else { + r.run(); + } + + return resultWrapper.argvalue; + } finally { + if(editor != null) + FuncSessionManager.getCurrent().endEdit(editor); //manager.getBefSessionMgr().endEdit(editor); + CefActionStack.pop(); + } + } + + private static void pushStatck(AbstractFSAction action, FSManager manager, IFSManagerContext context, String actionId, String actionCode, Map parameters) { + VoActionContext voActionContext=new VoActionContext(context.getVoId(),actionId,actionCode,parameters); + CefActionStack.push(voActionContext); + } + + public static void processResponse(FSManager manager, IFSManagerContext context) + { + HashMap beResponse = new HashMap(); + + for (Map.Entry lcp : context.getLcps().entrySet()) + { + if (lcp.getValue() == null|| lcp.getValue().getResponseContext() == null) + { + continue; + } + + beResponse.put(lcp.getKey(), lcp.getValue().getResponseContext()); + } + //IStandardLcp lcp = context.GetLcp(); + //IResponseContext beResponse = lcp.ResponseContext; + ResponseContext fsResponse = manager.getResponseContext(); + mergeResponse(fsResponse, beResponse, context); + } + + private static void mergeResponse(ResponseContext fsResponse, HashMap beResponse, IFSManagerContext context) + { + mergeChanges(fsResponse, beResponse, context); + mergeVariableChanges(fsResponse, context); + mergeMessages(fsResponse, beResponse, context); + clearBEResponse(beResponse); + } + + private static void clearBEResponse(HashMap beResponse) { + beResponse.entrySet().forEach(item -> item.getValue().clear()); + } + + private static void mergeVariableChanges(ResponseContext fsResponse, IFSManagerContext context) + { + IChangeDetail variableInnerChange = context.getVariableInnerChange(); + if (variableInnerChange == null) + { + return; + } + if (fsResponse.getVariableInnerChange() == null) + { + fsResponse.setVariableInnerChange(variableInnerChange.clone()); + } + else + { + ChangeDetailMerger.mergeChangeDetail(variableInnerChange, fsResponse.getVariableInnerChange()); + } + } + + private static void mergeChanges(ResponseContext fsResponse, HashMap beResponse, IFSManagerContext context) + { + if (beResponse.size() < 1) + { + return; + } + + HashMap> change = new HashMap<>(); + for (Map.Entry item: + beResponse.entrySet()) { + + ArrayList changes = new ArrayList(item.getValue().getInnerChangeset().values()); + change.put(item.getKey(), changes); + } + + ChangeMapperContext mapperContext = new ChangeMapperContext(); + mapperContext.setInnerChange(change); + context.getAssemblerManager().getChangeMapperAssembler().doChangeMapping2Vo(context, mapperContext); + + mergeChange(fsResponse, mapperContext.getTargetChange()); + } + + private static void mergeChange(ResponseContext fsResponse, ArrayList voChangeDetails) + { + if (voChangeDetails == null || voChangeDetails.isEmpty()) + { + return; + } + + for (IChangeDetail voChangeDetail : voChangeDetails) + { + //TODO 存在时,是合并还是覆盖 + if (!fsResponse.getInnerChangeset().containsKey(voChangeDetail.getDataID())) + { + fsResponse.getInnerChangeset().put(voChangeDetail.getDataID(), voChangeDetail); + } + else + { + fsResponse.mergeInnerChange(voChangeDetail); + } + } + } + + private static void mergeMessages(ResponseContext fsResponse, HashMap beResponse, IFSManagerContext context) + { + if (beResponse == null || beResponse.size() < 1) + { + return; + } + + IMessageMapperAssembler msgMapper = getMesssageMapper(context); + if(msgMapper != null) { + HashMap> message = new HashMap<>(); + for (Map.Entry item: beResponse.entrySet()) { + if(item.getValue().getMessages()==null || item.getValue().getMessages().isEmpty()){ + continue; + } + message.put(item.getKey(), new ArrayList<>(item.getValue().getMessages())); + } + + MessageMapperContext mapperContext = new MessageMapperContext(); + mapperContext.setSourceMessage(message); + msgMapper.doMessageMapping2Vo(context, mapperContext); + if(mapperContext.getTargetMessage() != null) { + fsResponse.addMessage(mapperContext.getTargetMessage()); + } + } else { + for (IResponseContext response : beResponse.values()) { + //改be的message引用 + fsResponse.addMessage(response.getMessages()); + } + } + } + + private static IMessageMapperAssembler getMesssageMapper(IFSManagerContext context){ + if(context.getAssemblerManager() == null || !(context.getAssemblerManager() instanceof AbstractAssemblerManager)){ + return null; + } + + return ((AbstractAssemblerManager)context.getAssemblerManager()).getMessageMapperAssembler(); + } +} -- Gitee From ccc93fc301f2e426508637729ff266d654e7daa6 Mon Sep 17 00:00:00 2001 From: qinxinyuan Date: Thu, 27 Oct 2022 09:41:28 +0800 Subject: [PATCH 22/81] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../edp/bff/core/action/query/AuditUtils.java | 177 ++++++++++++++++++ .../bff/core/manager/BaseChangeConvertor.java | 20 ++ 2 files changed, 197 insertions(+) create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/AuditUtils.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/manager/BaseChangeConvertor.java diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/AuditUtils.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/AuditUtils.java new file mode 100644 index 0000000..a3c0969 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/AuditUtils.java @@ -0,0 +1,177 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.query; + +import com.inspur.edp.bef.auditconfig.entity.BefAuditConfigItem; +import com.inspur.edp.bef.auditconfig.entity.info.BeEntityFieldsInfo; +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.spi.action.actionstatck.VoActionContext; +import com.inspur.edp.cef.api.ValueGetterConfig; +import com.inspur.edp.cef.core.valuegetter.CefValueGetter; +import com.inspur.edp.cef.entity.changeset.ChangeType; +import com.inspur.edp.cef.entity.entity.IEntityData; +import io.iec.edp.caf.audit.api.data.GspAudit; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Stack; + +public class AuditUtils { + public static Map> getAuditMessageField(GspAudit gspAudit, + BefAuditConfigItem item,Map> auditMessageDataFields,Map>> childAuditMessageDataFields) { + Stack stack=new Stack(); + Map> fields =new HashMap<>(); + Map>> childFields =new HashMap<>(); + if (item.getAuditMessage() == null || item.getAuditMessage().getAuditMessage() == null || !item.getAuditMessage().getAuditMessage().contains("#")) { + return fields; + } + String[] list = item.getAuditMessage().getAuditMessage().split("#"); + for(int i=0;i()); + } + else + { + String prefix =list[i].substring(0,list[i].lastIndexOf("/")).replaceFirst("data:", ""); + if(childFields.containsKey(prefix)==false) + childFields.put(prefix,new HashMap<>()); + childFields.get(prefix).put(list[i].replaceFirst("data:"+prefix+"/",""),new ArrayList<>()); + } + stack.pop(); + } + } + auditMessageDataFields.putAll(fields); + childAuditMessageDataFields.putAll(childFields); + return fields; + } + + public static void addAuditMessageFieldValue(IEntityData data,String entityCode,Map> auditMessageDataFields, + Map>> childAuditMessageDataFields,IFSManagerContext managerContext) { + + setCurrentDataValue(data,auditMessageDataFields,entityCode,managerContext); + + for(Map.Entry>> childFields:childAuditMessageDataFields.entrySet()) + { + addAuditMessageChildFieldsValue(childFields,data,managerContext); + } + } + + private static void setCurrentDataValue(IEntityData data,Map> fields,String entityCode,IFSManagerContext managerContext) { + if (fields == null || fields.size() == 0) + return ; + for (Entry> entry : fields.entrySet()) { + + entry.getValue().add(getEntityDataFieldValue(data,entityCode,entry.getKey(),managerContext)); +// String.valueOf( +// new CefValueGetter().getValue(data, entry.getKey(), new ValueGetterConfig()))); + } + } + + private static void addAuditMessageChildFieldsValue(Entry>> childFields,IEntityData data,IFSManagerContext managerContext) { + String[] childs = childFields.getKey().split("/"); + if(childs ==null||childs.length==0) + return; + List parentDatas =new ArrayList<>(); + parentDatas.add(data); + int index =0; + List childDatas= addItems(index,childs,parentDatas); + if(childDatas==null||childDatas.size()==0) + return; + for(IEntityData item:childDatas) + { + setCurrentDataValue(item,childFields.getValue(),childs[childs.length-1],managerContext); + } + } + + private static List addItems(int index, String[] childs, List parentDatas) { + if(parentDatas==null||parentDatas.size()==0) + return null; + + List childDatas =new ArrayList<>(); + for(IEntityData item:parentDatas) + { + if(item.getChilds()==null||item.getChilds().containsKey(childs[index])==false) + return null; + childDatas.addAll(item.getChilds().get(childs[index])); + } + if(index==childs.length-1) + return childDatas; + return addItems(index+1,childs,childDatas); + } + + static String getEntityDataFieldValue(IEntityData data,String entityCode,String fieldLabel, + IFSManagerContext managerContext) + { + if(entityCode==null||entityCode.equals("")) + entityCode="RootNode"; + Object value =new CefValueGetter().getValue(data,fieldLabel,new ValueGetterConfig()); + if(value==null) + return ""; + if(value instanceof Enum) + { + return managerContext.getBffManager().getModelInfo().getCustomResource(entityCode).getEnumPropertyDispalyValue(fieldLabel,String.valueOf(value)); + } + if(value instanceof Date) + { + SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS" ); + return sdf.format((Date)value); + } + return String.valueOf(value); + } + + public static void setAuditMessage(GspAudit gspAudit, Map> auditMessageDataFields,Map>> childAuditMessageDataFields) { + + for (Map.Entry> entry : auditMessageDataFields.entrySet()) { + String message = getFieldValue(entry.getValue()); + gspAudit.setDescription( + gspAudit.getDescription().replaceAll("#data:" + entry.getKey() + "#", message)); + } + for(Map.Entry>> entry:childAuditMessageDataFields.entrySet()) + { + for(Entry> childEntry:entry.getValue().entrySet()) + { + String message = getFieldValue(childEntry.getValue()); + if(message==null) + message=""; + gspAudit.setDescription(gspAudit.getDescription().replaceAll("#data:" + entry.getKey()+"/"+childEntry.getKey()+"#",message)); + } + } + } + + private static String getFieldValue(List value) { + StringBuilder stringBuilder=new StringBuilder(); + for(int i =0;i Date: Thu, 27 Oct 2022 09:48:18 +0800 Subject: [PATCH 23/81] =?UTF-8?q?bean=E7=B1=BB=E4=B8=8E=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=B8=AE=E5=8A=A9id=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../builtinimpl/BffBuiltInManager.java | 123 ++++++++++++++++++ .../bff/core/session/BeanConfiguration.java | 41 ++++++ 2 files changed, 164 insertions(+) create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/manager/builtinimpl/BffBuiltInManager.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/BeanConfiguration.java diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/manager/builtinimpl/BffBuiltInManager.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/manager/builtinimpl/BffBuiltInManager.java new file mode 100644 index 0000000..7ed7975 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/manager/builtinimpl/BffBuiltInManager.java @@ -0,0 +1,123 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.manager.builtinimpl; + +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.core.manager.FSManager; +import com.inspur.edp.bff.spi.AbstractBffEntityDeserConvertor; +import com.inspur.edp.bff.spi.AbstractBffEntitySerConvertor; +import com.inspur.edp.bff.spi.BffChangeDeserConvertor; +import com.inspur.edp.bff.spi.BffChangeSerConvertor; +import com.inspur.edp.bff.spi.BffEntityDeserConvertor; +import com.inspur.edp.bff.spi.BffEntitySerConvertor; +import com.inspur.edp.bff.spi.AbstractBffEntityDeserConvertor; +import com.inspur.edp.bff.spi.AbstractBffEntitySerConvertor; +import com.inspur.edp.bff.spi.BffChangeDeserConvertor; +import com.inspur.edp.bff.spi.BffChangeSerConvertor; +import com.inspur.edp.bff.spi.BffEntityDeserConvertor; +import com.inspur.edp.bff.spi.BffEntitySerConvertor; +import com.inspur.edp.bff.spi.VMHelpConfig; +import com.inspur.edp.bff.spi.changeset.AbstractBffChangeJsonDeserializer; +import com.inspur.edp.bff.spi.changeset.AbstractBffChangeJsonSerializer; +import com.inspur.edp.bff.spi.changeset.AbstractBffChangeJsonDeserializer; +import com.inspur.edp.bff.spi.changeset.AbstractBffChangeJsonSerializer; +import com.inspur.edp.cef.spi.entity.resourceInfo.ModelResInfo; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefEntityResInfoImpl; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefEntityResInfoImpl; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefModelResInfoImpl; +import java.lang.reflect.InvocationTargetException; + +public abstract class BffBuiltInManager extends FSManager { +// @Override +// protected final ModelResInfo innerGetModelInfo() { +// if(getManagerCacheInfo().getModelResInfo()!=null) +// return getManagerCacheInfo().getModelResInfo(); +// ModelResInfo modelResInfo=getModelInfo(); +// getManagerCacheInfo().setModelResInfo(modelResInfo); +// return modelResInfo; +// } + + @Override + public final ModelResInfo getModelInfo() { + return getCefModelResourceInfo(); + } + + public abstract CefModelResInfoImpl getCefModelResourceInfo(); + + protected IFSManagerContext getContext() { + return getBffContext(); + } + + protected final void processResponse() { + getContext().processResponse(); + } + + @Override + protected String getHelpId(String codeName, String labelId) { + VMHelpConfig config = getHelpConfig(codeName, labelId); + if(config == null){ + throw new RuntimeException("节点"+codeName+"上没有找到字段"+labelId+"的帮助配置。请检查视图对象元数据中是否正确设置帮助信息,并成功部署。"); + } + return config.getHelpId(); + } + protected void addExtends() { + String classFullName = "com.inspur.edp.customize.bff.BffCtmExtendProvider"; + try { + Class providerClass = Class.forName(classFullName); + addExtClass(providerClass); + } catch (ClassNotFoundException e) { + throw new RuntimeException("无法实例化类型" + classFullName,e); + } + } + + + @Override + protected AbstractBffEntityDeserConvertor getDataJsonDeSerizlize() { + return new BffEntityDeserConvertor(getCefModelResourceInfo().getRootNodeCode(), true, getType(), + (CefEntityResInfoImpl) getCefModelResourceInfo().getCustomResource(getCefModelResourceInfo().getRootNodeCode())); + } + + @Override + protected AbstractBffEntitySerConvertor getDataJsonSerizlize() { + return new BffEntitySerConvertor(getCefModelResourceInfo().getRootNodeCode(), true, getType(), + (CefEntityResInfoImpl) getCefModelResourceInfo().getCustomResource(getCefModelResourceInfo().getRootNodeCode())); + } + + @Override + protected AbstractBffChangeJsonSerializer getChangeSerializer() { + return new BffChangeSerConvertor(getCefModelResourceInfo().getRootNodeCode(), true, getType(), + (CefEntityResInfoImpl) getCefModelResourceInfo().getCustomResource(getCefModelResourceInfo().getRootNodeCode())); + } + + @Override + protected AbstractBffChangeJsonDeserializer getChangeDeserializer() { + return new BffChangeDeserConvertor(getCefModelResourceInfo().getRootNodeCode(), true, getType(), + (CefEntityResInfoImpl) getCefModelResourceInfo().getCustomResource(getCefModelResourceInfo().getRootNodeCode())); + } + + private String getType() { + CefEntityResInfoImpl cefEntityResInfo = (CefEntityResInfoImpl) getCefModelResourceInfo().getCustomResource(getCefModelResourceInfo().getRootNodeCode()); + String configId = cefEntityResInfo.getConfigId(); + if (configId.isEmpty()) { + throw new RuntimeException("序列化反序列化获取VoType失败! nodeCode :" + getCefModelResourceInfo().getRootNodeCode()); + } + if (!configId.startsWith("com.") && configId.contains(".")) { + configId = "com." + configId; + } + return configId; + } +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/BeanConfiguration.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/BeanConfiguration.java new file mode 100644 index 0000000..7fa8f15 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/BeanConfiguration.java @@ -0,0 +1,41 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.session; + +import com.inspur.edp.commonmodel.core.session.SessionItemRecover; +import com.inspur.edp.commonmodel.core.session.distributed.SessionItemDistributedFactory; +import com.inspur.edp.commonmodel.core.util.SessionIncSerializerUtil; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class BeanConfiguration { + @Bean(name = BffSessionItem.Category) + public SessionItemDistributedFactory getSessionItemDistributedFactory() { + return new SessionItemDistributedFactory() { + @Override + public SessionIncSerializerUtil getSerializer() { + return new BffIncrementSerializerUtil(); + } + + @Override + public SessionItemRecover getRecover() { + return new SessionItemRecoverImpl(); + } + }; + } +} -- Gitee From 7b23507d2c67ded9b5890da3d6a7fedd117069db Mon Sep 17 00:00:00 2001 From: qinxinyuan Date: Thu, 27 Oct 2022 09:53:02 +0800 Subject: [PATCH 24/81] =?UTF-8?q?session=E5=BA=8F=E5=88=97=E5=8C=96?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BFFCommonDataExtension.java | 40 ++++++++++++ .../session/BffIncrementSerializerUtil.java | 65 +++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/commonstructure/BFFCommonDataExtension.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/BffIncrementSerializerUtil.java diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/commonstructure/BFFCommonDataExtension.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/commonstructure/BFFCommonDataExtension.java new file mode 100644 index 0000000..97e8457 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/commonstructure/BFFCommonDataExtension.java @@ -0,0 +1,40 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.commonstructure; + +import com.inspur.edp.bff.api.manager.IFSManagerFactory; +import com.inspur.edp.caf.cef.rt.api.CommonData; +import com.inspur.edp.caf.cef.rt.spi.ObjectCreateExtension; +import io.iec.edp.caf.runtime.config.CefBeanUtil; + +public class BFFCommonDataExtension implements ObjectCreateExtension { + + private String voType = "GSPViewModel"; + + // region ObjectCreateExtension + @Override + public CommonData newInstance(String configId) { + return (CommonData) CefBeanUtil.getAppCtx().getBean(IFSManagerFactory.class).getFSManager(configId).createData(); + } + + @Override + public String getCreatorType() { + return voType; + } + + // endregion +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/BffIncrementSerializerUtil.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/BffIncrementSerializerUtil.java new file mode 100644 index 0000000..81cbfa8 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/BffIncrementSerializerUtil.java @@ -0,0 +1,65 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.session; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.bff.api.manager.IFSManagerFactory; +import com.inspur.edp.cef.api.session.ICefSessionItem; +import com.inspur.edp.cef.designtime.api.json.SerializerUtils; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import com.inspur.edp.cef.entity.changeset.ValueObjModifyChangeDetail; +import com.inspur.edp.commonmodel.core.session.distributed.dac.FuncSessionItemIncrement; +import com.inspur.edp.commonmodel.core.util.SessionIncSerializerUtil; +import io.iec.edp.caf.commons.utils.SpringBeanUtils; +import java.util.List; +import lombok.SneakyThrows; + +public class BffIncrementSerializerUtil implements SessionIncSerializerUtil { + + @SneakyThrows + @Override + public ValueObjModifyChangeDetail deserializerVar(String configId, JsonParser jsonParser) { + IFSManagerFactory factory = SpringBeanUtils.getBean(IFSManagerFactory.class); + IFSManager fsManager = factory.getFSManagerByVOId(configId); + return (ValueObjModifyChangeDetail) fsManager.createVariableManager() + .deserializeChange(jsonParser.readValueAsTree().toString()); + } + + @Override + public List deserializerChanges(String configId, JsonParser jsonParser) { + return null; + } + + @SneakyThrows + @Override + public void serializerVar(JsonGenerator writer, FuncSessionItemIncrement increment, + ICefSessionItem cefSessionItem) { + IFSManagerFactory factory = SpringBeanUtils.getBean(IFSManagerFactory.class); + IFSManager fsManager = factory.getFSManagerByVOId(cefSessionItem.getConfigId()); + String propertyValue = fsManager.createVariableManager() + .serializeChange(increment.getVariable()); + SerializerUtils.writePropertyName(writer, "variable"); + writer.writeRawValue(propertyValue); + } + + @Override + public void serializerChanges(JsonGenerator jsonGenerator, + FuncSessionItemIncrement funcSessionItemIncrement, ICefSessionItem cefSessionItem) { + } +} -- Gitee From cfa6949502f3f80c7c1ab68ce4983496f29b24b2 Mon Sep 17 00:00:00 2001 From: qinxinyuan Date: Thu, 27 Oct 2022 09:57:49 +0800 Subject: [PATCH 25/81] =?UTF-8?q?session=E6=8F=90=E4=BA=A4=EF=BC=8C?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E4=B8=8E=E5=88=A0=E9=99=A4=E5=8A=A8=E4=BD=9C?= =?UTF-8?q?=E7=B1=BB=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bff/core/action/cancel/CancelAction.java | 38 +++++++++++ .../bff/core/action/delete/DeleteAction.java | 63 +++++++++++++++++++ .../edp/bff/core/session/BffSessionItem.java | 55 ++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/cancel/CancelAction.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/delete/DeleteAction.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/BffSessionItem.java diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/cancel/CancelAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/cancel/CancelAction.java new file mode 100644 index 0000000..7135388 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/cancel/CancelAction.java @@ -0,0 +1,38 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.cancel; + +import com.inspur.edp.bef.api.action.VoidActionResult; +import com.inspur.edp.bef.api.lcp.IStandardLcp; +import com.inspur.edp.bff.spi.AbstractFSAction; + +public class CancelAction extends AbstractFSAction { + + public CancelAction() + { + } + + @Override + protected void execute() + { + for (IStandardLcp lcp : getContext().getLcps().values()) + { + lcp.cancel(); + } + } + +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/delete/DeleteAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/delete/DeleteAction.java new file mode 100644 index 0000000..332cbad --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/delete/DeleteAction.java @@ -0,0 +1,63 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.delete; + +import com.inspur.edp.bef.api.action.VoidActionResult; +import com.inspur.edp.bff.api.manager.context.DeleteContext; +import com.inspur.edp.bff.spi.AbstractFSAction; + +public class DeleteAction extends AbstractFSAction { + + private String dataID; + + public DeleteAction(String dataID) + { + this.dataID = dataID; + } + + @Override + protected void execute() + { + //foreach (var lcp in GetLcp()) + //{ + // lcp.Delete(dataID); + //} + if (getContext().getAssemblerManager() == null) + { + doDefaultDelete(); + return; + } + + DeleteContext deleteContext = new DeleteContext(); + deleteContext.setDataId(dataID); + + //① DoBeforeDelete + getContext().getAssemblerManager().getDeleteAssembler().doBeforeDelete(getContext(), deleteContext); + + //② DoDelete + getContext().getAssemblerManager().getDeleteAssembler().doDelete(getContext(), deleteContext); + + //④ AfterDelete + getContext().getAssemblerManager().getDeleteAssembler().doAfterDelete(getContext(), deleteContext); + + } + + private void doDefaultDelete() + { + getLcp().delete(dataID); + } +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/BffSessionItem.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/BffSessionItem.java new file mode 100644 index 0000000..ff06d44 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/BffSessionItem.java @@ -0,0 +1,55 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.session; + +import com.inspur.edp.cef.api.session.CefSessionItem; +import com.inspur.edp.commonmodel.core.session.distributed.DistributedSessionPart; +import com.inspur.edp.commonmodel.core.session.distributed.RootEditToken; +import com.inspur.edp.commonmodel.core.variable.VarBufferManager; +import lombok.Getter; +import lombok.Setter; + +public class BffSessionItem extends CefSessionItem implements DistributedSessionPart { + + public static final String Category = "BffSessionItem"; + + public BffSessionItem(String configId) { + setCategory(Category); + setConfigId(configId); + } + + @Getter + @Setter + private VarBufferManager varBufferManager; + + @Override + public void endEdit(RootEditToken token) { + if(varBufferManager != null){ + varBufferManager.endEdit(token); + } + } + + @Override + public void beginEdit(RootEditToken token) { + if(varBufferManager != null){ + varBufferManager.beginEdit(token); + } + } + + @Override + public void notifySave() {} +} -- Gitee From ec0379fb786bfe0c93936b27f79b8f9465805650 Mon Sep 17 00:00:00 2001 From: qinxinyuan Date: Thu, 27 Oct 2022 10:03:39 +0800 Subject: [PATCH 26/81] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=8E=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E5=8A=A8=E4=BD=9C=EF=BC=8C=E5=88=A0=E9=99=A4=E5=AD=90?= =?UTF-8?q?=E5=8A=A8=E4=BD=9C=EF=BC=8C=E5=8A=A8=E4=BD=9C=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E7=B1=BB=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/delete/DeleteAndSaveAction.java | 58 +++++++++++++++++++ .../core/action/delete/DeleteChildAction.java | 42 ++++++++++++++ .../bff/core/action/retrieve/EditAction.java | 52 +++++++++++++++++ 3 files changed, 152 insertions(+) create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/delete/DeleteAndSaveAction.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/delete/DeleteChildAction.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/EditAction.java diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/delete/DeleteAndSaveAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/delete/DeleteAndSaveAction.java new file mode 100644 index 0000000..2e2a868 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/delete/DeleteAndSaveAction.java @@ -0,0 +1,58 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.delete; + +import com.inspur.edp.bef.api.action.VoidActionResult; +import com.inspur.edp.bef.api.exceptions.BefException; +import com.inspur.edp.bef.api.exceptions.ErrorCodes; +import com.inspur.edp.bef.api.lcp.IStandardLcp; +import com.inspur.edp.bef.entity.exception.ExceptionLevel; +import com.inspur.edp.bff.api.manager.context.DeleteContext; +import com.inspur.edp.bff.spi.AbstractFSAction; + +import javax.naming.Context; + +/** + * @author Jakeem + * @Data 2019/11/19 - 13:49 + */ +public +class DeleteAndSaveAction extends AbstractFSAction { + + private String dataID; + + public DeleteAndSaveAction(String dataID) + { + this.dataID = dataID; + } + + @Override + protected void execute() + { + if(getContext().getSourceConfigs()==null || getContext().getSourceConfigs().size()<=0){ + throw new RuntimeException("虚拟VO不支持删除并保存操作! void:"+getContext().getVoId()); + } + if (getContext().getLcp() != null) + { + getContext().getLcp().atomicallyInvoke(()->{getContext().getBffManager().delete(dataID); + getContext().getBffManager().save();}); + }else{ + throw new BefException(ErrorCodes.NoScope, "虚拟VO不支持删除并保存操作", null, ExceptionLevel.Error); + } + } +} + diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/delete/DeleteChildAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/delete/DeleteChildAction.java new file mode 100644 index 0000000..544fc44 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/delete/DeleteChildAction.java @@ -0,0 +1,42 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.delete; + +import com.inspur.edp.bef.api.action.VoidActionResult; +import com.inspur.edp.bff.spi.AbstractFSAction; + +import java.util.List; + +public class DeleteChildAction extends AbstractFSAction { + + private List nodeCodes; + private List hierachyIdList; + private List ids; + + public DeleteChildAction(List nodeCodes, List hierachyIdList, List ids) + { + this.nodeCodes = nodeCodes; + this.hierachyIdList = hierachyIdList; + this.ids = ids; + } + + @Override + protected void execute() + { + getLcp().deleteChild(nodeCodes, hierachyIdList, ids); + } +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/EditAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/EditAction.java new file mode 100644 index 0000000..9ec38ed --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/EditAction.java @@ -0,0 +1,52 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.retrieve; + +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.api.manager.SourceConfig; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.action.EditResult; +import com.inspur.edp.cef.entity.entity.IEntityData; +import java.util.ArrayList; + +public class EditAction extends AbstractFSAction { + + private String dataID; + + public EditAction(String dataID) { + this.dataID = dataID; + } + + @Override + protected void execute() { + setResult(new EditResult()); + ArrayList config = getContext().getSourceConfigs(); + if (config != null && config.size() == 1) { + doDefaultEdit(); + } + } + + private void doDefaultEdit() { + EditResult retriveResult = getLcp().edit(dataID); + if (retriveResult.getData() != null) { + IDataConvertor dataConvertor = getContext().getDataConvertor(); + IEntityData vmData = getContext().createData(); + dataConvertor.convertFromBEData(retriveResult.getData(), vmData); + getResult().setData(vmData); + } + } +} -- Gitee From cc25d1efad1c283f927c2f1e239384b3919af196 Mon Sep 17 00:00:00 2001 From: qinxinyuan Date: Thu, 27 Oct 2022 10:08:28 +0800 Subject: [PATCH 27/81] =?UTF-8?q?=E7=B1=BB=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../edp/bff/core/action/FSActionFactory.java | 179 ++ .../bff/core/filter/FilterFieldConvertor.java | 388 ++++ .../edp/bff/core/manager/FSManager.java | 1583 +++++++++++++++++ 3 files changed, 2150 insertions(+) create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/FSActionFactory.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/filter/FilterFieldConvertor.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/manager/FSManager.java diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/FSActionFactory.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/FSActionFactory.java new file mode 100644 index 0000000..133aa5c --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/FSActionFactory.java @@ -0,0 +1,179 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action; + +import com.inspur.edp.bef.api.lcp.AuthInfo; +import com.inspur.edp.bef.api.parameter.retrieve.RetrieveParam; +import com.inspur.edp.bff.core.action.cancel.CancelAction; +import com.inspur.edp.bff.core.action.delete.DeleteAction; +import com.inspur.edp.bff.core.action.delete.DeleteAndSaveAction; +import com.inspur.edp.bff.core.action.delete.DeleteChildAction; +import com.inspur.edp.bff.core.action.delete.MultiDeleteAction; +import com.inspur.edp.bff.core.action.modify.ModifyAction; +import com.inspur.edp.bff.core.action.query.QoQueryAction; +import com.inspur.edp.bff.core.action.query.QueryAction; +import com.inspur.edp.bff.core.action.query.QueryChildAction; +import com.inspur.edp.bff.core.action.query.QueryChildWithCodeAction; +import com.inspur.edp.bff.core.action.query.QueryWithAuthInfoAction; +import com.inspur.edp.bff.core.action.retrieve.*; +import com.inspur.edp.bff.core.action.retrievedefault.*; +import com.inspur.edp.bff.core.action.save.SaveAction; +import com.inspur.edp.bff.entity.RetrieveDefaultParam; +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import com.inspur.edp.cef.entity.condition.EntityFilter; +import com.inspur.edp.cef.entity.dependenceTemp.Pagination; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class FSActionFactory { + static void TTT(){} + public static RetrieveDefaultAction getRetrieveDefaultAction() + { + return new RetrieveDefaultAction(); + } + + public static RetrieveDefaultAction getRetrieveDefaultAction(VoDefaultValue defaultValue) + { + return new RetrieveDefaultAction(defaultValue); + } + + public static RetrieveDefaultAction getRetrieveDefaultAction(String dataId) + { + return new RetrieveDefaultAction(dataId); + } + + public static RetrieveDefaultBatchAction getRetrieveDefaultBatchAction(RetrieveDefaultParam defaultParam) + { + return new RetrieveDefaultBatchAction(defaultParam); + } + + public static RetrieveDefaultChildAction getRetrieveDefaultChildAction(ArrayList nodeCodes, ArrayList lierachyIds) + { + return new RetrieveDefaultChildAction(nodeCodes, lierachyIds); + } + + public static RetrieveDefaultChildeWithIdsAction getRetrieveDefaultChildWithIdsAction(ArrayList nodeCodes, ArrayList lierachyIds, ArrayList ids){ + + return new RetrieveDefaultChildeWithIdsAction(nodeCodes,lierachyIds,ids); + + } + public static MultiRetrieveAction getMultiRetrieveAction(ArrayList dataIds, RetrieveParam param) + { + return new MultiRetrieveAction(dataIds, param); + } + + public static RetrieveAction getRetrieveAction(String dataID) + { + return new RetrieveAction(dataID); + } + + public static RetrieveAction getRetrieveAction(String dataId, RetrieveParam param) + { + return new RetrieveAction(dataId, param); + } + public static RetrieveChildAction getRetrieveChildAction(ArrayList nodeCodes, ArrayList lierachyIds, RetrieveParam retrieveParam) { + return new RetrieveChildAction(nodeCodes, lierachyIds, retrieveParam); + } + public static RetrieveChildAndChildAction getRetrieveChildAndChildAction(ArrayList nodeCodes, ArrayList lierachyIds, ArrayList ids,RetrieveParam retrieveParam) { + return new RetrieveChildAndChildAction(nodeCodes, lierachyIds, ids,retrieveParam); } + + public static EditAction getEditAction(String dataId) + { + return new EditAction(dataId); + } + + public static ModifyAction getModifyAction(IChangeDetail change) + { + return new ModifyAction(change); + } + + public static QueryAction getQueryAction(EntityFilter filter) + { + return new QueryAction(filter); + } + + + public static QueryChildAction getQueryChildAction(List nodeCodes,EntityFilter filter) { + return new QueryChildAction(nodeCodes,filter); + } + + + public static QueryChildWithCodeAction getQueryChildWithCodeAction(String nodeCode,EntityFilter filter) { + return new QueryChildWithCodeAction(nodeCode,filter); + } + public static QueryWithAuthInfoAction getQueryWithAuthInfoAction(EntityFilter filter, AuthInfo authInfo) + {return new QueryWithAuthInfoAction(filter,authInfo);} + + public static QoQueryAction getQoQueryAction(IEntityData param, Pagination pageInfo, String extendCond) + { + return new QoQueryAction(param, pageInfo, extendCond); + } + + public static DeleteAction getDeleteAction(String dataID) + { + return new DeleteAction(dataID); + } + + public static MultiDeleteAction getMultiDeleteAction(ArrayList dataIds) + { + return new MultiDeleteAction(dataIds); + } + public static + DeleteAndSaveAction getDeleteAndSaveAction(String dataID){return new DeleteAndSaveAction(dataID);} + + public static DeleteChildAction getDeleteChildAction(List nodeCodes, List hierachyIdList, List ids) + { + return new DeleteChildAction(nodeCodes, hierachyIdList, ids); + } + + public static SaveAction getSaveAction() + { + return new SaveAction(); + } + + public static CancelAction getCancelAction() + { + return new CancelAction(); + } + public static RetrieveWithChildPaginationAction getRetrieveWithChildPagination( + String dataId, + com.inspur.edp.bff.api.param.retrieve.RetrieveParam param){ + return new RetrieveWithChildPaginationAction(dataId,param); + } + public static RetrieveChildByIndexAction getRetrieveChildByIndexAction( + ArrayList nodeCodes, + ArrayList hierachyIds, Pagination pagination){ + return new RetrieveChildByIndexAction(nodeCodes,hierachyIds,pagination); + } + + public static MulitRetrieveDefaultWtihDefaultValueAction getMulitRetrieveDefaultWtihDefaultValueAction( + ArrayList nodeCodes, ArrayList lierachyIds, ArrayList defaultValues) { + return new MulitRetrieveDefaultWtihDefaultValueAction(nodeCodes,lierachyIds,defaultValues); + } + public static RetrieveDefaultChildWithDefaultValueAtion getRetrieveDefaultChildWithDefaultValueAction( + ArrayList nodeCodes, ArrayList lierachyIds, VoDefaultValue defaultValue) { + return new RetrieveDefaultChildWithDefaultValueAtion(nodeCodes,lierachyIds,defaultValue); + } + public static RetrieveDefaultChildWithDefaultValueBatchAtion getRetrieveDefaultChildWithDefaultValueBatchAction( + ArrayList nodeCodes, ArrayList lierachyIds, RetrieveDefaultParam param) { + return new RetrieveDefaultChildWithDefaultValueBatchAtion(nodeCodes,lierachyIds,param); + } +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/filter/FilterFieldConvertor.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/filter/FilterFieldConvertor.java new file mode 100644 index 0000000..b755d68 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/filter/FilterFieldConvertor.java @@ -0,0 +1,388 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.filter; + +import com.inspur.edp.bef.api.lcp.IStandardLcp; +import com.inspur.edp.bef.spi.entity.builtinimpls.BefEntityResInfoImpl; +import com.inspur.edp.bef.spi.entity.builtinimpls.BefPropertyInfo; +import com.inspur.edp.bff.api.dataprocessor.IFilterFieldConvertor; +import com.inspur.edp.bff.api.extend.IBffManagerExtend; +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.bff.spi.builtin.BffEntityResInfoImpl; +import com.inspur.edp.bff.spi.builtin.BffPropertyInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.AssocationPropertyInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.BasePropertyInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.ComplexUdtPropertyInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.DataTypePropertyInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.ObjectType; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.RefDataTypePropertyInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.SimpleAssoUdtPropertyInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.SimpleUdtPropertyInfo; +import com.inspur.edp.cef.spi.entity.resourceInfo.EntityResInfo; +import com.inspur.edp.cef.spi.entity.resourceInfo.ModelResInfo; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefValueObjModelResInfo; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefValueObjResInfo; +import com.inspur.edp.cef.spi.jsonser.base.StringUtils; +import com.inspur.edp.udt.api.Manager.IUdtManager; +import com.inspur.edp.udt.api.UdtManagerUtils; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +public class FilterFieldConvertor implements IFilterFieldConvertor { + + private IFSManager manager; + private Map filterMap=new HashMap<>(); + private Map beEntityInfoMap=new HashMap<>(); + public FilterFieldConvertor(IFSManager fsManager){ + this.manager=fsManager; + initFilterDic(); + } + @Override + public String transFilterField(String fieldName) { + //todo 处理虚拟vo + if (manager.getBffContext().getSourceConfigs()==null|| manager.getBffContext().getSourceConfigs().size()==0) + return fieldName; + if(filterMap.containsKey(fieldName)) + return filterMap.get(fieldName); + return fieldName; + } + + private BefEntityResInfoImpl getBefEntityResInfo(){ + if (beEntityInfoMap.get("BefEntityResInfo")!=null) + return beEntityInfoMap.get("BefEntityResInfo"); + IStandardLcp lcp=manager.getBffContext().getLcp(); + String beEntityCode=manager.getBffContext().getBECodeFromVM(manager.getModelInfo().getRootNodeCode()); + EntityResInfo befEntityResInfo= lcp.getModelInfo().getCustomResource(beEntityCode); + if(befEntityResInfo instanceof BefEntityResInfoImpl) { + beEntityInfoMap.put("BefEntityResInfo", (BefEntityResInfoImpl) befEntityResInfo); + return (BefEntityResInfoImpl) befEntityResInfo; + } + else + throw new RuntimeException("当前BE实体对应的的ResourceInfo类型不是BefEntityResInfoImpl类型,需要生成代码升级到最新!"); + } + private Map getBefPropertyInfos(){ + if(this.getBefEntityResInfo()==null){ + return new HashMap(); + } + Map befPropertyInfos=this.getBefEntityResInfo().getEntityTypeInfo().getPropertyInfos(); + return befPropertyInfos; + } + private BffEntityResInfoImpl getBffEntityResInfo(){ + ModelResInfo modelResInfo=manager.getModelInfo(); + String mainCode=modelResInfo.getRootNodeCode(); + BffEntityResInfoImpl bffEntityResInfo=(BffEntityResInfoImpl)modelResInfo.getCustomResource(mainCode); + return bffEntityResInfo; + } + + private Map getPropertyInfos(){ + Map propInfos=this.getBffEntityResInfo().getEntityTypeInfo().getPropertyInfos(); + return propInfos; + } + private void initFilterDic(){ + //todo 处理虚拟vo + if (manager.getBffContext().getSourceConfigs()==null || manager.getBffContext().getSourceConfigs().size()==0) + return; + initBasicFilterDic(); + initExtendFilterDic(); + } + + private void initBasicFilterDic() { + Map propertyInfos=this.getPropertyInfos(); + + if(propertyInfos==null ||propertyInfos.size()==0) + return; + for (Map.Entry map:propertyInfos.entrySet()){ + DataTypePropertyInfo dataTypePropertyInfo=map.getValue(); + ObjectType type=dataTypePropertyInfo.getObjectType(); + + String parentlabel= dataTypePropertyInfo.getPropertyName(); + if(isVirtualElement(dataTypePropertyInfo)) + continue; + if (type==ObjectType.Association){ + initAssociationElement(dataTypePropertyInfo,parentlabel,""); + continue; + } + if(type==ObjectType.UDT){ + initUdtElement(dataTypePropertyInfo,parentlabel,""); + } + } + } + + private void initExtendFilterDic() { + List bffExtends=manager.getBffContext().getExtList(); + if(bffExtends==null ||bffExtends.size()==0 ) + return; + for (IBffManagerExtend managerExtend:bffExtends){ + managerExtend.mapFilterFromVo(filterMap); + } + } + + private boolean isVirtualElement(DataTypePropertyInfo propertyInfo){ + boolean isVirtual=false; + if (propertyInfo instanceof BffPropertyInfo){ + String beLabelId =((BffPropertyInfo) propertyInfo).getBeLabelId(); + if(beLabelId==null ||"".equalsIgnoreCase(beLabelId)) + isVirtual=true; + } + return isVirtual; + } + + private void initAssociationElement(DataTypePropertyInfo typePropertyInfo,String parentLabel,String returnValue){ + //关联字段本身 + String beLabelId= ((BffPropertyInfo)typePropertyInfo).getBeLabelId(); + initFilterDic(parentLabel+"."+parentLabel,beLabelId); + + AssocationPropertyInfo assocationPropertyInfo= (AssocationPropertyInfo) typePropertyInfo.getObjectInfo(); + + TreeMap refPropInfos =assocationPropertyInfo.getAssociationInfo().getRefPropInfos(); + if(refPropInfos==null || refPropInfos.size()==0) + return; + + if(this.getBefPropertyInfos()==null ||this.getBefPropertyInfos().size()==0 ) + return; + DataTypePropertyInfo befPropInfo= this.getBefPropertyInfos().get(beLabelId); + if(befPropInfo==null){ + throw new RuntimeException("当前VO实体对应的BE实体上没有字段"+beLabelId+"的信息"); + } + + AssocationPropertyInfo beAssoPropInfo= (AssocationPropertyInfo) befPropInfo.getObjectInfo(); + + for (Map.Entry refPropInfo:refPropInfos.entrySet()){ + DataTypePropertyInfo refDataTypePropInfo= refPropInfo.getValue(); + + String beElementLabelId=getBeElementLabelId(beAssoPropInfo,((RefDataTypePropertyInfo)refDataTypePropInfo).getRefPropertyName()); + String childValue = isNullOrEmpty(returnValue) ?beElementLabelId : returnValue; + + String childLabel = isNullOrEmpty(parentLabel) ? refDataTypePropInfo.getPropertyName() : parentLabel; + childLabel=childLabel+"."+refDataTypePropInfo.getPropertyName(); + + if(refDataTypePropInfo.getObjectType()==ObjectType.UDT){ + initUdtElement(refDataTypePropInfo,childLabel,childValue); + }else { + initFilterDic(childLabel,childValue); + } + } + } + + private String getBeElementLabelId(AssocationPropertyInfo beAssoInfo,String refPropName) { + String propName=""; + for (Map.Entry assoPorpInfo:beAssoInfo.getAssociationInfo().getRefPropInfos().entrySet()){ + DataTypePropertyInfo dataTypePropInfo= assoPorpInfo.getValue(); + if(dataTypePropInfo instanceof RefDataTypePropertyInfo){ + RefDataTypePropertyInfo refDataTypePropInfo= (RefDataTypePropertyInfo) dataTypePropInfo; + if(refPropName.equals(refDataTypePropInfo.getRefPropertyName())){ + propName=refDataTypePropInfo.getPropertyName(); + break; + } + } + + if(dataTypePropInfo instanceof BefPropertyInfo) { + propName = getBeElementLabelIdByBePropInfo((BefPropertyInfo) dataTypePropInfo); + if(refPropName.equals(propName)){ + propName=dataTypePropInfo.getPropertyName(); + break; + } + } + } + return propName; + + } + + private String getBeElementLabelIdByBePropInfo(BefPropertyInfo befPropertyInfo) { + String propName=befPropertyInfo.getPropertyName(); + String refPropName=propName.substring(propName.indexOf("_")+1,propName.length()); + return refPropName; + } + + private void initUdtElement( DataTypePropertyInfo typePropertyInfo, String parentLabel, String returnValue) { + BasePropertyInfo propertyInfo= (BasePropertyInfo) typePropertyInfo.getObjectInfo(); + if(propertyInfo instanceof SimpleUdtPropertyInfo) { + initSimpleUdtElement(typePropertyInfo, parentLabel, returnValue); + }else { + initComplexUdt(typePropertyInfo,(ComplexUdtPropertyInfo)propertyInfo); + } + + } + + private void initComplexUdt(DataTypePropertyInfo typePropertyInfo,ComplexUdtPropertyInfo bffUdtPropertyInfo) { + String propLabel=typePropertyInfo.getPropertyName(); + CefValueObjResInfo udtResInfo=getUdtResInfo(bffUdtPropertyInfo.getUdtConfigId()); + Map udtPropInfos =udtResInfo.getEntityTypeInfo().getPropertyInfos(); + //todo 暂时判断多值udt存为一列 + if(udtPropInfos.size()<=1) + return; + if(typePropertyInfo instanceof BffPropertyInfo){ + BffPropertyInfo bffPropertyInfo=(BffPropertyInfo)typePropertyInfo; + BefPropertyInfo befPropertyInfo= (BefPropertyInfo) this.getBefPropertyInfos().get(bffPropertyInfo.getBeLabelId()); + //todo 目前虚拟字段是多值udt时,BffPropertyInfo上的beLabel属性有值,实际be上没有这个字段,返回不处理 + if(befPropertyInfo==null) + return; + ComplexUdtPropertyInfo befUdtPropInfo= (ComplexUdtPropertyInfo) befPropertyInfo.getObjectInfo(); + for(Map.Entry typePropMap:befUdtPropInfo.getPropertyInfos().entrySet()){ + DataTypePropertyInfo udtTypePropInfo= typePropMap.getValue(); + String beChildLabel=udtTypePropInfo.getPropertyName(); + String udtPropName=""; + if(udtTypePropInfo instanceof RefDataTypePropertyInfo){ + udtPropName=((RefDataTypePropertyInfo)udtTypePropInfo).getRefPropertyName(); + initComplexUdtElement(propLabel,udtPropName,beChildLabel); + } + if(udtTypePropInfo instanceof BefPropertyInfo){ + udtPropName=getBeElementLabelIdByBePropInfo((BefPropertyInfo) udtTypePropInfo); + initComplexUdtElement(propLabel,udtPropName,beChildLabel); + } + + } + } else{ + for(Map.Entry typePropMap:udtPropInfos.entrySet()){ + DataTypePropertyInfo udtTypePropInfo=typePropMap.getValue(); + String udtPropName=udtTypePropInfo.getPropertyName(); + String beChildLabel=propLabel; + initComplexUdtElement(propLabel,udtPropName,beChildLabel); + } + + } + + + } + + private void initComplexUdtElement( String propLabel, String udtPropName,String beChildLabel) { + String udtLabel=propLabel+"."+udtPropName; + + initFilterDic(udtLabel,beChildLabel); + initFilterDic(beChildLabel,beChildLabel); + + } + + private void initSimpleUdtElement(DataTypePropertyInfo typePropertyInfo, String parentLabel, String returnValue) { + + SimpleUdtPropertyInfo simpleUdtPropertyInfo= (SimpleUdtPropertyInfo) typePropertyInfo.getObjectInfo(); + CefValueObjResInfo udtResInfo=getUdtResInfo(simpleUdtPropertyInfo.getUdtConfigId()); + + String udtLabel1=parentLabel+"."+udtResInfo.getEntityCode(); + String udtLabel2=udtLabel1+"."+udtResInfo.getEntityCode(); + + String childValue=isNullOrEmpty(returnValue)? typePropertyInfo.getPropertyName():returnValue; + + initFilterDic(udtLabel1,childValue); + initFilterDic(udtLabel2,childValue); + initFilterDic(typePropertyInfo.getPropertyName(),childValue); + if(simpleUdtPropertyInfo instanceof SimpleAssoUdtPropertyInfo){ + initAssoUdtElement(typePropertyInfo,udtLabel1,returnValue,udtResInfo); + } + } + private void initAssoUdtElement(DataTypePropertyInfo typePropertyInfo,String parentLabel,String returnValue, CefValueObjResInfo udtResInfo ){ + + SimpleAssoUdtPropertyInfo simpleAssoUdtPropertyInfo= (SimpleAssoUdtPropertyInfo)typePropertyInfo.getObjectInfo(); + TreeMap refPropInfos= simpleAssoUdtPropertyInfo.getAssoInfo().getAssociationInfo().getRefPropInfos(); + if(refPropInfos==null ||refPropInfos.size()==0) + return; + for (Map.Entry refPropInfo:refPropInfos.entrySet()){ + DataTypePropertyInfo dataTypePropertyInfo=refPropInfo.getValue(); + String childValue=""; + String childLabel=""; + if(dataTypePropertyInfo instanceof RefDataTypePropertyInfo){ + RefDataTypePropertyInfo refDataTypePropInfo= (RefDataTypePropertyInfo) refPropInfo.getValue(); + childValue=isNullOrEmpty(returnValue)?refDataTypePropInfo.getPropertyName():returnValue; + childLabel=isNullOrEmpty(parentLabel) ? refDataTypePropInfo.getPropertyName() : parentLabel; + }else { + String propName=getBeElementLabelIdByBePropInfo((BefPropertyInfo) dataTypePropertyInfo); + childValue=isNullOrEmpty(returnValue)?propName:returnValue; + childLabel=isNullOrEmpty(parentLabel) ? propName : parentLabel; + } + + String udtRefPrpLabel=getUdtPropLabel(dataTypePropertyInfo.getPropertyName(),simpleAssoUdtPropertyInfo); + + if (udtRefPrpLabel != null) { + childLabel = childLabel + "." + udtRefPrpLabel; + } else { + childLabel = childLabel + "." + dataTypePropertyInfo.getPropertyName(); + } + + if(dataTypePropertyInfo.getObjectType()==ObjectType.UDT){ + //todo 多值ud后续处理 + if(dataTypePropertyInfo.getObjectInfo() instanceof ComplexUdtPropertyInfo) + continue; + initUdtElement(dataTypePropertyInfo,childLabel,childValue); + }else { + initFilterDic(childLabel,childValue); + } + } + } + private String getUdtPropLabel( String refPropName, SimpleAssoUdtPropertyInfo assoUdtPropertyInfo){ + + HashMap assoMapping=assoUdtPropertyInfo.getMapping(); + for (Map.Entry udtLabel:assoMapping.entrySet()){ + if(refPropName.equals(udtLabel.getValue())) + return udtLabel.getKey(); + } + return null; + } + + private void initFilterDic(String label,String returnValue){ + filterMap.put(label,returnValue); + + if(!label.equals(StringUtils.toCamelCase(label))){ + if(!filterMap.containsKey(StringUtils.toCamelCase(label))){ + filterMap.put(StringUtils.toCamelCase(label),returnValue); + } + } + + String labelToCamel=toCamel(label); + if(!filterMap.containsKey(labelToCamel)){ + filterMap.put(labelToCamel,returnValue); + } + } + + private String toCamel(String propName){ + if(!propName.contains(".")) + return StringUtils.toCamelCase(propName); + String[] strArray=propName.split("\\."); + int length=strArray.length; + String propLabelName=""; + for(int i=0;i=0 &&i()); +// if (!getBEType().contains(";")) { +// getBETypes().add(getBEType()); +// return; +// } +// +// String[] types = getBEType().split("[;]", -1); +// setBETypes(new ArrayList(Arrays.asList(types))); +// } + + private String funcSessionID; + + private IFSManagerContext context; + + public IFSManagerContext getBffContext() { + if (context == null) { + context = new FSManagerContext(this); + context.setVoId(getVoId()); + } + return context; + } + + private ResponseContext responseContext; + + public final ResponseContext getResponseContext() { + if (responseContext == null) { + responseContext = new ResponseContext(); + } + return responseContext; + } + + public com.inspur.edp.cef.api.resourceInfo.ModelResourceInfos getModelResourceInfos() { + return null; + } + @Override + public ModelResInfo getModelInfo() { + return null; + } + + + //region BffManager + private AbstractSourceConfig sourceConfigs = null; + + protected AbstractSourceConfig getSourceConfigs() { + return null; + } + + public AbstractSourceConfig getOutSourceConfigs() { + if(sourceConfigs == null) + sourceConfigs =getSourceConfigs(); + return sourceConfigs; + } +// protected abstract String getBEType(); + private String voType; + + private ArrayList beTypes; + + public final ArrayList getBETypes() { + return beTypes; + } + + public final void setBETypes(ArrayList value) { + beTypes = value; + } + + protected final TResult executeAction(AbstractFSAction action) { + return ActionExecutor.executeAction(action, this, getBffContext()); + } + protected final TResult executeAction(AbstractFSAction action,String actionId, String actionCode + , Map parameters) + { + return executeAction(action,actionId,actionCode,parameters,false); + } + protected final TResult executeAction( + AbstractFSAction action, + String actionId, + String actionCode, + Map parameters,boolean autuSave) + { + return ActionExecutor.executeAction(action,this,getBffContext(),actionId,actionCode,parameters,autuSave); + } + + public IVariableManager createVariableManager(){return null;} + + // region Actions + + EditableBefSessionManager getBefSessionMgr(){ + return SpringBeanUtils.getBean(EditableBefSessionManager.class); + } + + public final String connect(String parentSessionID) { + if(funcInstanceId != null) + synchronized (funcInstanceId.intern()) { + return FuncSessionManager.getCurrent().initSessionWithToken(funcInstanceId); + } + return FuncSessionManager.getCurrent().initSessionWithToken(funcInstanceId); + } + + public final void tryConnect(){ + Runnable action = () -> { + if (FuncSessionManager.getCurrentFuncSessionId() == null) { + String sessionId = FuncSessionManager.getCurrent().tryInitSessionWithToken(funcInstanceId); + ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder + .getRequestAttributes(); + HttpServletResponse response = servletRequestAttributes.getResponse(); + response.addHeader("BEFSessionID", sessionId); + } + }; + if(funcInstanceId != null){ + synchronized (funcInstanceId.intern()){ + action.run(); + } + } else{ + action.run(); + } + } + + private String voSessionKey ; + private String getVoSessionKey(){ + if(voSessionKey == null){ + voSessionKey = "Vo_".concat(getVoId()); + } + return voSessionKey; + } + + private ICefSessionItem tryGetAndAddSessionItem() { + ICefSession session = FuncSessionManager.getCurrentSession(); + ICefSessionItem sessionItem = session.getSessionItems().get(getVoSessionKey()); + return sessionItem != null ? sessionItem : initSessionItem(session); + } + + private ICefSessionItem initSessionItem(ICefSession session) { + ICefSessionItem sessionItem = buildSessionItem(); + session.getSessionItems().put(getVoSessionKey(), sessionItem); + return sessionItem; + } + + public BffSessionItem buildSessionItem() { + BffSessionItem item = new BffSessionItem(getVoId()); + IVariableManager varManager = createVariableManager(); + if (varManager != null) { + VarBufferManager varBuffer = new VarBufferManager(item, varManager, getVoSessionKey()); + varBuffer.initBuffer(); + item.setVarBufferManager(varBuffer); + } + return item; + } + + private IAccessor buildVariableAccessor(IVariableManager manager, IValueObjData data) { + return manager.getAccessorCreator().createAccessor(data); + } + + private IAccessor buildVariableReadOnlyAccessor(IVariableManager manager, IValueObjData data) { + return manager.getAccessorCreator().createReadonlyAccessor(data); + } + + public final void close() { + String sessionId = FuncSessionManager.getCurrentFuncSessionId(); + if(StringUtils.isEmpty(sessionId)) { + throw new RuntimeException("当前不存在SessionId"); + } + FuncSessionManager.getCurrent().closeSessionWithToken(sessionId); + } + + public final void cancel() { + CancelAction action = FSActionFactory.getCancelAction(); + executeAction(action); + } + + public final IEntityData retrieveDefault() { + RetrieveDefaultAction action = FSActionFactory.getRetrieveDefaultAction(); + try { + BffRetrieveDefaultEventBroker.fireBeforeRetrieveDefault(this,null,""); + IEntityData data=executeAction(action,"Tji_dbrLtEKQlOLRpOJj9Q","RetrieveDefault",new HashMap<>(),false); + BffRetrieveDefaultEventBroker.fireAfterRetrieveDefault(this,data); + return data; + }catch (Exception e){ + BffRetrieveDefaultEventBroker.fireExceptionStop(e); + throw new RuntimeException(e); + } + } + + public final IEntityData retrieveDefault(String dataId) { + RetrieveDefaultAction action = FSActionFactory.getRetrieveDefaultAction(dataId); + try { + BffRetrieveDefaultEventBroker.fireBeforeRetrieveDefault(this,null,dataId); + IEntityData data=executeAction(action,"Tji_dbrLtEKQlOLRpOJj9Q","RetrieveDefault",new HashMap<>(),false); + BffRetrieveDefaultEventBroker.fireAfterRetrieveDefault(this,data); + return data; + }catch (Exception e){ + BffRetrieveDefaultEventBroker.fireExceptionStop(e); + throw new RuntimeException(e); + } + + } + + public final IEntityData retrieveDefault(VoDefaultValue defaultValue) { + RetrieveDefaultAction action = FSActionFactory.getRetrieveDefaultAction(defaultValue); + try { + BffRetrieveDefaultEventBroker.fireBeforeRetrieveDefault(this,defaultValue,""); + IEntityData data= executeAction(action,"Tji_dbrLtEKQlOLRpOJj9Q","RetrieveDefault",new HashMap<>(),false); + BffRetrieveDefaultEventBroker.fireAfterRetrieveDefault(this,data); + return data; + }catch (Exception e){ + BffRetrieveDefaultEventBroker.fireExceptionStop(e); + throw new RuntimeException(e); + } + + } + + public final ArrayList retrieveDefaultBatch(RetrieveDefaultParam defaultParam) { + RetrieveDefaultBatchAction action = FSActionFactory.getRetrieveDefaultBatchAction(defaultParam); + return executeAction(action,"Tji_dbrLtEKQlOLRpOJj9Q","BatchRetrieveDefault",new HashMap<>(),false); + } + + public final IEntityData retrieveDefaultChild(ArrayList nodeCodes, ArrayList lierachyIds) { + RetrieveDefaultChildAction action = FSActionFactory.getRetrieveDefaultChildAction(nodeCodes, lierachyIds); + try { + BffRetrieveDefaultEventBroker.fireBeforeRetrieveDefaultChild(this,nodeCodes,lierachyIds,null,null); + IEntityData data=executeAction(action); + BffRetrieveDefaultEventBroker.fireAfterRetrieveDefaultChild(this,new ArrayList(){{add(data);}},nodeCodes); + return data; + }catch (Exception e){ + BffRetrieveDefaultEventBroker.fireExceptionStop(e); + throw new RuntimeException(e); + } + } + public final IEntityData retrieveDefaultChild(ArrayList nodeCodes, ArrayList lierachyIds,VoDefaultValue defaultValue) { + RetrieveDefaultChildWithDefaultValueAtion action = FSActionFactory.getRetrieveDefaultChildWithDefaultValueAction(nodeCodes, lierachyIds,defaultValue); + try { + BffRetrieveDefaultEventBroker.fireBeforeRetrieveDefaultChild(this,nodeCodes,lierachyIds,null,new ArrayList(){{add(defaultValue);}}); + IEntityData data=executeAction(action); + BffRetrieveDefaultEventBroker.fireAfterRetrieveDefaultChild(this,new ArrayList(){{add(data);}},nodeCodes); + return data; + }catch (Exception e){ + BffRetrieveDefaultEventBroker.fireExceptionStop(e); + throw new RuntimeException(e); + } + } + public final ArrayList retrieveDefaultChild(ArrayList nodeCodes, ArrayList lierachyIds, + RetrieveDefaultParam param) { + RetrieveDefaultChildWithDefaultValueBatchAtion action = FSActionFactory.getRetrieveDefaultChildWithDefaultValueBatchAction(nodeCodes, lierachyIds,param); + return executeAction(action); + } + public final ArrayList retrieveDefaultChilds(ArrayList nodeCodes, ArrayList lierachyIds,ArrayList defaultValues) { + MulitRetrieveDefaultWtihDefaultValueAction action = FSActionFactory.getMulitRetrieveDefaultWtihDefaultValueAction(nodeCodes, lierachyIds,defaultValues); + try { + BffRetrieveDefaultEventBroker.fireBeforeRetrieveDefaultChild(this,nodeCodes,lierachyIds,null,defaultValues); + ArrayList data=executeAction(action); + BffRetrieveDefaultEventBroker.fireAfterRetrieveDefaultChild(this,data,nodeCodes); + return data; + }catch (Exception e){ + BffRetrieveDefaultEventBroker.fireExceptionStop(e); + throw new RuntimeException(e); + } + } + public final ArrayList retrieveDefaultChild(java.util.ArrayList nodeCodes, java.util.ArrayList lierachyIds,ArrayList ids){ + RetrieveDefaultChildeWithIdsAction action=FSActionFactory.getRetrieveDefaultChildWithIdsAction(nodeCodes,lierachyIds,ids); + try { + BffRetrieveDefaultEventBroker.fireBeforeRetrieveDefaultChild(this,nodeCodes,lierachyIds,ids,null); + ArrayList data=executeAction(action); + BffRetrieveDefaultEventBroker.fireAfterRetrieveDefaultChild(this,data,nodeCodes); + return data; + }catch (Exception e){ + BffRetrieveDefaultEventBroker.fireExceptionStop(e); + throw new RuntimeException(e); + } + } + public final IEntityData retrieve(String dataID) { + RetrieveAction action = FSActionFactory.getRetrieveAction(dataID); + Map parameters = new HashMap<>(); + parameters.put("dataID",dataID); + return executeAction(action,"fQbpcO7bIEGoRdTZZIyrag","Retrieve",parameters,false); + } + + public final List retrieve(ArrayList dataIds,RetrieveParam retrieveParam) { + MultiRetrieveAction action=FSActionFactory.getMultiRetrieveAction(dataIds,retrieveParam); + Map parameters = new HashMap<>(); + parameters.put("dataIds",dataIds); + return executeAction(action,"fQbpcO7bIEGoRdTZZIyrag","Retrieve",parameters,false); + } + public final IEntityData retrieve(String dataId, RetrieveParam retrieveParam) { + RetrieveAction action = FSActionFactory.getRetrieveAction(dataId, retrieveParam); + Map parameters = new HashMap<>(); + parameters.put("dataId",dataId); + parameters.put("retrieveParam",retrieveParam); + return executeAction(action,"fQbpcO7bIEGoRdTZZIyrag","Retrieve",parameters,false); + } + + public final EditResult edit(String dataId) { + EditAction action = FSActionFactory.getEditAction(dataId); + return executeAction(action); + } + + public final IEntityData retrieveChild(ArrayList nodeCodes, ArrayList lierachyIds, RetrieveParam retrieveParam) { + //TODO 临时处理,后续改造成Action +// return getBffContext().getLcp().retrieveChild(nodeCodes, lierachyIds, retrieveParam).getData(); + RetrieveChildAction retrieveChildAction = FSActionFactory.getRetrieveChildAction(nodeCodes, lierachyIds, retrieveParam); + return executeAction(retrieveChildAction); + } + + public final ArrayList retrieveChild(ArrayList nodeCodes, ArrayList lierachyIds,ArrayList ids, RetrieveParam retrieveParam) { + //TODO 临时处理,后续改造成Action +// return getBffContext().getLcp().retrieveChild(nodeCodes, lierachyIds, retrieveParam).getData(); + RetrieveChildAndChildAction retrieveChildAction = FSActionFactory.getRetrieveChildAndChildAction(nodeCodes, lierachyIds, ids,retrieveParam); + return executeAction(retrieveChildAction); + } + public final void modify(IChangeDetail change) { + ModifyAction action = FSActionFactory.getModifyAction(change); + Map parameters =new HashMap<>(); + parameters.put("change",change); + executeAction(action,"8Wna6KaBQEOHpRJfmGMBYQ","Modify",parameters,false); + } + + public final QueryResult query(EntityFilter filter) { + QueryResult result = new QueryResult(); + try { + BffQueryEventBroker.fireBeforeQuery(getBffContext(), filter, null); + Map parameters = new HashMap<>(); + parameters.put("filter", filter); + //TODO 临时修改,后续添加filter的克隆功能。 + ArrayList sorts = filter.getSortConditions(); + copyFilter(filter); + QueryAction action = FSActionFactory.getQueryAction(filter); + ArrayList queryresult = executeAction(action, "m_6xIwJwoUy7qzsuZ6_S5A", "Query", parameters, false); + filter.setSortConditions(sorts); + result.setResult(queryresult); + result.setPagination(filter.getPagination()); + BffQueryEventBroker.fireAfterQuery(getBffContext(), filter, queryresult); + } catch (Exception e) { + BffQueryEventBroker.fireQueryUnnormalStop(e); + throw e; + } + return result; + } + + public final QueryResult queryChild(List nodeCodes,EntityFilter filter) { + QueryResult result = new QueryResult(); + ArrayList sorts = filter.getSortConditions(); + copyFilter(filter); + QueryChildAction action = FSActionFactory.getQueryChildAction( nodeCodes,filter); + ArrayList queryresult = executeAction(action); + filter.setSortConditions(sorts); + result.setResult(queryresult); + result.setPagination(filter.getPagination()); + return result; + } + + public final QueryResult queryChild(String nodeCode,EntityFilter filter) { + QueryResult result = new QueryResult(); + ArrayList sorts = filter.getSortConditions(); + copyFilter(filter); + QueryChildWithCodeAction action = FSActionFactory.getQueryChildWithCodeAction(nodeCode,filter); + ArrayList queryresult = executeAction(action); + filter.setSortConditions(sorts); + result.setResult(queryresult); + result.setPagination(filter.getPagination()); + return result; + } + private void copyFilter(EntityFilter filter){ + ArrayList sorts = filter.getSortConditions(); + if(sorts == null || sorts.size() < 1) + return; + filter.setSortConditions(new ArrayList<>()); + for(SortCondition sort : sorts){ + SortCondition newSort = new SortCondition(sort.getSortField(), sort.getSortType()); + filter.getSortConditions().add(newSort); + } + } +// public final QueryResult query(EntityFilter filter, boolean useAuth){ +// +// QueryResult result = new QueryResult(); +// Map parameters=new HashMap<>(); +// parameters.put("filter",filter); +// +// IStandardLcp lcp =getBffContext().getLcp(); +// if(!useAuth) +// { +// lcp.getBefContext().getAuthInfo().setExtType(null); +// lcp.getBefContext().getAuthInfo().setExtend1(null); +// } +// ArrayList queryResult = new ArrayList(lcp.query(filter)); +// +// if (queryResult == null) +// { +// } +// +// +// +// result.setResult(queryresult); +// result.setPagination(filter.getPagination()); +// return result; +// +// } +public final QueryResult queryWithAuthInfo(EntityFilter filter, AuthInfo authInfo) { + QueryResult queryResult; + try { + BffQueryEventBroker.fireBeforeQuery(getBffContext(), filter, authInfo); + queryResult = new QueryResult(); + QueryWithAuthInfoAction authInfoAction = FSActionFactory.getQueryWithAuthInfoAction(filter, authInfo); + ArrayList qresult = executeAction(authInfoAction); + queryResult.setResult(qresult); + queryResult.setPagination(filter.getPagination()); + BffQueryEventBroker.fireAfterQuery(getBffContext(), filter, qresult); + } catch (Exception e) { + BffQueryEventBroker.fireQueryUnnormalStop(e); + throw e; + } + return queryResult; +} + + public final List query(String param, Pagination pageInfo, String extendCond) { + +// String indexVoConfig = getSourceConfigs().getIndexVoConfig(); +// +// var indexEntity = ServiceManager.GetService().GetFSManager(indexVoConfig).DeserializeData(param); +// +// QoQueryAction action = FSActionFactory.getQoQueryAction(indexEntity, pageInfo, extendCond); +// return executeAction(action); + return null; + } + + public final void delete(String dataID) { + DeleteAction action = FSActionFactory.getDeleteAction(dataID); + Map parameters= new HashMap<>(); + parameters.put("dataID",dataID); + executeAction(action,"9sEsnADPFkCRK6ZBC0OwiA","Delete",parameters,false); + } + + public final void delete(ArrayList dataIds) { + + MultiDeleteAction action = FSActionFactory.getMultiDeleteAction(dataIds); + Map parameters= new HashMap<>(); + parameters.put("dataIDs",dataIds); + executeAction(action,"9sEsnADPFkCRK6ZBC0OwiA","Delete",parameters,false); + } + + public final void deleteAndSave(String dataID){ + DeleteAndSaveAction action = FSActionFactory.getDeleteAndSaveAction(dataID); + Map parameters= new HashMap<>(); + parameters.put("dataID",dataID); + executeAction(action,"9sEsnADPFkCRK6ZBC0OwiAAA","DeleteAndSave",parameters,false); + } + + public final void deleteChild(List nodeCodes, List hierachyIdList, List ids) { + + DeleteChildAction action = FSActionFactory.getDeleteChildAction(nodeCodes, hierachyIdList, ids); + executeAction(action); + } + + public final void save() { + + SaveAction action = FSActionFactory.getSaveAction(); + Map parameters= new HashMap<>(); + executeAction(action,"6cb6c52d-6cb3-4f26-89c0-af9bd54ccf72","Save",parameters,false); + } + + // endregion Actions + + // region abstracts + //TODO 確認是否已經不需要了 + protected abstract IChangeConvertor getChangeMapConvertor(); + + protected abstract IDataConvertor getDataConvertor(); + + protected IFilterFieldConvertor getFilterConvertor() { + return new FilterFieldConvertor(this); + } + + protected IDefaultValueConvertor getDefaultValueConvertor() { + return null; + } + + protected abstract IEntityData innerCreateData(); + + protected abstract IEntityData innerCreateChildData(String childCode); + + + public IAssemblerManager getAssemblerManager() { + return null; + } + + public final IEntityData createData(String dataID) { + IEntityData entity = innerCreateData(); + entity.setID(dataID); + tryAddExtend2RootData(entity); + return (IEntityData) getAccessorCreator().createAccessor(entity); + } + + //原CreateData抽象方法改名为CreateDataCore + public final IEntityData createData() { + IEntityData entity = innerCreateData(); + tryAddExtend2RootData(entity); + return (IEntityData) getAccessorCreator().createAccessor(entity); + } + + //原CreateChilData抽象方法改名为CreateChilDataCore + public final IEntityData createChilData(String childCode) { + return createChildData(childCode, null); + } + + public final IEntityData createChildData(String childCode, String dataID) { + if(getExtList() != null){ + for(IBffManagerExtend ext : getExtList()){ + + ICefAddedChildEntityExtend added = ext.getAddedChildEntity(childCode); + if(added == null){ + continue; + } + ICefAddedChildDataExtend dataExtend = added.getDataExtend(); + IEntityData data = (IEntityData)dataExtend.createData(); + data.setID(dataID); + return (IEntityData)dataExtend.createAccessor(data); + } + } + IEntityData childEntity = innerCreateChildData(childCode); + if (childEntity instanceof IDataExtendContainer && getExtList() != null) { + for(IBffManagerExtend mgrExt : getExtList()){ + ICefEntityExtend childEntityExt = mgrExt.getChildEntityExtend(childCode); + if(childEntityExt == null){ continue; } + ICefDataExtend dataExt = childEntityExt.getDataExtend(); + if(dataExt == null){ continue; } + ((IDataExtendContainer) childEntity).addExtend(dataExt); + } + } + childEntity.setID(dataID); + return (IEntityData) ((IEntityAccessorCreator) getAccessorCreator()).createChildAccessor(childCode, childEntity); + } + + public IEntityData createUnlistenableData(String dataID) { + IEntityData entity = innerCreateData(); + entity.setID(dataID); + tryAddExtend2RootData(entity); + return entity; + } + + + public IEntityData createUnlistenableChildData(String childCode, String dataID) { + IEntityData childEntity = innerCreateChildData(childCode); + if(childEntity instanceof IDataExtendContainer && getExtList() != null){ + for(IBffManagerExtend ext : getExtList()){ + + ICefAddedChildEntityExtend added = ext.getAddedChildEntity(childCode); + if(added == null){ + continue; + } + ICefAddedChildDataExtend dataExtend = added.getDataExtend(); + IEntityData data = (IEntityData)dataExtend.createData(); + data.setID(dataID); + return data; + } + + } + + if(childEntity instanceof IDataExtendContainer && getExtList() != null){ + for(IBffManagerExtend mgrExt : getExtList()){ + ICefEntityExtend childEntityExt = mgrExt.getChildEntityExtend(childCode); + if(childEntityExt == null){ continue; } + ICefDataExtend dataExt = childEntityExt.getDataExtend(); + if(dataExt == null){ continue; } + ((IDataExtendContainer) childEntity).addExtend(dataExt); + } + } + childEntity.setID(dataID); + + return childEntity; + } + + protected abstract AbstractBffEntitySerConvertor getDataJsonSerizlize(); + + protected abstract AbstractBffEntityDeserConvertor getDataJsonDeSerizlize(); + + private ObjectMapper getEntityJsonMapper(boolean keepAssoPropertyForExpression) { + ObjectMapper mapper = new ObjectMapper(); + SimpleModule module = new SimpleModule(); + var extList = getExtList().stream().map(item -> item.getDataTypeExtend()) + .filter(item -> item != null).collect(Collectors.toList()); + + AbstractBffEntitySerConvertor dataJsonSerizlize = getDataJsonSerizlize(); + extList.forEach(item -> dataJsonSerizlize.addExtend(item)); + module.addSerializer(ICefData.class, dataJsonSerizlize); + if(keepAssoPropertyForExpression) + { + dataJsonSerizlize.setCefSerializeContext(CefSerializeContext.getSerContextKeepAssoPropertyForExpression()); + } + + AbstractBffEntityDeserConvertor dataJsonDeSerizlize = getDataJsonDeSerizlize(); + extList.forEach(item -> dataJsonDeSerizlize.addExtend(item)); + dataJsonDeSerizlize.setManager(this); + module.addDeserializer(createData().getClass(), dataJsonDeSerizlize); + + mapper.registerModule(module); + return mapper; + } + private ObjectMapper getEntityJsonMapper(List nodeCodes) { + ObjectMapper mapper = new ObjectMapper(); + SimpleModule module = new SimpleModule(); + AbstractEntityDataSerializer serializer = getDataJsonSerizlize().getChildDataConvertor((String)nodeCodes.get(0)); + AbstractEntityDataDeSerializer deSerializer = getDataJsonDeSerizlize().getChildDataConvertor((String)nodeCodes.get(0)); + for (int i = 1; i < nodeCodes.size(); i++) { + serializer = serializer.getChildDataConvertor((String)nodeCodes.get(i)); + deSerializer = deSerializer.getChildDataConvertor((String)nodeCodes.get(i)); + } + module.addSerializer(ICefData.class, serializer); + module.addDeserializer(createChilData((String)nodeCodes.get(nodeCodes.size() - 1)).getClass(), deSerializer); + mapper.registerModule(module); + return mapper; + } + public final String serializeData(List nodeCodes, IEntityData data) { + try { + return getEntityJsonMapper(nodeCodes).writeValueAsString(data); + } catch (JsonProcessingException e) { + throw new RuntimeException("序列化失败", e); + } + } public final IEntityData deserializeData(List nodeCodes, String serializedData) { + try { + IEntityData data = (IEntityData)getEntityJsonMapper(nodeCodes).readValue(serializedData, createChilData((String)nodeCodes.get(nodeCodes.size() - 1)).getClass()); + return (IEntityData)((IEntityAccessorCreator)getAccessorCreator()).createChildAccessor((String)nodeCodes.get(nodeCodes.size() - 1), data); + } catch (IOException e) { + throw new RuntimeException("反序列化失败", e); + } + } + + @Override + public final String serializeDataForExpression(IEntityData data) { + try { + SerializerUtil.isKeepAssoPropertyForExpression().set("1"); + return getEntityJsonMapper(true).writeValueAsString(data); + } catch (JsonProcessingException e) { + throw new RuntimeException("序列化失败",e); + } + finally { + SerializerUtil.isKeepAssoPropertyForExpression().remove(); + } +// JsonConverter jsonConverter = getJsonConverter(); +// DataValidator.checkForNullReference(jsonConverter, "getJsonConverter()"); +// return JsonConvert.SerializeObject(data, jsonConverter); + } + public final String serializeData(IEntityData data) { + try { + return getEntityJsonMapper(false).writeValueAsString(data); + } catch (JsonProcessingException e) { + throw new RuntimeException("序列化失败",e); + } +// JsonConverter jsonConverter = getJsonConverter(); +// DataValidator.checkForNullReference(jsonConverter, "getJsonConverter()"); +// return JsonConvert.SerializeObject(data, jsonConverter); + } + + public final IEntityData deserializeData(String serializedData) { + try { +// new ObjectMapper().readValue(serializedData, new ArrayList().getClass()); + IEntityData data = getEntityJsonMapper(false).readValue(serializedData, createData().getClass()); + return (IEntityData) getAccessorCreator().createAccessor(data); + } catch (IOException e) { + throw new RuntimeException("反序列化失败",e); + } +// JsonConverter jsonConverter = getJsonConverter(); +// DataValidator.checkForNullReference(jsonConverter, "getJsonConverter()"); + +// var data = (IEntityData) JsonConvert.DeserializeObject(serializedData, innerCreateData().getClass(), jsonConverter); + //return (IEntityData) getAccessorCreator().createAccessor(data); + } + + @Override + public String serializeChanges(List arrayList) { + try { + return getChangeJsonMapper().writeValueAsString(arrayList); + } catch (JsonProcessingException e) { + throw new RuntimeException("变更集序列化异常", e); + } + } + + @Override + public ArrayList deserializeChanges(String strChange) { + ArrayList changeDetails = null; + try { + var mapper = getChangeJsonMapper(); + JavaType type = mapper.getTypeFactory(). + constructCollectionType(ArrayList.class, IChangeDetail.class); + changeDetails = mapper.readValue(strChange, type); + } catch (IOException e) { + throw new RuntimeException("变更集反序列化异常", e); + } + return changeDetails; + } + + protected abstract AbstractBffChangeJsonSerializer getChangeSerializer(); + + protected abstract AbstractBffChangeJsonDeserializer getChangeDeserializer(); + + private ObjectMapper getChangeJsonMapper() { + ObjectMapper mapper = new ObjectMapper(); + SimpleModule module = new SimpleModule(); + var extList = getExtList().stream().map(item -> item.getDataTypeExtend()) + .filter(item -> item != null).collect(Collectors.toList()); + + AbstractBffChangeJsonSerializer ser = getChangeSerializer(); + extList.forEach(item -> ser.addExtend(item)); + module.addSerializer(IChangeDetail.class, ser); + + var deSer = getChangeDeserializer(); + extList.forEach(item -> deSer.addExtend(item)); + deSer.setManager(this); + deSer.setCefSerializeContext(new CefSerializeContext()); + module.addDeserializer(IChangeDetail.class, deSer); + + mapper.registerModule(module); + return mapper; + } + + public final String serializeChange(IChangeDetail change) { + + try { + return getChangeJsonMapper().writeValueAsString(change); + }catch (JsonProcessingException e) + { + throw new RuntimeException(e); + } + + } + + public final IChangeDetail deserializeChange(String strChange) { + + try { + return getChangeJsonMapper().readValue(strChange, IChangeDetail.class); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + +// private String serializeChanges(ArrayList changes) { +// return JsonConvert.SerializeObject(changes, GetChangeConvertor()); +// } +// +// private ArrayList deserializeChange(String strChanges) { +// return JsonConvert.>DeserializeObject(strChanges, GetChangeConvertor()); +// } + + protected abstract String getBECodeFromVM(String vmObjectCode); + + protected abstract String getVMCodeFromBE(String beObjectCode); + + //子类实现 + protected IEntityPropertyMapper getRootEntityPropertyMapper(){ + return null; + } + + // endregion + + protected final void setContext(AbstractFSManager mgr) { + mgr.setContext(this.getBffContext()); + } + + public final LookupResult getElementHelp(String codeName, String labelId, String queryParam) { + LookupQueryParam target = null; + if (!StringUtils.isEmpty(queryParam)) { + try { + target = new ObjectMapper().readValue(queryParam, LookupQueryParam.class); + } catch (IOException e) { + throw new RuntimeException("LookupQueryParam反序列化失败",e); + } +// target = JsonConvert.DeserializeObject(queryParam); + } + if (target == null) { + target = new LookupQueryParam(); + } + + return getElementHelp(codeName, labelId, target); + } + + private ILookupService lookupService; + private ILookupService getLookupService(){ + if(lookupService == null){ + lookupService = CefBeanUtil.getAppCtx().getBean(ILookupService.class); + } + return lookupService; + } + private LookupDataService lookupDataService; + private LookupDataService getLookupDataService(){ + if(lookupDataService == null){ + lookupDataService = CefBeanUtil.getAppCtx().getBean(LookupDataService.class); + } + return lookupDataService; + } + + public final LookupResult getElementHelp(String codeName, String labelId, + LookupQueryParam queryParam) { + Objects.requireNonNull(codeName); + Objects.requireNonNull(labelId); + + String helpId = null; + //TODO 目前由于项目问题,临时修改先走扩展再走基,后续需要讨论 + VMHelpConfig helpConfig =FSManagerExtendUtil.getHelpConfig(getExtList(), codeName, labelId); + if (helpConfig == null) { + helpConfig = getHelpConfig(codeName, labelId); + } + if (helpConfig == null) {//发现一些很老的基础字典没有生成getHelpConfig方法, 在这里兼容 + helpId = getHelpId(codeName, labelId); + if (getHelpActions(codeName, labelId).size() > 0) { + for (IHelpExtend item : getHelpActions(codeName, labelId)) { + ((AbstractFSAction) item).deal(getBffContext()); + item.beforeHelp(queryParam); + } + } + } else { + helpId = helpConfig.getHelpId(); + + ArrayList actionRecord = helpConfig.getActionRecord(); + ComponentInvokeService componentInvokeService = SpringBeanUtils.getBean(ComponentInvokeService.class); + if (actionRecord != null) { + for (ReflectInfo item : actionRecord) { + if(item.getParameterInfoList()!=null && !item.getParameterInfoList().isEmpty()) + { + List parameters = new ArrayList<>(1); + parameters.add(item.getParameterInfoList()); + IHelpExtend instance; + if (item.getComponentID() != null && !item.getComponentID().isEmpty()) { + instance = (IHelpExtend) componentInvokeService.getInstance(item.getComponentID(), parameters); + } else { + instance = (IHelpExtend) createInstance(item.getClassName(), item.getParameterInfoList()); + } + ((AbstractFSAction)instance).deal(getBffContext()); + instance.beforeHelp(queryParam); + } + else { + IHelpExtend instance; + if (item.getComponentID() != null && !item.getComponentID().isEmpty()) { + instance = (IHelpExtend) componentInvokeService.getInstance(item.getComponentID()); + } else { + instance = (IHelpExtend) createInstance(item.getClassName()); + } + ((AbstractFSAction)instance).deal(getBffContext()); + instance.beforeHelp(queryParam); + } + } + } + if (helpConfig != null && helpConfig.getUseCustomAuthInfo() && queryParam != null) { + queryParam.setAuthInfo(new AuthInfo()); + queryParam.getAuthInfo().setExtType("VoHelp"); + queryParam.getAuthInfo().setExtend1(helpConfig.getVoID()); + queryParam.getAuthInfo().setExtend2(helpConfig.getHelpElementID()); + } + } + if("47273c90-0a06-487f-a9d2-11e0fe902d90".equals(helpId) ||"802cebf2-fd97-445d-bdb7-e1d8150b1e4b".equals(helpId)) { + + return getLookupDataService().getData(helpId, queryParam); + } + return getLookupService().getData(helpId, queryParam); + } + + private List getCompParams(List parameterInfoList) { + List parameters = new ArrayList<>(parameterInfoList.size()); + for (ParameterInfo parameterInfo : parameterInfoList) { + parameters.add(parameterInfo.getParameterValue()); + } + return parameters; + } + + protected VMHelpConfig getHelpConfig(String codeName,String labelId) { + return null; + } + + protected Object createInstance(String classFullName) { + try { + Class c = Class.forName(classFullName); + return c.getConstructor((Class[]) null).newInstance((Object[]) null); + } catch (InstantiationException + | IllegalAccessException + | InvocationTargetException + | NoSuchMethodException + | ClassNotFoundException e) { + throw new RuntimeException("无法实例化类型" + classFullName,e); + } + } + + protected Object createInstance(String classFullName, List parameterInfoList) { + try { + Class c = Class.forName(classFullName); + return c.getConstructor(new Class[]{java.util.List.class}).newInstance(parameterInfoList); + } catch (InstantiationException + | IllegalAccessException + | InvocationTargetException + | NoSuchMethodException + | ClassNotFoundException e) { + throw new RuntimeException("无法实例化类型" + classFullName,e); + } + } + + protected abstract String getHelpId(String codeName, String labelId); + + protected ArrayList getHelpActions(String codeName, String labelId) { + return new ArrayList(); + } + + public java.lang.Class getDefaultValueType() { + return null; + } + + public java.lang.Class getChangeInfoType() { + return null; + } + + public java.lang.Class getRequsetType() { + return null; + } + + public ResponseInfo createResponse() { + return null; + } + + public RequestInfo buildRequest(String requestStr,CefSerializeContext context){ + ObjectMapper mapper = new ObjectMapper(); + SimpleModule module = new SimpleModule(); + var deSer = getRequestConvertor(); + deSer.setContext(context); + var extList = getExtList().stream().map(item -> item.getDataTypeExtend()) + .filter(item -> item != null).collect(Collectors.toList()); + deSer.setExtList(extList); + + module.addDeserializer(RequestInfo.class, deSer); + mapper.registerModule(module); + try { + return mapper.readValue(requestStr, RequestInfo.class); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + protected RequestConvertor getRequestConvertor(){ + //此默认实现,为了兼容原有生成的代码, + Class requestType = getRequsetType(); + var annotation = (JsonDeserialize)requestType.getAnnotation(JsonDeserialize.class); + if (annotation == null) + throw new RuntimeException("生成的Request类有问题,没有注解JsonDeserialize"); + var convertorType = annotation.using(); + try { + return (RequestConvertor)convertorType.newInstance(); + } catch (InstantiationException | IllegalAccessException e) { + throw new RuntimeException("反序列化类"+convertorType.getName()+"实例化失败"); + } + } + + public final void dealRequest(RequestInfo request) { + if (request == null) { + return; + } + SessionEditToken token = null; + if(getBefSessionMgr().getCurrentSessionId()!= null) { + token = getBefSessionMgr().beginEdit(); + } + try { + if (request.getDataChange() != null && request.getDataChange().size() > 0) { + + for (IChangeDetail changeDetail : request.getDataChange()) { + modify(changeDetail); + } + } + + if (request.getVariableChange() != null) { + dealVariable(request.getVariableChange()); + } + } finally { + if(token!= null) + getBefSessionMgr().endEdit(token); + } + } + + public final void dealVariable(IChangeDetail change) { +// FuncSession session= FuncSessionManager.getCurrentSession(); + IVariableManager varManager = createVariableManager(); + //TODO 发版后放开 +// if(varManager == null) +// throw new RuntimeException(getVoType()+"中没有设置变量,不允许写入变量值"); + + IValueObjData data = (IValueObjData) ((tryGetAndAddSessionItem().getVariableBuffers().get(0).getData()) ); + Object tempVar = varManager.createValueObject(data); + IVariable variableEntity = (IVariable) ((tempVar instanceof IVariable) ? tempVar : null); + + EntityDataChangeListener listener = tryGetAndAddSessionItem().getVarListener(); + listener.suspend(); + try { + variableEntity.modify(change); + getResponseContext().setVariableInnerChange(variableEntity.getVariableContext().getInnerChange()); + } finally { + listener.resume(); + } + } + + public final ResponseInfo buildResponse(Object returnValue) { + ResponseInfo response = createResponse(); + response.setReturnValue(returnValue); + response.setInnerDataChange(getResponseContext().getInnerChangeset()); + response.setMessage(getResponseContext().getMessages()); + response.setInnerVariableChange(getResponseContext().getVariableInnerChange()); + return response; + } + + public final ICefData getVariableData() { + ICefBuffer buffer= tryGetAndAddSessionItem().getVariableBuffers().get(0); + return buffer.getData(); + } + + public final EntityDataChangeListener getVariableListener() { + return tryGetAndAddSessionItem().getVarListener(); + } + +// @Override +// public IRootManagerContext getRootContext() { +// return null; +//// } + + @Override + public IRootRepository getRepository() { + return null; + } + // endregion + + // region Impl + +// public final ICefEntity createEntity(String id) +// { +// return super.createEntity(id); +// } + + public final IEntityData createDataType() { + return createData(); + } + + @Override + public String serialize(ICefData data) { + return serializeData((IEntityData) data); + } + + @Override + public ICefData deserialize(String content) { + return deserializeData(content); + } + + @Override + protected IRootManagerContext createRootManagerContext() { + FSManagerContext fsContext = new FSManagerContext(this); + fsContext.setVoId(getVoId()); + return fsContext; + } + + @Override + protected IRootEntityCacheManager createEntityCacheManager() { + return null; + } + + @Override + protected IBufferManager createBufferManager() { + return null; + } + + @Override + protected final IChangesetManager createChangesetManager() { + return null; + } + + @Override + protected final ICefRootEntity newEntity(String id) { + var entity = (ViewObjectEntity) createVoEntity(id); + if (extList != null) { + entity.setExtend( + extList.stream().map(item -> item.getDataTypeExtend()).filter(item -> item != null) + .collect(Collectors.toList())); + } + return entity; + } + + protected abstract ICefRootEntity createVoEntity(String id); + + //region [运行时定制]扩展 + private List extList = new ArrayList<>(); + List getExtList(){ + return extList; + } + + private List extClassList = new ArrayList<>(); + public List getExtClassList(){ + return extClassList; + } + protected void addExtClass (Class extClass){ + extClassList.add(extClass); + } + + public void addExtend(IBffManagerExtend ext) { + Objects.requireNonNull(ext, "ext"); + extList.add(ext); + } + + protected void tryAddExtend2RootData(ICefData data){ + if(!(data instanceof IDataExtendContainer)){ + return; + } + if(extList.isEmpty()){ + return; + } + IDataExtendContainer container = (IDataExtendContainer) data; + for (IBffManagerExtend mgrExt : extList){ + IBffEntityExtend dataTypeExtend = mgrExt.getDataTypeExtend(); + if(dataTypeExtend == null){ + continue; + } + IBffEntityDataExtend dataExt = dataTypeExtend.getDataExtend(); + if(dataExt == null){ + continue; + } + container.addExtend(dataExt); + } + } + + public String getVoType() { + if(voType == null) + voType = getModelResourceInfos().getModelDispalyName(); + return voType; + } + + public void setVoType(String voType) { + this.voType = voType; + } + + public String getVoNodeCode(String frontNodeCode) { + return null; + }; + //endregion + @Override + public RetrieveResult retrieveWithChildPagination(String dataId, com.inspur.edp.bff.api.param.retrieve.RetrieveParam param){ + RetrieveWithChildPaginationAction action= FSActionFactory.getRetrieveWithChildPagination(dataId,param); + return executeAction(action); + } + @Override + public RetrieveChildResult retrieveChildByIndex(ArrayList nodeCodes,ArrayList hierachyIds, Pagination pagination) + { + RetrieveChildByIndexAction action = FSActionFactory.getRetrieveChildByIndexAction(nodeCodes, hierachyIds, pagination); + return executeAction(action); + } + + + //region new mode + public Object executeCustomAction(String actionCode, LinkedHashMap params){ + + RefObject result = new RefObject<>(new Object()); + for (IBffManagerExtend mgrExt : extList){ + boolean hasExecute = mgrExt.invokeAction(actionCode, result, (FSManagerContext)getBffContext(), params); + if(hasExecute) + return result.argvalue; + + } + throw new RuntimeException("找不到动作" + actionCode); + } + + public void deleteAndSave(ArrayList dataIds){ + getBffContext().getLcp().atomicallyInvoke(()->{ + delete(dataIds); + save(); + }); + } + + public boolean isEngine(){ + return false; + } + + /** + * 解析型ResponseInfo序列化调用 + * @return 序列化结果 + */ + public String serializeResponseInfo(ResponseInfo responseInfo, CefSerializeContext context){ + ObjectMapper mapper; + try { +// + mapper = JSONSerializer.getObjectMapper().copy(); +// JavaTimeModule timeModule = new JavaTimeModule(); +// LocalDateTimeDeserializer deserializer = new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS a")); +// timeModule.addDeserializer(LocalDateTime.class, deserializer); +// mapper.registerModule(timeModule); +// mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); + ResponseConvertor convertor = getResponseConvertor(); + if(convertor != null && (context != null && context.getJsonFormatType() == JsonFormatType.Tiled)){ + SimpleModule module = new SimpleModule(); + setResponseExtList(convertor,this.getExtList()); + convertor.setContext(context); + module.addSerializer(responseInfo.getClass(), convertor); + mapper.registerModule(module); + mapper.configure(MapperFeature.USE_ANNOTATIONS, false); + } + return mapper.writeValueAsString(responseInfo); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + private void setResponseExtList(ResponseConvertor convertor, List bffManagerExtends){ + if(bffManagerExtends==null || bffManagerExtends.size()==0) + return; + ArrayList bffEntityExtends=new ArrayList<>(); + for (IBffManagerExtend managerExtend:this.getExtList()){ + bffEntityExtends.add(managerExtend.getDataTypeExtend()); + } + if(bffEntityExtends.size()>0){ + convertor.setExtList(bffEntityExtends); + } + } + protected ResponseConvertor getResponseConvertor(){ + return null; + } + + + public ArrayList convertChangefromVo(ArrayList voChanges){ + ChangeMapperContext mapperContext = new ChangeMapperContext(); + mapperContext.setSourceChange(voChanges); + getAssemblerManager().getChangeMapperAssembler().doChangeMappingFromVo(getBffContext(), mapperContext); + return mapperContext.getMappedChange().values().stream().findFirst().get(); + } + + public ArrayList convertChange2Vo(ArrayList sourceChanges){ + ArrayList voChanges = new ArrayList(); + IChangeConvertor convertor = getChangeMapConvertor(); + for(IChangeDetail sourceChange : sourceChanges){ + IChangeDetail voChange = convertor.convertFromBEChange(sourceChange); + voChanges.add(voChange); + } + return voChanges; + } + + + @Override + public IEntityData createAndSave(IEntityData data) { + IStandardLcp lcp = (IStandardLcp) getBffContext().getLcp(); + IEntityData beData = lcp.createUnlistenableData(data.getID()); + getBffContext().getDataConvertor().convertFromVMData(data, beData); + beData = lcp.retrieveDefault(beData); + lcp.save(); + return retrieve(beData.getID()); + } + + @Override + public IEntityData modifyAndSave(IEntityData data) { + IStandardLcp lcp = (IStandardLcp) getBffContext().getLcp(); + IEntityData beData = lcp.createUnlistenableData(data.getID()); + getBffContext().getDataConvertor().convertFromVMData(data, beData); + lcp.modify(beData); + lcp.save(); + return retrieve(data.getID()); + } + private final static String FuncInstanceId = "Func-Inst-Id"; + + private static List headers = Arrays.asList(FuncInstanceId); + @Override + public List getAcceptHeaderNames(){ + return headers; + } + + @Override + public void setHeader(String name, String value){ + Objects.requireNonNull(name, "name"); + switch(name) + { + case FuncInstanceId: + setFuncInstanceId(value); + break; + } + } + + private String funcInstanceId = null; + public void setFuncInstanceId(String id){ + this.funcInstanceId = id; + } + + private SessionEditToken locked; + @Override + public void onBeforeRequest(){ + locked = getBefSessionMgr().getCurrentSessionId() != null ? getBefSessionMgr().beginEdit() + : null; +// FuncSession currentSession = FuncSessionManager.getCurrentSession(); +// if(currentSession == null){ +// return; +// } +// Lock lock = currentSession.getSessionLock().writeLock(); +// lock.lock(); +// locked = lock; + } + + @Override + public void onFinallyRequest(){ + if(locked == null) { + return; + } + getBefSessionMgr().endEdit(locked); + } + + /** + * @param nodeCodes 除主表外,从上级到下级的节点编号 + * @param nodeJson 前端传过来的json串 + * @return + */ + public ArrayList deserializeVoDefaultValues(List nodeCodes, String nodeJson) { + if(nodeCodes == null || nodeCodes.size() ==0){ + return deserializeVoDefaultValues(nodeJson); + } + VoDefaultValueChildDeserializer deserializer=new VoDefaultValueChildDeserializer(getBffContext().getBffManager(), (ArrayList) nodeCodes); + ArrayList voDefaultValues; + try { + + ObjectMapper mapper = getDefaultValueMapper(deserializer); + JavaType type = mapper.getTypeFactory(). + constructCollectionType(ArrayList.class, VoDefaultValue.class); + voDefaultValues = mapper.readValue(nodeJson, type); + } catch (IOException e) { + throw new RuntimeException("VoDefaulValue反序列化失败", e); + } + + return voDefaultValues; + } + + public ArrayList deserializeVoDefaultValues(String nodeJson) { + VoBuiltInDefaultValueDeserializer deserializer=new VoBuiltInDefaultValueDeserializer(getBffContext().getBffManager()); + ArrayList voDefaultValues; + try { + + ObjectMapper mapper = getDefaultValueMapper(deserializer); + JavaType type = mapper.getTypeFactory(). + constructCollectionType(ArrayList.class, VoDefaultValue.class); + voDefaultValues = mapper.readValue(nodeJson, type); + } catch (IOException e) { + throw new RuntimeException("VoDefaulValue反序列化失败", e); + } + + return voDefaultValues; + } + + public VoDefaultValue deserializeVoDefaultValue(List nodeCodes,String nodeJson){ + if(nodeCodes == null) + return deserializeVoDefaultValue(nodeJson); + VoDefaultValueChildDeserializer deserializer=new VoDefaultValueChildDeserializer(getBffContext().getBffManager(), (ArrayList) nodeCodes); + VoDefaultValue voDefaultValue; + try { + voDefaultValue = getDefaultValueMapper(deserializer).readValue(nodeJson, VoDefaultValue.class); + } catch (IOException e) { + throw new RuntimeException("VoDefaulValue反序列化失败", e); + } + + return voDefaultValue; + } + + public VoDefaultValue deserializeVoDefaultValue(String nodeJson){ + VoBuiltInDefaultValueDeserializer deserializer=new VoBuiltInDefaultValueDeserializer(getBffContext().getBffManager()); + VoDefaultValue voDefaultValue ; + try { + voDefaultValue = getDefaultValueMapper(deserializer).readValue(nodeJson, VoDefaultValue.class); + } catch (IOException e) { + throw new RuntimeException("VoDefaulValue反序列化失败", e); + } + + return voDefaultValue; + } + + private ObjectMapper getDefaultValueMapper(VoBuiltInDefaultValueDeserializer deserializer){ + ObjectMapper mapper = new ObjectMapper(); + SimpleModule module=new SimpleModule(); + module.addDeserializer(VoDefaultValue.class,deserializer); + mapper.registerModule(module); + return mapper; + } + + public RetrieveDefaultParam deserializerRetrieveDefaultParam(String nodeJson){ + return deserializerRetrieveDefaultParam(null, nodeJson); + } + + public RetrieveDefaultParam deserializerRetrieveDefaultParam(List nodeCodes,String nodeJson){ + ObjectMapper mapper=new ObjectMapper(); + RetrieveDefaultParam param=new RetrieveDefaultParam(); + try { + JsonNode node=mapper.readTree(nodeJson); + + ArrayList defaultValues=deserializeVoDefaultValues( nodeCodes, node.get("defaultValues").toString()); + param.getVoDefaultValues().addAll(defaultValues); + return param; + } catch (IOException e) { + throw new RuntimeException("[retrieveDefaultParam]节点反序列化失败!"); + } + } + + + private TimeStampContext enableTimeStampLastModifiedBy; + public TimeStampContext getTimeStampContext(){ + if(this.enableTimeStampLastModifiedBy==null){ + this.enableTimeStampLastModifiedBy= new TimeStampContext(); + } + return this.enableTimeStampLastModifiedBy; + } + + public void setTimeStampContext(TimeStampContext value){ + this.enableTimeStampLastModifiedBy=value; + } + + public final List getDistinctFJM(String fjnPropertyName, EntityFilter filter, Integer parentLayer,AuthInfo authInfo) + { + if(getBffContext().getFilterConvertor()!=null) + { + fjnPropertyName=getBffContext().getFilterConvertor().transFilterField(fjnPropertyName); + if(filter.getFilterConditions()!=null) + for(FilterCondition filterCondition:filter.getFilterConditions()) + { + filterCondition.setFilterField(getBffContext().getFilterConvertor().transFilterField(filterCondition.getFilterField())); + } + if(filter.getSortConditions()!=null) + for(SortCondition sortCondition:filter.getSortConditions()) + { + sortCondition.setSortField(getBffContext().getFilterConvertor().transFilterField(sortCondition.getSortField())); + } + } + + IStandardLcp lcp =getBffContext().getLcp(); + if(authInfo!=null&&authInfo.getExtType()!=null&&"".equals(authInfo.getExtType())==false) { + AuthUtils.buildAuthInfo( + lcp.getBefContext().getAuthInfo(), + authInfo.getExtType(), + authInfo.getExtend1(), + authInfo.getExtend2(), + authInfo.getExtend3(), + authInfo.getExtend4(), + authInfo.getExtend5() + ); + } + return lcp.getDistinctFJM(fjnPropertyName,filter,parentLayer); + } +} -- Gitee From f24606148e741abb70f189cefdca149c69bbd437 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Thu, 27 Oct 2022 10:23:28 +0800 Subject: [PATCH 28/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增新增扩展操作接口 --- .../IExtendRetrieveDefaultAssembler.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendRetrieveDefaultAssembler.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendRetrieveDefaultAssembler.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendRetrieveDefaultAssembler.java new file mode 100644 index 0000000..8f7194d --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendRetrieveDefaultAssembler.java @@ -0,0 +1,28 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.assembler; + +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.context.RetrieveDefaultContext; + +public interface IExtendRetrieveDefaultAssembler { + void doBeforeRetrieveDefault(IFSManagerContext context, RetrieveDefaultContext createContext); + + void doRetrieveDefault(IFSManagerContext context, RetrieveDefaultContext createContext); + + void doAfterRetrieveDefault(IFSManagerContext context, RetrieveDefaultContext createContext); +} -- Gitee From 5ca38629efd1969d121496b44ae881c9bec7c620 Mon Sep 17 00:00:00 2001 From: qinxinyuan Date: Thu, 27 Oct 2022 10:45:51 +0800 Subject: [PATCH 29/81] =?UTF-8?q?pom=EF=BC=8Cspring=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bff-framework-core/pom.xml | 96 +++++++++++++++++++ .../main/resources/META-INF/spring.factories | 1 + 2 files changed, 97 insertions(+) create mode 100644 bff-framework-core/pom.xml create mode 100644 bff-framework-core/src/main/resources/META-INF/spring.factories diff --git a/bff-framework-core/pom.xml b/bff-framework-core/pom.xml new file mode 100644 index 0000000..1c9625e --- /dev/null +++ b/bff-framework-core/pom.xml @@ -0,0 +1,96 @@ + + + 4.0.0 + + com.inspur.edp + bff-framework-core + 0.1.1 + + + + com.inspur.edp + bff-api + ${project.version} + + + com.inspur.edp + cef-core + ${cef.version} + + + com.inspur.edp + lcm-metadata-api + + + io.iec.edp + caf-boot-commons-json + + + com.inspur.edp + cm-api + compile + + + com.inspur.edp + bef-api + + + com.inspur.edp + bef-core + + + io.iec.edp + caf-boot-starter-context + 0.2.6 + + + com.inspur.edp + bff-spi + ${project.version} + compile + + + com.inspur.edp + caf-cef-rt-spi + ${caf.cef.rt.version} + + + com.inspur.edp + caf-cef-rt-api + 0.1.2 + + + io.iec.edp + caf-boot-commons-utils + 0.2.3 + + + com.inspur.edp + bef-auditconfig-api + 0.1.1 + + + io.iec.edp + caf-framework-audit-api + 0.2.2 + + + com.inspur.edp + bef-spi + + + com.inspur.edp + bef-entity + + + com.inspur.edp + web-help-api + + + com.inspur.edp + cm-core + + + diff --git a/bff-framework-core/src/main/resources/META-INF/spring.factories b/bff-framework-core/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..73ead31 --- /dev/null +++ b/bff-framework-core/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.inspur.edp.bff.core.session.BeanConfiguration \ No newline at end of file -- Gitee From 0b3e228bf93557731b89b20c09369c75a621c3c6 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Thu, 27 Oct 2022 11:37:23 +0800 Subject: [PATCH 30/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增保存扩展操作接口 --- .../assembler/IExtendSaveAssembler.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendSaveAssembler.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendSaveAssembler.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendSaveAssembler.java new file mode 100644 index 0000000..4b88701 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendSaveAssembler.java @@ -0,0 +1,27 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.assembler; + +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.context.SaveContext; + +public interface IExtendSaveAssembler { + + void doBeforeSave(IFSManagerContext context, SaveContext saveContext); + + void doAfterSave(IFSManagerContext context, SaveContext saveContext); +} -- Gitee From ff8c2a5c4f91f958a154e4075be1dfbe13f90c27 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Thu, 27 Oct 2022 14:37:55 +0800 Subject: [PATCH 31/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增检索扩展操作接口 --- .../assembler/IExtendRetrieveAssembler.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendRetrieveAssembler.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendRetrieveAssembler.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendRetrieveAssembler.java new file mode 100644 index 0000000..47bf4ac --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IExtendRetrieveAssembler.java @@ -0,0 +1,28 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.assembler; + +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.context.RetrieveContext; + +public interface IExtendRetrieveAssembler { + void doBeforeRetrieve(IFSManagerContext context, RetrieveContext retrieveContext); + + void doRetrieve(IFSManagerContext context, RetrieveContext retrieveContext); + + void doAfterRetrieve(IFSManagerContext context, RetrieveContext retrieveContext); +} -- Gitee From 5d9746406db936c8fc0d359ef772465ce1dbee99 Mon Sep 17 00:00:00 2001 From: qinxinyuan Date: Thu, 27 Oct 2022 16:18:24 +0800 Subject: [PATCH 32/81] =?UTF-8?q?=E7=B1=BB=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bff/core/manager/FSManagerContext.java | 437 ++++++++++++++++++ .../BffIncrementSerializerUtilConf.java | 13 + 2 files changed, 450 insertions(+) create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/manager/FSManagerContext.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/BffIncrementSerializerUtilConf.java diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/manager/FSManagerContext.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/manager/FSManagerContext.java new file mode 100644 index 0000000..592a971 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/manager/FSManagerContext.java @@ -0,0 +1,437 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.manager; + +import com.inspur.edp.bef.api.lcp.ILcpFactory; +import com.inspur.edp.bef.api.lcp.IStandardLcp; +import com.inspur.edp.bff.api.attribute.AbstractSourceConfig; +import com.inspur.edp.bff.api.dataprocessor.IChangeConvertor; +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.api.dataprocessor.IDefaultValueConvertor; +import com.inspur.edp.bff.api.dataprocessor.IEntityPropertyMapper; +import com.inspur.edp.bff.api.dataprocessor.IFilterFieldConvertor; +import com.inspur.edp.bff.api.manager.*; +import com.inspur.edp.bff.api.manager.assembler.IAssemblerManager; +import com.inspur.edp.bff.spi.AbstractDataConvertor; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.bff.api.extend.*; +import com.inspur.edp.bff.spi.event.query.BffQueryEventBroker; +import com.inspur.edp.bff.spi.utils.AuthUtils; +import com.inspur.edp.cef.api.changeListener.EntityDataChangeListener; +import com.inspur.edp.cef.api.manager.action.IMgrActionExecutor; +import com.inspur.edp.cef.core.rootmanager.BaseRootManagerContext; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import com.inspur.edp.cef.entity.entity.ICefData; +import com.inspur.edp.cef.entity.entity.IEntityData; +import com.inspur.edp.cef.spi.entity.resourceInfo.EntityResInfo; +import com.inspur.edp.cef.spi.entity.resourceInfo.ModelResInfo; +import io.iec.edp.caf.runtime.config.CefBeanUtil; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class FSManagerContext extends BaseRootManagerContext implements IFSManagerContext { + + private FSManager manager; + private IAssemblerManager assemblerManager; + private String sessionId; + private String voId; + private EntityDataChangeListener varListener; + private ICefData variableData; + private ILcpFactory lcpFactory; + + public FSManagerContext(FSManager manager) { + this.manager = manager; + assemblerManager = this.manager.getAssemblerManager(); + } + + public final IAssemblerManager getAssemblerManager() { + return assemblerManager; + } + + public IFSManager getBffManager() { + return manager; + } + + public final IEntityData createData() { + return manager.innerCreateData(); + } + + public final IEntityData createData(String objectCode) { + return manager.innerCreateChildData(objectCode); + } + + public final TResult executeAction(IFSAction action) { + return ActionExecutor.executeAction((AbstractFSAction) action, manager, this); + } + @Override + public TResult executeAction(IFSAction action, String actionId, String actionCode, Map parameters) + { + return this.executeAction(action,actionId,actionCode,parameters,false); + } + @Override + public TResult executeAction(IFSAction action, String actionId, String actionCode, Map parameters,boolean autoSave) { + return ActionExecutor.executeAction((AbstractFSAction) action,manager,this,actionId,actionCode,parameters,autoSave); + } + + public final void processResponse() { + ActionExecutor.processResponse(manager, this); + } + + public final String getBECodeFromVM(String vmObjectCode) { + return manager.getBECodeFromVM(vmObjectCode); + } + + public final String getVoId() { + return voId; + } + + public final void setVoId(String value) { + voId = value; + } + + public boolean isUseAuth() { + return useAuth; + } + + public void setUseAuth(boolean useAuth) { + this.useAuth = useAuth; + } + + private boolean useAuth = true; + + + public final IChangeDetail getVariableInnerChange() { + if (varListener == null) { + return null; + } + IChangeDetail rez = varListener.getChange(); + varListener.clear(); + return rez; + } + + @Override + public String getVoCode(String frontVoCode) { + return manager.getVoNodeCode(frontVoCode); + } + + public final ICefData getVariableData() { + if (variableData == null) { + variableData = manager.getVariableData(); + varListener = manager.getVariableListener(); + } + return variableData; + } + + public final IChangeConvertor getChangeConvertor() { + return manager.getChangeMapConvertor(); + } + + @Override + public final IEntityPropertyMapper getRootEntityPropertyMapper() { + return manager.getRootEntityPropertyMapper(); + } + + public final IDataConvertor getDataConvertor() { + + AbstractDataConvertor dataConvertor = (AbstractDataConvertor) manager.getDataConvertor(); +// if (dataConvertor instanceof AbstractDataConvertor absConverter) +// { +// absConverter.FSManager = this.getBffManager(); +// } + if(dataConvertor == null) + throw new RuntimeException("未找到数据转换器,请设置扩展数据映射操作"); + dataConvertor.setFSManager(this.getBffManager()); + return dataConvertor; + } + + public final IFilterFieldConvertor getFilterConvertor() { + return manager.getFilterConvertor(); + } + + public final IDefaultValueConvertor getDefaultValueConvertor() { + return manager.getDefaultValueConvertor(); + } + + public final HashMap getLcps() { + HashMap lcps = new HashMap(); + if (manager.getOutSourceConfigs() != null && getSourceConfigs() != null && getSourceConfigs().size() > 0) { + for (SourceConfig sourceConfig : getSourceConfigs()) { + if (sourceConfig.getSourceType() == SourceType.Qo || DotNetToJavaStringHelper.isNullOrEmpty(sourceConfig.getSourceConfigId())) { + continue; + } + IStandardLcp lcp = getLcp(sourceConfig.getSourceConfigId()); + lcp.getBefContext().setEnableTimeStampLastModifiedBy(getBffManager().getTimeStampContext().isEnableTimeStampLastModifiedBy()); + lcps.put(sourceConfig.getSourceConfigId(), lcp); + } + } + +// for (String beType : manager.getBETypes()) { +// if (DotNetToJavaStringHelper.isNullOrEmpty(beType)) { +// continue; +// } +// IStandardLcp lcp = getLcp(beType); +// lcps.put(beType, lcp); +// } + return lcps; + } + + private ILcpFactory getLcpFactory() { + if (lcpFactory == null) { + lcpFactory = CefBeanUtil.getAppCtx().getBean(ILcpFactory.class); + } + return lcpFactory; + } + + private IStandardLcp getLcp(String configId) { + IStandardLcp lcp = getLcpFactory().createLcp(configId); + if(useAuth){ + AuthUtils.buildAuthInfo( + lcp.getBefContext().getAuthInfo(), + "VM", + getVoId(), + null, + null, + null, + null, + configId + ); + }else{ + AuthUtils.buildAuthInfo( + lcp.getBefContext().getAuthInfo(), + null, + null, + null, + null, + null, + null, + null + ); + } + return lcp; + } + + public ArrayList getSourceConfigs() { + AbstractSourceConfig sourceConfigs = manager.getOutSourceConfigs(); + return sourceConfigs == null ? null : sourceConfigs.getSourceConfigs(); + } + + public final IStandardLcp getLcp() { + String beType; +// if (manager.getSourceConfigs() != null && getSourceConfigs() != null && getSourceConfigs().size() > 0) { + beType = getSourceConfigs().get(0).getSourceConfigId(); +// } +// else { +// beType = manager.getBETypes().get(0); +// } + if (DotNetToJavaStringHelper.isNullOrEmpty(beType)) { + return null; + } + + IStandardLcp lcp = getLcp(beType); + lcp.getBefContext().setEnableTimeStampLastModifiedBy(getBffManager().getTimeStampContext().isEnableTimeStampLastModifiedBy()); + return lcp; + } + + public final String getVMCodeFromBE(String beObjectCode) { + return manager.getVMCodeFromBE(beObjectCode); + } + + public SourceType getMainSourceType() { + return manager.getOutSourceConfigs().getSourceConfigs().get(0).getSourceType(); + } + + public final IMgrActionExecutor GetActionExecutor() { + throw new RuntimeException(); + } + + public boolean getIsBeforeSaving() { + return getLcp().getBefContext().getBefStatus().getIsBeforeSaving(); + } + + // region i18n + public ModelResInfo getModelResourceInfo() { + return manager.getModelInfo(); + } + + @Override + public String getEntityI18NName(String nodeCode) { + + return getEntityResourceInfo(nodeCode).getDisplayName(); + } + + @Override + public String getPropertyI18NName(String nodeCode, String labelID) { + + String result = getEntityResourceInfo(nodeCode).getPropertyDispalyName(labelID); + if (DotNetToJavaStringHelper.isNullOrEmpty(result)) { + result = labelID; + } + return result; + } + + @Override + public String getRefPropertyI18NName(String nodeCode, String labelID, String refLabelID) { + return getEntityResourceInfo(nodeCode).getAssoRefPropertyDisplay(labelID, refLabelID); + } + + @Override + public String getEnumValueI18NDisplayName(String nodeCode, String labelID, String enumKey) { + return getEntityResourceInfo(nodeCode).getEnumPropertyDispalyValue(labelID, enumKey); + } + + + public final EntityResInfo getEntityResourceInfo(String nodeCode) { + return getModelResourceInfo().getCustomResource(nodeCode); + } + + public final String getUniqueConstraintMessage(String nodeCode, String conCode) { + return getEntityResourceInfo(nodeCode).getUniqueConstraintMessage(conCode); + } + + public List getExtList(){ + return manager.getExtList(); + } + + // endregion +//---------------------------------------------------------------------------------------- +// Copyright © 2006 - 2010 Tangible Software Solutions Inc. +// This class can be used by anyone provided that the copyright notice remains intact. +// +// This class is used to simulate some .NET string functions in Java. +//---------------------------------------------------------------------------------------- + public static final class DotNetToJavaStringHelper { + //------------------------------------------------------------------------------------ + // This method replaces the .NET static string method 'IsNullOrEmpty'. + //------------------------------------------------------------------------------------ + public static boolean isNullOrEmpty(String string) { + return string == null || string.equals(""); + } + + //------------------------------------------------------------------------------------ + // This method replaces the .NET static string method 'Join' (2 parameter version). + //------------------------------------------------------------------------------------ + public static String join(String separator, String[] stringarray) { + if (stringarray == null) + return null; + else + return join(separator, stringarray, 0, stringarray.length); + } + + //------------------------------------------------------------------------------------ + // This method replaces the .NET static string method 'Join' (4 parameter version). + //------------------------------------------------------------------------------------ + public static String join(String separator, String[] stringarray, int startindex, int count) { + String result = ""; + + if (stringarray == null) + return null; + + for (int index = startindex; index < stringarray.length && index - startindex < count; index++) { + if (separator != null && index > startindex) + result += separator; + + if (stringarray[index] != null) + result += stringarray[index]; + } + + return result; + } + + //------------------------------------------------------------------------------------ + // This method replaces the .NET static string method 'TrimEnd'. + //------------------------------------------------------------------------------------ + public static String trimEnd(String string, Character... charsToTrim) { + if (string == null || charsToTrim == null) + return string; + + int lengthToKeep = string.length(); + for (int index = string.length() - 1; index >= 0; index--) { + boolean removeChar = false; + if (charsToTrim.length == 0) { + if (Character.isWhitespace(string.charAt(index))) { + lengthToKeep = index; + removeChar = true; + } + } else { + for (int trimCharIndex = 0; trimCharIndex < charsToTrim.length; trimCharIndex++) { + if (string.charAt(index) == charsToTrim[trimCharIndex]) { + lengthToKeep = index; + removeChar = true; + break; + } + } + } + if (!removeChar) + break; + } + return string.substring(0, lengthToKeep); + } + + //------------------------------------------------------------------------------------ + // This method replaces the .NET static string method 'TrimStart'. + //------------------------------------------------------------------------------------ + public static String trimStart(String string, Character... charsToTrim) { + if (string == null || charsToTrim == null) + return string; + + int startingIndex = 0; + for (int index = 0; index < string.length(); index++) { + boolean removeChar = false; + if (charsToTrim.length == 0) { + if (Character.isWhitespace(string.charAt(index))) { + startingIndex = index + 1; + removeChar = true; + } + } else { + for (int trimCharIndex = 0; trimCharIndex < charsToTrim.length; trimCharIndex++) { + if (string.charAt(index) == charsToTrim[trimCharIndex]) { + startingIndex = index + 1; + removeChar = true; + break; + } + } + } + if (!removeChar) + break; + } + return string.substring(startingIndex); + } + + //------------------------------------------------------------------------------------ + // This method replaces the .NET static string method 'Trim' when arguments are used. + //------------------------------------------------------------------------------------ + public static String trim(String string, Character... charsToTrim) { + return trimEnd(trimStart(string, charsToTrim), charsToTrim); + } + + //------------------------------------------------------------------------------------ + // This method is used for string equality comparisons when the option + // 'Use helper 'stringsEqual' method to handle null strings' is selected + // (The Java String 'equals' method can't be called on a null instance). + //------------------------------------------------------------------------------------ + public static boolean stringsEqual(String s1, String s2) { + if (s1 == null && s2 == null) + return true; + else + return s1 != null && s1.equals(s2); + } + + } +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/BffIncrementSerializerUtilConf.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/BffIncrementSerializerUtilConf.java new file mode 100644 index 0000000..17ab147 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/BffIncrementSerializerUtilConf.java @@ -0,0 +1,13 @@ +//package com.inspur.edp.bff.core.session; +// +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +// +//@Configuration("com.inspur.edp.bff.core.session.BffIncrementDeserializerConf") +//public class BffIncrementSerializerUtilConf { +// +// @Bean(name = BffSessionItem.Category) +// public BffIncrementSerializerUtil getBffIncrementDeserializer(){ +// return new BffIncrementSerializerUtil(); +// } +//} -- Gitee From af84515926c35e9539675899d80fb20993039664 Mon Sep 17 00:00:00 2001 From: qinxinyuan Date: Thu, 27 Oct 2022 16:31:34 +0800 Subject: [PATCH 33/81] =?UTF-8?q?fsManager=E6=89=A9=E5=B1=95=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E7=B1=BB=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=8A=A8=E4=BD=9C?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bff/core/action/modify/ModifyAction.java | 71 +++++++++++++++++++ .../bff/core/manager/FSManagerExtendUtil.java | 49 +++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/modify/ModifyAction.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/manager/FSManagerExtendUtil.java diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/modify/ModifyAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/modify/ModifyAction.java new file mode 100644 index 0000000..5477c99 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/modify/ModifyAction.java @@ -0,0 +1,71 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.modify; + +import com.inspur.edp.bef.api.action.VoidActionResult; +import com.inspur.edp.bff.api.dataprocessor.IChangeConvertor; +import com.inspur.edp.bff.api.manager.context.ChangeMapperContext; +import com.inspur.edp.bff.api.manager.context.ModifyContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; + +public class ModifyAction extends AbstractFSAction { + + + private IChangeDetail change; + + public ModifyAction(IChangeDetail change) + { + this.change = change; + } + + @Override + protected void execute() + { + if (getContext().getAssemblerManager() == null) + { + doDefaultModify(); + return; + } + ModifyContext modifyContext = new ModifyContext(); + modifyContext.getSourceChange().add(change); + //① BeforeModify + getContext().getAssemblerManager().getModifyAssembler().doBeforeModify(getContext(), modifyContext); + + //② ChangeMapping + ChangeMapperContext mapperContext = new ChangeMapperContext(); + mapperContext.setSourceChange(modifyContext.getSourceChange()); + getContext().getAssemblerManager().getChangeMapperAssembler().doChangeMappingFromVo(getContext(), mapperContext); + + //③ DoModify + //modifyContext.SourceChange = mapperContext.SourceChange; + modifyContext.setMappedChange(mapperContext.getMappedChange()); + getContext().getAssemblerManager().getModifyAssembler().doModify(getContext(), modifyContext); + + //④ AfterModify + getContext().getAssemblerManager().getModifyAssembler().doAfterModify(getContext(), modifyContext); + + + } + + private void doDefaultModify() + { + IChangeConvertor changeConvertor = getContext().getChangeConvertor(); + IChangeDetail beChange = changeConvertor.convertFromVMChange(change); + getLcp().modify(beChange); + } +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/manager/FSManagerExtendUtil.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/manager/FSManagerExtendUtil.java new file mode 100644 index 0000000..09e355a --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/manager/FSManagerExtendUtil.java @@ -0,0 +1,49 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.manager; + +import com.inspur.edp.bff.api.extend.IBffManagerExtend; +import com.inspur.edp.bff.api.extend.IVMHelpExtendInfo; +import com.inspur.edp.bff.spi.VMHelpConfig; +import com.inspur.edp.bff.spi.extend.AddHelpExtend; +import java.util.List; + +class FSManagerExtendUtil { + + public static VMHelpConfig getHelpConfig(List extList, String codeName, + String labelId) { + if (extList == null) { + return null; + } + for (IBffManagerExtend ext : extList) { + List helps = ext.getHelpExtends(); + if (helps == null) { + continue; + } + for (IVMHelpExtendInfo help : helps) { + if (!(help instanceof AddHelpExtend)) { + continue; + } + VMHelpConfig helpConfig = ((AddHelpExtend) help).getAddedHelpConfig(); + if ((codeName + "/" + labelId).equals(helpConfig.getHelpElementID())) { + return helpConfig; + } + } + } + return null; + } +} -- Gitee From 9dcd874ff87be5f6bd193c089324a85629ef94fe Mon Sep 17 00:00:00 2001 From: qinxinyuan Date: Thu, 27 Oct 2022 16:36:44 +0800 Subject: [PATCH 34/81] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=A3=80=E7=B4=A2?= =?UTF-8?q?=EF=BC=8C=E6=9F=A5=E8=AF=A2=E7=B1=BB=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/action/delete/MultiDeleteAction.java | 64 ++++++ .../action/retrieve/MultiRetrieveAction.java | 133 +++++++++++++ ...RetrieveDefaultWtihDefaultValueAction.java | 186 ++++++++++++++++++ 3 files changed, 383 insertions(+) create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/delete/MultiDeleteAction.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/MultiRetrieveAction.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/MulitRetrieveDefaultWtihDefaultValueAction.java diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/delete/MultiDeleteAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/delete/MultiDeleteAction.java new file mode 100644 index 0000000..0fcbc8a --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/delete/MultiDeleteAction.java @@ -0,0 +1,64 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.delete; + +import com.inspur.edp.bef.api.action.VoidActionResult; +import com.inspur.edp.bff.api.manager.context.DeleteContext; +import com.inspur.edp.bff.spi.AbstractFSAction; + +import java.util.ArrayList; + +public class MultiDeleteAction extends AbstractFSAction { + + private ArrayList dataIds; + + public MultiDeleteAction(ArrayList dataIds) + { + this.dataIds = dataIds; + } + + @Override + protected void execute() + { + //foreach (var lcp in GetLcp()) + //{ + // lcp.Delete(dataIds); + //} + if (getContext().getAssemblerManager() == null) + { + doDefaultDelete(); + return; + } + + DeleteContext deleteContext = new DeleteContext(); + deleteContext.setDataIds(dataIds); + + //① DoBeforeDelete + getContext().getAssemblerManager().getDeleteAssembler().doBeforeMultiDelete(getContext(), deleteContext); + + //② DoDelete + getContext().getAssemblerManager().getDeleteAssembler().doMultiDelete(getContext(), deleteContext); + + //④ AfterDelete + getContext().getAssemblerManager().getDeleteAssembler().doAfterMultiDelete(getContext(), deleteContext); + } + private void doDefaultDelete() + { + getLcp().delete(dataIds); + } + +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/MultiRetrieveAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/MultiRetrieveAction.java new file mode 100644 index 0000000..10d3809 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/MultiRetrieveAction.java @@ -0,0 +1,133 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.retrieve; + +import com.inspur.edp.bef.api.parameter.retrieve.RespectiveRetrieveResult; +import com.inspur.edp.bef.api.parameter.retrieve.RetrieveParam; +import com.inspur.edp.bef.auditconfig.api.BefAuditConfigService; +import com.inspur.edp.bef.auditconfig.entity.BefAuditConfig; +import com.inspur.edp.bef.auditconfig.entity.BefAuditConfigItem; +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.api.manager.assembler.IAssemblerManager; +import com.inspur.edp.bff.api.manager.context.DataMapperContext; +import com.inspur.edp.bff.api.manager.context.RetrieveContext; +import com.inspur.edp.bff.core.action.query.AuditUtils; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.entity.entity.IEntityData; +import io.iec.edp.caf.audit.api.data.AuditType; +import io.iec.edp.caf.audit.api.data.EventResultType; +import io.iec.edp.caf.audit.api.data.GspAudit; +import io.iec.edp.caf.audit.api.manager.GspAuditManager; +import io.iec.edp.caf.boot.context.CAFContext; +import io.iec.edp.caf.commons.utils.SpringBeanUtils; +import lombok.var; + +import java.util.*; + +public class MultiRetrieveAction extends AbstractFSAction> { + + private java.util.ArrayList dataIds; + private RetrieveParam param; + + + public MultiRetrieveAction(java.util.ArrayList dataIds, RetrieveParam param) { + this.dataIds = dataIds; + this.param = param; + } + + @Override + protected void execute() { + IAssemblerManager assemblyManager = getContext().getAssemblerManager(); + RetrieveContext retrieveContext = new RetrieveContext(); + retrieveContext.setDataIds(dataIds); + retrieveContext.setParam(param); + //① BeforeRetrieve + assemblyManager.getRetrieveAssembler().doBeforeRetrieve(getContext(), retrieveContext); + + //② DoRetrieve + assemblyManager.getRetrieveAssembler().doRetrieve(getContext(), retrieveContext); + if (retrieveContext.getRetrieveData() == null || retrieveContext.getRetrieveData().size() < 1) { + setResult(null); + return; + } + //③ DataMapping + DataMapperContext mapperContext = new DataMapperContext(); + mapperContext.setSourceData(retrieveContext.getRetrieveData()); + + ArrayList vmDatas = assemblyManager. + getDataMapperAssembler().doDataMapping2Vo(getContext(), mapperContext); + retrieveContext.setRetrieveResult(vmDatas); + //④ AfterRetrieve + assemblyManager.getRetrieveAssembler().doAfterRetrieve(getContext(), retrieveContext); + setResult(vmDatas); + auditLog(retrieveContext.getRetrieveData()); + } + private void auditLog(HashMap> vmDatas) { + if(getContext().getVoId()==null||getContext().getVoId().equals("")) + return; + + List list = SpringBeanUtils.getBean(BefAuditConfigService.class).getBefAuditConfigsByVoId(this.getContext().getVoId()); + if(list==null||list.size()==0) + return; + for (BefAuditConfig config:list) + { + auditItem(config,vmDatas); + } + } + + private void auditItem(BefAuditConfig auditConfig, HashMap> vmDatas) { + if(auditConfig.getConfigItems()==null||auditConfig.getConfigItems().size()==0) + return; + for(var item:auditConfig.getConfigItems()) { + if("9sEsnADPFkCRK6ZBC0OwiA".equals(item.getTargetVoActionId())==false) + continue; + GspAudit gspAudit = new GspAudit(); + gspAudit.setId(UUID.randomUUID().toString()); + gspAudit.setCategoryId(item.getAuditTypeId()); + gspAudit.setEventId(item.getAuditEventId()); + gspAudit.setDateTime(new Date()); + gspAudit.setType(AuditType.message); + gspAudit.setEventResult(EventResultType.success); + gspAudit.setGspAuditData(new ArrayList<>()); + gspAudit.setDescription(item.getAuditMessage().getAuditMessage()); + setAuditMessage(gspAudit,item,vmDatas); + if(CAFContext.current.getFrameworkContext()!=null) { + gspAudit.setFunctionId(CAFContext.current.getFrameworkContext().getFuncId()); + gspAudit.setFunctionCode(CAFContext.current.getFrameworkContext().getFuncCode()); + if (CAFContext.current.getFrameworkContext().getItems().containsKey("menuName")) + gspAudit.setFunctionName( + String.valueOf( + CAFContext.current.getFrameworkContext().getItems().get("menuName"))); + } + SpringBeanUtils.getBean(GspAuditManager.class).addAuditSync(gspAudit); + } + } + + private void setAuditMessage(GspAudit gspAudit, BefAuditConfigItem item, + HashMap> vmDatas) { + Map> auditMessageDataFields=new HashMap<>(); + Map>> childAuditMessageDataFields=new HashMap<>(); + AuditUtils.getAuditMessageField(gspAudit,item,auditMessageDataFields,childAuditMessageDataFields); + for(Map.Entry> data:vmDatas.entrySet()) + { + if(data.getValue()!=null) + for(IEntityData dataItem :data.getValue()) + AuditUtils.addAuditMessageFieldValue(dataItem,"",auditMessageDataFields,childAuditMessageDataFields,this.getContext()); + } + AuditUtils.setAuditMessage(gspAudit,auditMessageDataFields,childAuditMessageDataFields); + } +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/MulitRetrieveDefaultWtihDefaultValueAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/MulitRetrieveDefaultWtihDefaultValueAction.java new file mode 100644 index 0000000..1d9ddf0 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/MulitRetrieveDefaultWtihDefaultValueAction.java @@ -0,0 +1,186 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.retrievedefault; + +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.api.extend.IBffEntityExtend; +import com.inspur.edp.bff.api.extend.IBffManagerExtend; +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; +import com.inspur.edp.bff.spi.AbstractDataConvertor; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.bff.spi.defaultvalue.DefaultValueUtil; +import com.inspur.edp.cef.api.changeListener.EntityDataChangeListener; +import com.inspur.edp.cef.api.dataType.entity.ICefEntity; +import com.inspur.edp.cef.entity.accessor.entity.IEntityAccessor; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import com.inspur.edp.cef.entity.changeset.ModifyChangeDetail; +import com.inspur.edp.cef.entity.entity.ICefData; +import com.inspur.edp.cef.entity.entity.IEntityData; +import com.inspur.edp.udt.entity.IUdtData; +import lombok.var; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +public class MulitRetrieveDefaultWtihDefaultValueAction extends AbstractFSAction> { + + private ArrayList nodeCodes; + private ArrayList lierachyIds; + private ArrayList defaultValues; + + public MulitRetrieveDefaultWtihDefaultValueAction(ArrayList nodeCodes, + ArrayList lierachyIds, + ArrayList defaultValues) { + this.nodeCodes = nodeCodes; + this.lierachyIds = lierachyIds; + this.defaultValues = defaultValues; + } + + + @Override + protected void execute() { + if(defaultValues==null ||defaultValues.size()==0){ + throw new RuntimeException("根据默认值批量新增子表数据时,默认值列表不能为空!"); + } + ArrayList dataList=new ArrayList<>(defaultValues.size()); + + IFSManager manager=getContext().getBffManager(); + for(VoDefaultValue defaultValue:defaultValues){ + //将vo默认值转换为be默认值 + Map beDefaultValue=DefaultValueUtil.transVoDefaultValueToBe(getContext(),defaultValue,nodeCodes); + //创建一条数据带默认值的数据 + IEntityData beData=getLcp().retrieveDefaultChild(nodeCodes,lierachyIds,beDefaultValue); + + Object tempVar = getContext().getBffManager().createChildData(nodeCodes.get(nodeCodes.size() - 1), ""); + IEntityAccessor vmAccessor = (IEntityAccessor) ((tempVar instanceof IEntityAccessor) ? tempVar : null); + IEntityData voData = (IEntityData) ((vmAccessor.getInnerData() instanceof IEntityData) ? vmAccessor.getInnerData() : null); + + transBeDataToVoData(beData,voData); + //region extend + dealExtendMapping(voData, beData); + + + vmAccessor.setInnerData(voData); + + dealDefaultValue(vmAccessor,defaultValue); + IEntityData result = (IEntityData) ((vmAccessor.getInnerData() instanceof IEntityData) ? vmAccessor.getInnerData() : null); + dataList.add(result); + } + + setResult(dataList); + } + + private IEntityData transBeDataToVoData(IEntityData beData,IEntityData voData){ + + IDataConvertor dataConvertor=getDataConvertor(nodeCodes); + if(dataConvertor!=null) + + dataConvertor.convertFromBEData(beData, voData); + + return voData; + } + + private void dealDefaultValue(IEntityAccessor vmAccessor,VoDefaultValue VoDefaultValue) { + + IEntityData voData = (IEntityData) ((vmAccessor.getInnerData() instanceof IEntityData) ? vmAccessor.getInnerData() : null); + + EntityDataChangeListener listener = EntityDataChangeListener.createInstance(); + listener.registListener((ICefData) ((vmAccessor instanceof ICefData) ? vmAccessor : null)); + ICefEntity entinty = getEntity(voData.getID()); + entinty.assignDefaultValue(vmAccessor); + + if (VoDefaultValue != null && VoDefaultValue.getDefaultValue() != null && VoDefaultValue.getDefaultValue().size() > 0) { + + for (Map.Entry defaultItem : VoDefaultValue.getDefaultValue().entrySet()) { + + Object value = defaultItem.getValue(); + //不支持直接setUdt,新增时传参的方式赋udt默认值 + if(value instanceof IUdtData) + continue; + vmAccessor.setValue(defaultItem.getKey(), defaultItem.getValue()); + } + } + IChangeDetail defalutChange = listener.getChange(); + if (defalutChange != null) { + ModifyChangeDetail beChange = getChangeDetail((ModifyChangeDetail) ((defalutChange instanceof ModifyChangeDetail) ? defalutChange : null)); + getContext().getBffManager().modify(beChange); + } + } + + private void dealExtendMapping(IEntityData voData, IEntityData beData) { + var extList = getContext().getExtList(); + if(extList == null || extList.size() < 1) + return ; + for (var ext : extList){ + IBffEntityExtend entityExtend = getChildEntityExtend(ext); + if(entityExtend != null) + entityExtend.mapData2Vo(voData, beData); + } + } + + private IBffEntityExtend getChildEntityExtend(IBffManagerExtend mgrExtend) { + IBffEntityExtend entityExtend = mgrExtend.getDataTypeExtend(); + for (String nodeCode : nodeCodes) { + entityExtend = entityExtend.getChildEntity(nodeCode); + if(entityExtend == null) + break; + } + return entityExtend; + } + + private ModifyChangeDetail getChangeDetail(ModifyChangeDetail defaultChange) { + IChangeDetail tempVar = defaultChange.clone(); + + ModifyChangeDetail currentChange = (ModifyChangeDetail) ((tempVar instanceof ModifyChangeDetail) ? tempVar : null); + for (int i = lierachyIds.size() - 1; i >= 0; i--) { + + String nodeCode = nodeCodes.get(i); + ModifyChangeDetail change = new ModifyChangeDetail(lierachyIds.get(i)); + HashMap childChange = new HashMap(); + childChange.put(currentChange.getDataID(), currentChange); + change.getChildChanges().put(nodeCode, childChange); + IChangeDetail tempVar2 = change.clone(); + currentChange = (ModifyChangeDetail) ((tempVar2 instanceof ModifyChangeDetail) ? tempVar2 : null); + } + + return currentChange; + } + private ICefEntity getEntity(String childId) { + ICefEntity currentEntity = getContext().getBffManager().createEntity(lierachyIds.get(0)); + for (int i = 0; i < nodeCodes.size(); i++) { + currentEntity = currentEntity.getChildEntity(nodeCodes.get(i), i == nodeCodes.size() - 1 ? childId : lierachyIds.get(i + 1)); + } + + return currentEntity; + } + private IDataConvertor getDataConvertor(ArrayList nodeCodes) { + IDataConvertor tempVar = getContext().getDataConvertor(); + AbstractDataConvertor rootConvertor = (AbstractDataConvertor) ((tempVar instanceof AbstractDataConvertor) ? tempVar : null); + if (nodeCodes.isEmpty()) { + return rootConvertor; + } + AbstractDataConvertor currentConvertor = rootConvertor; + for (int i = 0; i < nodeCodes.size(); i++) { + currentConvertor = (AbstractDataConvertor) currentConvertor.getChildConvertor(nodeCodes.get(i)); + if (currentConvertor == null) + break; + } + return currentConvertor; + } +} -- Gitee From cd5b869565e6edac1ead5df6304229458c243d0c Mon Sep 17 00:00:00 2001 From: zhangjintr <1234qwer> Date: Thu, 27 Oct 2022 16:40:32 +0800 Subject: [PATCH 35/81] =?UTF-8?q?feature(bff-framework-entity):=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bff-framework-entity/pom.xml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 bff-framework-entity/pom.xml diff --git a/bff-framework-entity/pom.xml b/bff-framework-entity/pom.xml new file mode 100644 index 0000000..20b3d95 --- /dev/null +++ b/bff-framework-entity/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + com.inspur.edp + bff-framework-entity + 0.1.1 + + + + com.inspur.edp + cef-api + + + com.inspur.edp + cef-entity + + + -- Gitee From 081db6a20b510befb64885fe62df7a9bf0775450 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Thu, 27 Oct 2022 16:48:32 +0800 Subject: [PATCH 36/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增基础配置 --- .../attribute/AbstractExtendActionConfig.java | 201 ++++++++++++++++++ .../api/attribute/AbstractSourceConfig.java | 38 ++++ 2 files changed, 239 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/AbstractExtendActionConfig.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/AbstractSourceConfig.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/AbstractExtendActionConfig.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/AbstractExtendActionConfig.java new file mode 100644 index 0000000..7bddd7c --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/AbstractExtendActionConfig.java @@ -0,0 +1,201 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.attribute; + +import java.util.ArrayList; + +public abstract class AbstractExtendActionConfig { + + // region Query + private ArrayList beforeQueryTypes = new ArrayList(); + public ArrayList getBeforeQueryTypes() + { + return beforeQueryTypes; + } + + private ArrayList queryTypes= new ArrayList(); + public ArrayList getQueryTypes() + { + return queryTypes; + } + + private ArrayList afterQueryTypes = new ArrayList(); + public ArrayList getAfterQueryTypes() + { + return afterQueryTypes; + } + + // endregion + + + ///#region DataMap + private ArrayList dataMapperTypes = new ArrayList(); + public ArrayList getDataMapperTypes() + { + return dataMapperTypes; + } + + private ArrayList dataReversalMapperTypes = new ArrayList(); + public ArrayList getDataReversalMapperTypes() + { + return dataReversalMapperTypes; + } + + + // endregion + + + ///#region Retrieve + private ArrayList beforeRetrieveTypes = new ArrayList(); + public ArrayList getBeforeRetrieveTypes() + { + return beforeRetrieveTypes; + } + + private ArrayList retrieveTypes = new ArrayList(); + public ArrayList getRetrieveTypes() + { + return retrieveTypes; + } + + private ArrayList afterRetrieveTypes = new ArrayList(); + public ArrayList getAfterRetrieveTypes() + { + return afterRetrieveTypes; + } + + ///#endregion + + + ///#region RetrieveDefault + private ArrayList beforeRetrieveDefaultTypes = new ArrayList(); + public ArrayList getBeforeRetrieveDefaultTypes() + { + return beforeRetrieveDefaultTypes; + } + + private ArrayList retrieveDefaultTypes = new ArrayList(); + public ArrayList getRetrieveDefaultTypes() + { + return retrieveDefaultTypes; + } + + private ArrayList afterRetrieveDefaultTypes = new ArrayList(); + public ArrayList getAfterRetrieveDefaultTypes() + { + return afterRetrieveDefaultTypes; + } + + + ///#endregion + + + // region Modify + private ArrayList beforeModifyTypes = new ArrayList(); + public ArrayList getBeforeModifyTypes() + { + return beforeModifyTypes; + } + + private ArrayList modifyTypes = new ArrayList(); + public ArrayList getModifyTypes() + { + return modifyTypes; + } + + private ArrayList afterModifyTypes = new ArrayList(); + public ArrayList getAfterModifyTypes() + { + return afterModifyTypes; + } + + // endregion + + + // region Delete + private ArrayList beforeDeleteTypes = new ArrayList(); + public ArrayList getBeforeDeleteTypes() + { + return beforeDeleteTypes; + } + + private ArrayList deleteTypes = new ArrayList(); + public ArrayList getDeleteTypes() + { + return deleteTypes; + } + + private ArrayList afterDeleteTypes = new ArrayList(); + public ArrayList getAfterDeleteTypes() + { + return afterDeleteTypes; + } + + // endregion + + //region MultiDelete + private ArrayList beforeMultiDeleteTypes=new ArrayList(); + public ArrayList getBeforeMultiDeleteTypes() + { + return beforeMultiDeleteTypes; + } + + private ArrayList multiDeleteTypes = new ArrayList(); + public ArrayList getMultiDeleteTypes() + { + return multiDeleteTypes; + } + + private ArrayList afterMultiDeleteTypes = new ArrayList(); + public ArrayList getAfterMultiDeleteTypes() + { + return afterMultiDeleteTypes; + } + + // endregion + + // region Save + private ArrayList beforeSaveTypes = new ArrayList(); + public ArrayList getBeforeSaveTypes() + { + return beforeSaveTypes; + } + + private ArrayList afterSaveTypes = new ArrayList(); + public ArrayList getAfterSaveTypes() + { + return afterSaveTypes; + } + + // endregion + + + // region ChangeMapping + private ArrayList changeMapperTypes = new ArrayList(); + public ArrayList getChangeMapperTypes() + { + return changeMapperTypes; + } + + private ArrayList changeReversalMapperTypes = new ArrayList(); + public ArrayList getChangeReversalMapperTypes() + { + return changeReversalMapperTypes; + } + + // endregion +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/AbstractSourceConfig.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/AbstractSourceConfig.java new file mode 100644 index 0000000..f7af8b5 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/AbstractSourceConfig.java @@ -0,0 +1,38 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.attribute; + +import com.inspur.edp.bff.api.manager.SourceConfig; +import lombok.Getter; + +import java.util.ArrayList; + +public abstract class AbstractSourceConfig { + + + @Getter + protected ArrayList sourceConfigs = new ArrayList(); + @Getter + protected String indexVoConfig = null; + + + public AbstractSourceConfig() + { + + } + +} -- Gitee From 57342a2273081114770972f6a56dfa263ff8e285 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Thu, 27 Oct 2022 18:07:33 +0800 Subject: [PATCH 37/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增变更集操作 --- .../attribute/ChangeConvertorAttribute.java | 40 ++++++++ .../manager/context/ChangeMapperContext.java | 94 +++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/ChangeConvertorAttribute.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/ChangeMapperContext.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/ChangeConvertorAttribute.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/ChangeConvertorAttribute.java new file mode 100644 index 0000000..4ea0d06 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/ChangeConvertorAttribute.java @@ -0,0 +1,40 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.attribute; + +import com.inspur.edp.bff.api.dataprocessor.IChangeConvertor; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +public @interface ChangeConvertorAttribute { + + /** + * 转换器所属的类型,该类型必须实现{@link IChangeConvertor}接口。 + */ + java.lang.Class convertorType(); + + + /** + * 变更集类型 + */ + java.lang.Class entityType(); + +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/ChangeMapperContext.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/ChangeMapperContext.java new file mode 100644 index 0000000..1e8cfb3 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/ChangeMapperContext.java @@ -0,0 +1,94 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.context; + +import com.inspur.edp.cef.entity.changeset.IChangeDetail; + +import java.util.ArrayList; +import java.util.HashMap; + +/** + * 变更集Mapping以及变更集反向Mapping上下文 + * 变更集Mapping:将be变更集转换为vo变更集 + * 变更集反向Mapping:将vo变更集转换为be变更集 + * 扩展动作执行顺序可参考:点击这里查看。 + * + */ +public class ChangeMapperContext { + + private ArrayList sourceChange = new ArrayList(); + /** + * 源变更集(外部传入) + *

目前源变更集一般为be数据变更集 + */ + public final ArrayList getSourceChange() + { + return sourceChange; + } + public final void setSourceChange(ArrayList value) + { + sourceChange = value; + } + + + private HashMap> mappedChange = new HashMap>(); + /** + * 映射后的变更集集合 + * Key:数据源编号 内部默认Key值使用Default,开发时请注意不要使用该Key值,以免出现未知问题。 + * Value:数据源对应变更集 + * + */ + public final HashMap> getMappedChange() + { + return mappedChange; + } + public final void setMappedChange(HashMap> value) + { + mappedChange = value; + } + + + private HashMap> innerChange = new HashMap>(); + /** + * 内部变更集合,执行完变更操作后,将内部变更集写入 + * Key:数据源编号 内部默认Key值使用Default,开发时请注意不要使用该Key值,以免出现未知问题。 + * Value:数据源对应内部变更集 + */ + public final HashMap> getInnerChange() + { + return innerChange; + } + public final void setInnerChange(HashMap> value) + { + innerChange = value; + } + + + private ArrayList targetChange = new ArrayList(); + /** + * Vo内部变更集:通过InnerChange反向映射合并后的结果 + */ + public final ArrayList getTargetChange() + { + return targetChange; + } + public final void setTargetChange(ArrayList value) + { + targetChange = value; + } + +} -- Gitee From 659c4e858770bae870c6509f8c6f2e020bf57fe6 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Fri, 28 Oct 2022 09:04:11 +0800 Subject: [PATCH 38/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增数据转换及扩展动作接口 --- .../api/attribute/DataConvertorAttribute.java | 34 +++++++++++++++++++ .../EntityPropertyMapperAttribute.java | 29 ++++++++++++++++ .../api/attribute/ExtendActionAttribute.java | 28 +++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/DataConvertorAttribute.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/EntityPropertyMapperAttribute.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/ExtendActionAttribute.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/DataConvertorAttribute.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/DataConvertorAttribute.java new file mode 100644 index 0000000..edb3b8e --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/DataConvertorAttribute.java @@ -0,0 +1,34 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.attribute; + +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +public @interface DataConvertorAttribute { + /** + * 转换器所属的类型,该类型必须实现{@link IDataConvertor}接口。 + * + */ + Class convertorType(); + +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/EntityPropertyMapperAttribute.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/EntityPropertyMapperAttribute.java new file mode 100644 index 0000000..d250080 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/EntityPropertyMapperAttribute.java @@ -0,0 +1,29 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.attribute; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +public @interface EntityPropertyMapperAttribute { + + Class value(); +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/ExtendActionAttribute.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/ExtendActionAttribute.java new file mode 100644 index 0000000..3d276d6 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/ExtendActionAttribute.java @@ -0,0 +1,28 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.attribute; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +public @interface ExtendActionAttribute { + Class extendActionConfig(); +} -- Gitee From 066e1e6b3e80e1dd18fda047ae2d7aa8f57938c6 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Fri, 28 Oct 2022 09:10:34 +0800 Subject: [PATCH 39/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增时间戳上下文 --- .../bff/api/attribute/VMChildAttribute.java | 36 +++++++++++++++++++ .../api/manager/context/TimeStampContext.java | 29 +++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/VMChildAttribute.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/TimeStampContext.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/VMChildAttribute.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/VMChildAttribute.java new file mode 100644 index 0000000..7e7fc5b --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/VMChildAttribute.java @@ -0,0 +1,36 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.attribute; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface VMChildAttribute { + String objectCode(); + + String id(); + + String keyFieldName(); + + String parentFieldName(); + + String refEntityObjectCode(); +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/TimeStampContext.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/TimeStampContext.java new file mode 100644 index 0000000..cbc064a --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/TimeStampContext.java @@ -0,0 +1,29 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.context; + +public class TimeStampContext { + public boolean isEnableTimeStampLastModifiedBy() { + return enableTimeStampLastModifiedBy; + } + + public void setEnableTimeStampLastModifiedBy(boolean enableTimeStampLastModifiedBy) { + this.enableTimeStampLastModifiedBy = enableTimeStampLastModifiedBy; + } + + private boolean enableTimeStampLastModifiedBy; +} -- Gitee From d4a105a6ee29a9be422b37d07a63db044af64e30 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Fri, 28 Oct 2022 09:29:22 +0800 Subject: [PATCH 40/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增实体扩展 --- .../bff/api/extend/IBffEntityDataExtend.java | 32 +++++++++++++ .../edp/bff/api/extend/IBffEntityExtend.java | 46 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/extend/IBffEntityDataExtend.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/extend/IBffEntityExtend.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/extend/IBffEntityDataExtend.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/extend/IBffEntityDataExtend.java new file mode 100644 index 0000000..0a02d7c --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/extend/IBffEntityDataExtend.java @@ -0,0 +1,32 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.extend; + +import com.inspur.edp.cef.entity.changeset.ModifyChangeDetail; +import com.inspur.edp.cef.entity.entity.IEntityData; +import com.inspur.edp.commonmodel.spi.extend.ICMEntityDataExtend; +import java.util.Map; + +public interface IBffEntityDataExtend extends ICMEntityDataExtend { + void mapDataFromVo(IEntityData voData, IEntityData beData); + void mapData2Vo(IEntityData voData,IEntityData beData); + + void mapChangeFromVo(ModifyChangeDetail voData, ModifyChangeDetail beData); + void mapChange2Vo(ModifyChangeDetail voData,ModifyChangeDetail beData); + + void mapDefaultValuesFromVo( Map voDefaultValues, Map beDefaultValues); +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/extend/IBffEntityExtend.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/extend/IBffEntityExtend.java new file mode 100644 index 0000000..2140e2d --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/extend/IBffEntityExtend.java @@ -0,0 +1,46 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.extend; + +import com.inspur.edp.bef.api.lcp.IStandardLcp; +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.cef.entity.changeset.ModifyChangeDetail; +import com.inspur.edp.cef.entity.entity.IEntityData; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.DataTypePropertyInfo; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefEntityResInfoImpl; +import com.inspur.edp.commonmodel.spi.extend.ICMEntityExtend; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public interface IBffEntityExtend extends ICMEntityExtend { + IBffEntityDataExtend getDataExtend(); + IBffEntityExtend getChildEntity(String nodeCode); + + void mapDataFromVo(IEntityData voData, IEntityData beData); + void mapData2Vo(IEntityData voData,IEntityData beData); + + void mapChangeFromVo(ModifyChangeDetail voData, ModifyChangeDetail beData); + void mapChange2Vo(ModifyChangeDetail voData,ModifyChangeDetail beData); + + CefEntityResInfoImpl getEntityResInfo(); + + void mapDefaultValuesFromVo( Map voDefaultValues, Map beDefaultValues); + + void mapChangedDefaultValuesFromVo(IFSManager manager, IStandardLcp lcp,ArrayList nodeCodes,Map values); +} -- Gitee From 0cc9a982441d3c87591fd477ec9cdbcee59046a4 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Fri, 28 Oct 2022 10:40:44 +0800 Subject: [PATCH 41/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增资源配置文件 --- .../api/attribute/SourceConfigAttribute.java | 32 ++++++++++ .../edp/bff/api/manager/SourceConfig.java | 62 +++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/SourceConfigAttribute.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/SourceConfig.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/SourceConfigAttribute.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/SourceConfigAttribute.java new file mode 100644 index 0000000..763c45e --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/SourceConfigAttribute.java @@ -0,0 +1,32 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.attribute; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +public @interface SourceConfigAttribute { + /** + 数据源配置类型,该类型必须实现{@link AbstractSourceConfig}接口。 + + */ + Class configType(); +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/SourceConfig.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/SourceConfig.java new file mode 100644 index 0000000..bd37540 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/SourceConfig.java @@ -0,0 +1,62 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager; + + + +public class SourceConfig { + + private String sourceConfigId; + + /** + * 获取数据源BE或者QO的功能标识:configid + * @return + */ + public final String getSourceConfigId() + { + return sourceConfigId; + } + + /** + * 数据源BE或者QO的功能标识:configid赋值 + * @return + */ + public final void setSourceConfigId(String value) + { + sourceConfigId = value; + } + + private SourceType sourceType; + + /** + * 获取数据源类型:{@link SourceType#Be},{@link SourceType#Qo} + * @return + */ + public final SourceType getSourceType() + { + return sourceType; + } + + /** + * 数据源类型赋值 + * @param value 数据源类型;{@link SourceType#Be},{@link SourceType#Qo} + */ + public final void setSourceType(SourceType value) + { + sourceType = value; + } +} -- Gitee From f17ada233d363677184e22379484bcb0e378312c Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Fri, 28 Oct 2022 11:09:29 +0800 Subject: [PATCH 42/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E8=A7=86?= =?UTF-8?q?=E5=9B=BE=E5=AF=B9=E8=B1=A1=E5=93=8D=E5=BA=94=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增视图对象响应信息 --- .../edp/bff/api/response/VoResponseInfo.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/response/VoResponseInfo.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/response/VoResponseInfo.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/response/VoResponseInfo.java new file mode 100644 index 0000000..2af9d36 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/response/VoResponseInfo.java @@ -0,0 +1,25 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.response; + +import com.inspur.edp.cef.api.response.ResponseInfo; +import lombok.Getter; + +public class VoResponseInfo extends ResponseInfo { + @Getter + private String voId; +} -- Gitee From d81ff2f537bca07f2d27964bd38ae8d7ebfce7e4 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Fri, 28 Oct 2022 14:50:43 +0800 Subject: [PATCH 43/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增数据扩展操作 --- .../api/attribute/VMDataExtendAttribute.java | 31 ++++++++++++++ .../bff/api/attribute/VMRootAttribute.java | 40 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/VMDataExtendAttribute.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/VMRootAttribute.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/VMDataExtendAttribute.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/VMDataExtendAttribute.java new file mode 100644 index 0000000..6e41377 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/VMDataExtendAttribute.java @@ -0,0 +1,31 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.attribute; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +public @interface VMDataExtendAttribute { + Class entityDataType(); + + Class serializerType(); + +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/VMRootAttribute.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/VMRootAttribute.java new file mode 100644 index 0000000..de295de --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/VMRootAttribute.java @@ -0,0 +1,40 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.attribute; + +import java.lang.annotation.*; + +@Target({ ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +public @interface VMRootAttribute { + + String defaultKeyFieldName = "ID"; + + String objectCode(); + + String keyFieldName(); + + String id(); + + String refBEObjectCode(); + + String voId(); + + java.lang.Class mappingType(); + + java.lang.Class recordType(); +} -- Gitee From 4940a08538f06b7fc5df09f449e9077eb59de7e3 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Fri, 28 Oct 2022 14:59:29 +0800 Subject: [PATCH 44/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增消息配置上下文 --- .../manager/context/MessageMapperContext.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/MessageMapperContext.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/MessageMapperContext.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/MessageMapperContext.java new file mode 100644 index 0000000..49ec013 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/MessageMapperContext.java @@ -0,0 +1,53 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.context; + +import com.inspur.edp.cef.api.message.IBizMessage; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class MessageMapperContext { + + /** + * be消息集合,执行完变更操作后,将内部消息写入 Key:数据源编号 Value:数据源对应消息 + */ + private Map> sourceMessage = new HashMap>(); + + public final Map> getSourceMessage() { + return sourceMessage; + } + + public final void setSourceMessage(Map> value) { + sourceMessage = value; + } + + /** + * Vo消息:通过SourceMessage映射后的结果 + */ + private List targetMessage = new ArrayList(); + + public final List getTargetMessage() { + return targetMessage; + } + + public final void setTargetMessage(List value) { + targetMessage = value; + } + +} -- Gitee From 0385c863cbde6653972bdb244d2270e72c1d98e8 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Fri, 28 Oct 2022 15:08:16 +0800 Subject: [PATCH 45/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E8=BF=87?= =?UTF-8?q?=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增过滤转换器 --- .../attribute/FilterConvertorAttribute.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/FilterConvertorAttribute.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/FilterConvertorAttribute.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/FilterConvertorAttribute.java new file mode 100644 index 0000000..3908999 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/attribute/FilterConvertorAttribute.java @@ -0,0 +1,33 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.attribute; + +import com.inspur.edp.bff.api.dataprocessor.IFilterFieldConvertor; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +public @interface FilterConvertorAttribute { + /** + 转换器所属的类型,该类型必须实现{@link IFilterFieldConvertor}接口。 + + */ + Class convertorType(); +} -- Gitee From e34a36b7f180f9c4060e9913545199ee5caa00a7 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Fri, 28 Oct 2022 15:15:39 +0800 Subject: [PATCH 46/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9ABffManager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增BffManager扩展 --- .../edp/bff/api/extend/IBffManagerExtend.java | 53 +++++++++++++++++++ .../manager/assembler/IAssemblerManager.java | 36 +++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/extend/IBffManagerExtend.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IAssemblerManager.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/extend/IBffManagerExtend.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/extend/IBffManagerExtend.java new file mode 100644 index 0000000..d54182d --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/extend/IBffManagerExtend.java @@ -0,0 +1,53 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.extend; + +import com.inspur.edp.bef.api.lcp.IStandardLcp; +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.cef.api.RefObject; +import com.inspur.edp.cef.api.rootManager.IRootManagerContext; +import com.inspur.edp.cef.entity.changeset.ModifyChangeDetail; +import com.inspur.edp.cef.entity.entity.IEntityData; +import com.inspur.edp.cef.spi.entity.resourceInfo.ModelResInfo; +import com.inspur.edp.commonmodel.spi.extend.ICMManagerExtend; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +public interface IBffManagerExtend extends ICMManagerExtend { + + @Override + IBffEntityExtend getDataTypeExtend(); + + List getHelpExtends(); + + void mapDataFromVo(IEntityData voData,IEntityData beData); + void mapData2Vo(IEntityData voData,IEntityData beData); + + void mapChangeFromVo(ModifyChangeDetail voData, ModifyChangeDetail beData); + void mapChange2Vo(ModifyChangeDetail voData,ModifyChangeDetail beData); + + + boolean invokeAction(String code, RefObject result, IRootManagerContext context, LinkedHashMap outterParams); + + ModelResInfo getModelInfo(); + + void mapDefaultValuesFromVo( Map voDefaultValues, Map beDefaultValues); + + void mapFilterFromVo(Map filterDic); +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IAssemblerManager.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IAssemblerManager.java new file mode 100644 index 0000000..0e80882 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IAssemblerManager.java @@ -0,0 +1,36 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.assembler; + +public interface IAssemblerManager { + + IExtendQueryAssembler getQueryAssembler(); + + IDataMapperAssembler getDataMapperAssembler(); + + IExtendRetrieveAssembler getRetrieveAssembler(); + + IExtendRetrieveDefaultAssembler getRetrieveDefaultAssembler(); + + IExtendDeleteAssembler getDeleteAssembler(); + + IChangeMapperAssembler getChangeMapperAssembler(); + + IExtendModifyAssembler getModifyAssembler(); + + IExtendSaveAssembler getSaveAssembler(); +} -- Gitee From d74c41bf6fac2c4a24698165ab0e79224827dba9 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Fri, 28 Oct 2022 16:31:00 +0800 Subject: [PATCH 47/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E6=89=A9?= =?UTF-8?q?=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增帮助扩展 --- .../edp/bff/api/extend/IVMHelpExtendInfo.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/extend/IVMHelpExtendInfo.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/extend/IVMHelpExtendInfo.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/extend/IVMHelpExtendInfo.java new file mode 100644 index 0000000..0fbdf21 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/extend/IVMHelpExtendInfo.java @@ -0,0 +1,21 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.extend; + +public interface IVMHelpExtendInfo { + +} -- Gitee From 6ec3573915565192460973d65b6808be55ac3cb9 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Fri, 28 Oct 2022 16:36:20 +0800 Subject: [PATCH 48/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增字段过滤转换器 --- .../dataprocessor/IFilterFieldConvertor.java | 22 ++++++++++++++++ .../assembler/IMessageMapperAssembler.java | 25 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IFilterFieldConvertor.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IMessageMapperAssembler.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IFilterFieldConvertor.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IFilterFieldConvertor.java new file mode 100644 index 0000000..d3c220a --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IFilterFieldConvertor.java @@ -0,0 +1,22 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.dataprocessor; + +public interface IFilterFieldConvertor { + + String transFilterField(String fieldName); +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IMessageMapperAssembler.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IMessageMapperAssembler.java new file mode 100644 index 0000000..db528de --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/assembler/IMessageMapperAssembler.java @@ -0,0 +1,25 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.manager.assembler; + +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.context.ChangeMapperContext; +import com.inspur.edp.bff.api.manager.context.MessageMapperContext; + +public interface IMessageMapperAssembler { + void doMessageMapping2Vo(IFSManagerContext context, MessageMapperContext mappingContext); +} -- Gitee From 56130df748eca43b035f16d2d54aef521394e43b Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Fri, 28 Oct 2022 17:31:17 +0800 Subject: [PATCH 49/81] =?UTF-8?q?feature(vo-runtime)=EF=BC=9A=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增默认值值转换器接口 --- .../dataprocessor/IDefaultValueConvertor.java | 33 +++++++++++++++++++ .../dataprocessor/IEntityPropertyMapper.java | 32 ++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IDefaultValueConvertor.java create mode 100644 bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IEntityPropertyMapper.java diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IDefaultValueConvertor.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IDefaultValueConvertor.java new file mode 100644 index 0000000..084d4b6 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IDefaultValueConvertor.java @@ -0,0 +1,33 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.dataprocessor; + +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; + +import java.util.HashMap; + +public interface IDefaultValueConvertor { + + /** + * 将Vo默认值转换成BE默认值 + * + * @param voDefaultValue Vo默认值 + * @return 转换之后的BE默认值 + */ + HashMap convertFromVo(VoDefaultValue voDefaultValue); + +} diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IEntityPropertyMapper.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IEntityPropertyMapper.java new file mode 100644 index 0000000..0113c76 --- /dev/null +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/dataprocessor/IEntityPropertyMapper.java @@ -0,0 +1,32 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.api.dataprocessor; + +public interface IEntityPropertyMapper { + + MapperBEEntityInfo getBEInfo(); + + String getVOCode(); + + MapperBEPropertyInfo getBEPropertyInfoFromVO(String prop); + + String getVOPropertyNameFromBE(String beType, String prop); + + IEntityPropertyMapper getMapperByBECode(String beType, String code); + + IEntityPropertyMapper getMapperByVOCode(String beCode); +} -- Gitee From 7016b3833df3b86ae6e3fb8a04e3347e06ce3ddd Mon Sep 17 00:00:00 2001 From: Jakeem Date: Fri, 28 Oct 2022 17:46:45 +0800 Subject: [PATCH 50/81] =?UTF-8?q?1.=20=E6=B7=BB=E5=8A=A0=E4=BA=86action?= =?UTF-8?q?=E5=A0=86=E6=A0=88=EF=BC=9B=202.=20=E6=B7=BB=E5=8A=A0=E4=BA=86d?= =?UTF-8?q?ataMapping;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/actionstatck/VoActionContext.java | 42 ++++++ .../action/datamapping/DataMappingAction.java | 35 +++++ .../DataReversalMappingAction.java | 35 +++++ .../datamapping/DefaultDataMappingAction.java | 121 ++++++++++++++++++ .../DefaultDataReversalAction.java | 50 ++++++++ 5 files changed, 283 insertions(+) create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/actionstatck/VoActionContext.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/datamapping/DataMappingAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/datamapping/DataReversalMappingAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/datamapping/DefaultDataMappingAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/datamapping/DefaultDataReversalAction.java diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/actionstatck/VoActionContext.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/actionstatck/VoActionContext.java new file mode 100644 index 0000000..e7a7e83 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/actionstatck/VoActionContext.java @@ -0,0 +1,42 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.actionstatck; + +import com.inspur.edp.cef.api.action.ActionExecuteContext; +import com.inspur.edp.cef.api.action.EditResult; + +import java.util.HashMap; +import java.util.Map; + +public class VoActionContext extends ActionExecuteContext { + + private String voId; + + private Map extendInfos =new HashMap<>(); + + public VoActionContext(String voId, String actionId, String actionCode, Map parameters) { + super(actionId, actionCode, parameters); + this.voId = voId; + } + + public String getVoId() + {return voId;} + + public Map getExtendInfos() { + return extendInfos; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/datamapping/DataMappingAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/datamapping/DataMappingAction.java new file mode 100644 index 0000000..4c5750c --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/datamapping/DataMappingAction.java @@ -0,0 +1,35 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.datamapping; + +import com.inspur.edp.bff.api.manager.context.DataMapperContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class DataMappingAction extends AbstractFSAction { + + private DataMapperContext mapContext; + protected final DataMapperContext getMapContext() + { + return mapContext; + } + + protected DataMappingAction(DataMapperContext context) + { + mapContext = context; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/datamapping/DataReversalMappingAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/datamapping/DataReversalMappingAction.java new file mode 100644 index 0000000..00af995 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/datamapping/DataReversalMappingAction.java @@ -0,0 +1,35 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.datamapping; + +import com.inspur.edp.bff.api.manager.context.DataMapperContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class DataReversalMappingAction extends AbstractFSAction { + + private DataMapperContext mapperContext; + protected final DataMapperContext getMapContext() + { + return mapperContext; + } + + protected DataReversalMappingAction(DataMapperContext context) + { + mapperContext = context; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/datamapping/DefaultDataMappingAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/datamapping/DefaultDataMappingAction.java new file mode 100644 index 0000000..726bee9 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/datamapping/DefaultDataMappingAction.java @@ -0,0 +1,121 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.datamapping; + +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.api.manager.context.DataMapperContext; +import com.inspur.edp.bff.spi.builtin.BffModelResInfoImpl; +import com.inspur.edp.bff.spi.utils.BffActionNames; +import com.inspur.edp.cef.api.changeListener.EntityDataChangeListener; +import com.inspur.edp.cef.api.dataType.entity.ICefRootEntity; +import com.inspur.edp.cef.entity.accessor.entity.IEntityAccessor; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import com.inspur.edp.cef.entity.entity.IEntityData; +import com.inspur.edp.cef.spi.entity.resourceInfo.ModelResInfo; +import com.inspur.edp.udt.entity.IUdtData; +import lombok.var; + +import java.util.Map; + +public class DefaultDataMappingAction extends DataMappingAction{ + + public DefaultDataMappingAction(DataMapperContext context) + { + super(context); + } + + @Override + protected void execute() + { + java.util.ArrayList vmDatas = new java.util.ArrayList(); + + IDataConvertor dataConvertor = getContext().getDataConvertor(); + if (!getMapContext().getSourceData().containsKey(BffActionNames.DefaultName)) + { + return; + } + + for (IEntityData entityData : getMapContext().getSourceData().get(BffActionNames.DefaultName)) + { + if(entityData==null){ + vmDatas.add(null); + continue; + } + Object tempVar = getContext().getBffManager().createData(); + + IEntityAccessor vmAccessor = (IEntityAccessor)((tempVar instanceof IEntityAccessor) ? tempVar : null); + + IEntityData voData = (IEntityData)((vmAccessor.getInnerData() instanceof IEntityData) ? vmAccessor.getInnerData() : null); + + //TODO Accessor暂不支持复杂类型赋值,临时用data赋值,在传给Accessor的方式处理 + dataConvertor.convertFromBEData(entityData, voData); + + //region 扩展 + dealExtendMapping(voData, entityData); + + + vmAccessor.setInnerData(voData); + + if(!(getMelInfo() instanceof BffModelResInfoImpl)){ + if (getMapContext().getIsNew()) { + dealDefaultValue(vmAccessor); + } + } + + //TODO 临时先返回InnerData,目前Accessor的ID不能序列化,等后续支持自定义序列化后,传Accessor + vmDatas.add((IEntityData)((vmAccessor.getInnerData() instanceof IEntityData) ? vmAccessor.getInnerData() : null)); + } + + getMapContext().setTargetResult(vmDatas); + } + + private void dealExtendMapping(IEntityData voData,IEntityData beData){ + var extList = getContext().getExtList(); + if(extList == null || extList.size() < 1) + return ; + for (var ext : extList){ + ext.mapData2Vo(voData, beData); + } + } + private ModelResInfo getMelInfo(){ + return this.getContext().getModelResourceInfo(); + } + private void dealDefaultValue(IEntityData vmAccessor) { + IEntityData voData = (IEntityData)((((IEntityAccessor)vmAccessor).getInnerData() instanceof IEntityData) ? ((IEntityAccessor)vmAccessor).getInnerData() : null); + EntityDataChangeListener listener = EntityDataChangeListener.createInstance(); + listener.registListener(vmAccessor); + ICefRootEntity entinty = getContext().getBffManager().createEntity(vmAccessor.getID()); + entinty.assignDefaultValue(vmAccessor); + if (getMapContext().getVoDefaultValue() != null && getMapContext().getVoDefaultValue().getDefaultValue() != null && getMapContext().getVoDefaultValue().getDefaultValue().size() > 0) + { + for (Map.Entry defaultItem : getMapContext().getVoDefaultValue().getDefaultValue().entrySet()) + { + Object value = defaultItem.getValue(); + //不支持直接setUdt,新增时传参的方式赋udt默认值 + if(value instanceof IUdtData) + continue; + vmAccessor.setValue(defaultItem.getKey(), defaultItem.getValue()); + } + } + + IChangeDetail defalutChange = listener.getChange(); + if (defalutChange != null) + { + getContext().getBffManager().modify(defalutChange); + } + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/datamapping/DefaultDataReversalAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/datamapping/DefaultDataReversalAction.java new file mode 100644 index 0000000..3392c03 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/datamapping/DefaultDataReversalAction.java @@ -0,0 +1,50 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.datamapping; + +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.api.manager.context.DataMapperContext; +import com.inspur.edp.bff.spi.utils.BffActionNames; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.ArrayList; + +public class DefaultDataReversalAction extends DataReversalMappingAction{ + + public DefaultDataReversalAction(DataMapperContext context) + { + super(context); + } + + @Override + protected void execute() + { + ArrayList beDatas = new ArrayList(); + + IDataConvertor dataConvertor = getContext().getDataConvertor(); + + for (IEntityData entityData : getMapContext().getTargetResult()) + { + + IEntityData beData = getContext().getLcp().createObjectData(); + dataConvertor.convertFromVMData(entityData, beData); + beDatas.add(beData); + } + getMapContext().getMappedData().put(BffActionNames.DefaultName, beDatas); + //MapContext.TargetResult = vmDatas; + } +} -- Gitee From c20cb9b617aeb265f57fc52c39b766e462248b5a Mon Sep 17 00:00:00 2001 From: Jakeem Date: Fri, 28 Oct 2022 17:54:09 +0800 Subject: [PATCH 51/81] =?UTF-8?q?1.=20=E6=B7=BB=E5=8A=A0=E4=BA=86=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=92=8C=E6=89=B9=E9=87=8F=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bff-framework-spi/bff-framework-spi.iml | 4 ++- .../action/delete/AbstractDeleteAction.java | 35 ++++++++++++++++++ .../spi/action/delete/AfterDeleteAction.java | 35 ++++++++++++++++++ .../spi/action/delete/BeforeDeleteAction.java | 36 +++++++++++++++++++ .../action/delete/DefaultDeleteAction.java | 33 +++++++++++++++++ .../AbstractMultiDeleteAction.java | 36 +++++++++++++++++++ .../multidelete/AfterMultiDeleteAction.java | 35 ++++++++++++++++++ .../multidelete/BeforeMultiDeleteAction.java | 35 ++++++++++++++++++ .../multidelete/DefaultMultiDeleteAction.java | 34 ++++++++++++++++++ 9 files changed, 282 insertions(+), 1 deletion(-) create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/delete/AbstractDeleteAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/delete/AfterDeleteAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/delete/BeforeDeleteAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/delete/DefaultDeleteAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/multidelete/AbstractMultiDeleteAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/multidelete/AfterMultiDeleteAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/multidelete/BeforeMultiDeleteAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/multidelete/DefaultMultiDeleteAction.java diff --git a/bff-framework-spi/bff-framework-spi.iml b/bff-framework-spi/bff-framework-spi.iml index 5fc4aec..64eabaf 100644 --- a/bff-framework-spi/bff-framework-spi.iml +++ b/bff-framework-spi/bff-framework-spi.iml @@ -5,7 +5,9 @@ - + + + diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/delete/AbstractDeleteAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/delete/AbstractDeleteAction.java new file mode 100644 index 0000000..1b63829 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/delete/AbstractDeleteAction.java @@ -0,0 +1,35 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.delete; + +import com.inspur.edp.bff.api.manager.context.DeleteContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class AbstractDeleteAction extends AbstractFSAction { + + private DeleteContext deleteContext; + protected final DeleteContext getDeleteContext() + { + return deleteContext; + } + + protected AbstractDeleteAction(DeleteContext context) + { + deleteContext = context; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/delete/AfterDeleteAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/delete/AfterDeleteAction.java new file mode 100644 index 0000000..26e170c --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/delete/AfterDeleteAction.java @@ -0,0 +1,35 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.delete; + +import com.inspur.edp.bff.api.manager.context.DeleteContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class AfterDeleteAction extends AbstractFSAction { + + private DeleteContext deleteContext; + protected final DeleteContext getDeleteContext() + { + return deleteContext; + } + + protected AfterDeleteAction(DeleteContext context) + { + deleteContext = context; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/delete/BeforeDeleteAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/delete/BeforeDeleteAction.java new file mode 100644 index 0000000..cebdfd0 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/delete/BeforeDeleteAction.java @@ -0,0 +1,36 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.delete; + +import com.inspur.edp.bff.api.manager.context.DeleteContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class BeforeDeleteAction extends AbstractFSAction { + + private DeleteContext deleteContext; + protected final DeleteContext getDeleteContext() + { + return deleteContext; + } + + protected BeforeDeleteAction(DeleteContext context) + { + deleteContext = context; + } + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/delete/DefaultDeleteAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/delete/DefaultDeleteAction.java new file mode 100644 index 0000000..37908f2 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/delete/DefaultDeleteAction.java @@ -0,0 +1,33 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.delete; + +import com.inspur.edp.bff.api.manager.context.DeleteContext; + +public class DefaultDeleteAction extends AbstractDeleteAction{ + + public DefaultDeleteAction(DeleteContext context) + { + super(context); + } + + @Override + protected void execute() + { + getLcp().delete(getDeleteContext().getDataId()); + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/multidelete/AbstractMultiDeleteAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/multidelete/AbstractMultiDeleteAction.java new file mode 100644 index 0000000..fca8f34 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/multidelete/AbstractMultiDeleteAction.java @@ -0,0 +1,36 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.multidelete; + +import com.inspur.edp.bff.api.manager.context.DeleteContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class AbstractMultiDeleteAction extends AbstractFSAction { + + private DeleteContext deleteContext; + protected final DeleteContext getDeleteContext() + { + return deleteContext; + } + + protected AbstractMultiDeleteAction(DeleteContext context) + { + deleteContext = context; + } +} + diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/multidelete/AfterMultiDeleteAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/multidelete/AfterMultiDeleteAction.java new file mode 100644 index 0000000..fa90a75 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/multidelete/AfterMultiDeleteAction.java @@ -0,0 +1,35 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.multidelete; + +import com.inspur.edp.bff.api.manager.context.DeleteContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class AfterMultiDeleteAction extends AbstractFSAction { + + private DeleteContext deleteContext; + protected final DeleteContext getDeleteContext() + { + return deleteContext; + } + + protected AfterMultiDeleteAction(DeleteContext context) + { + deleteContext = context; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/multidelete/BeforeMultiDeleteAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/multidelete/BeforeMultiDeleteAction.java new file mode 100644 index 0000000..98bcf20 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/multidelete/BeforeMultiDeleteAction.java @@ -0,0 +1,35 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.multidelete; + +import com.inspur.edp.bff.api.manager.context.DeleteContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class BeforeMultiDeleteAction extends AbstractFSAction { + + private DeleteContext deleteContext; + protected final DeleteContext getDeleteContext() + { + return deleteContext; + } + + protected BeforeMultiDeleteAction(DeleteContext context) + { + deleteContext = context; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/multidelete/DefaultMultiDeleteAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/multidelete/DefaultMultiDeleteAction.java new file mode 100644 index 0000000..90363e1 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/multidelete/DefaultMultiDeleteAction.java @@ -0,0 +1,34 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.multidelete; + +import com.inspur.edp.bff.api.manager.context.DeleteContext; +import com.inspur.edp.bff.spi.action.delete.AbstractDeleteAction; + +public class DefaultMultiDeleteAction extends AbstractMultiDeleteAction { + + public DefaultMultiDeleteAction(DeleteContext context) + { + super(context); + } + + @Override + protected void execute() + { + getLcp().delete(getDeleteContext().getDataIds()); + } +} -- Gitee From 09ae99b3a8909f7d81fde6ee5820cf07ac0816c1 Mon Sep 17 00:00:00 2001 From: Jakeem Date: Fri, 28 Oct 2022 18:02:07 +0800 Subject: [PATCH 52/81] =?UTF-8?q?1.=20modify=E5=92=8CQuery=E5=8A=A8?= =?UTF-8?q?=E4=BD=9C=E5=AE=9E=E4=BD=93=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/modify/AbstractModifyAction.java | 36 ++++++++ .../spi/action/modify/AfterModifyAction.java | 35 ++++++++ .../spi/action/modify/BeforeModifyAction.java | 35 ++++++++ .../action/modify/DefaultModifyAction.java | 41 +++++++++ .../spi/action/query/AbstractQueryAction.java | 38 ++++++++ .../spi/action/query/AfterQueryAction.java | 35 ++++++++ .../query/BaseQueryConditionAction.java | 89 +++++++++++++++++++ .../spi/action/query/BeforeQueryAction.java | 35 ++++++++ .../spi/action/query/DefaultQueryAction.java | 87 ++++++++++++++++++ 9 files changed, 431 insertions(+) create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/modify/AbstractModifyAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/modify/AfterModifyAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/modify/BeforeModifyAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/modify/DefaultModifyAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/AbstractQueryAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/AfterQueryAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/BaseQueryConditionAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/BeforeQueryAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/DefaultQueryAction.java diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/modify/AbstractModifyAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/modify/AbstractModifyAction.java new file mode 100644 index 0000000..5e9e79f --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/modify/AbstractModifyAction.java @@ -0,0 +1,36 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.modify; + +import com.inspur.edp.bff.api.manager.context.ModifyContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class AbstractModifyAction extends AbstractFSAction { + + private ModifyContext modifyContext; + protected final ModifyContext getModifyContext() + { + return modifyContext; + } + + protected AbstractModifyAction(ModifyContext context) + { + modifyContext = context; + } + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/modify/AfterModifyAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/modify/AfterModifyAction.java new file mode 100644 index 0000000..5efc317 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/modify/AfterModifyAction.java @@ -0,0 +1,35 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.modify; + +import com.inspur.edp.bff.api.manager.context.ModifyContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class AfterModifyAction extends AbstractFSAction { + + private ModifyContext modifyContext; + protected final ModifyContext getModifyContext() + { + return modifyContext; + } + + protected AfterModifyAction(ModifyContext context) + { + modifyContext = context; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/modify/BeforeModifyAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/modify/BeforeModifyAction.java new file mode 100644 index 0000000..0a27c32 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/modify/BeforeModifyAction.java @@ -0,0 +1,35 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.modify; + +import com.inspur.edp.bff.api.manager.context.ModifyContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class BeforeModifyAction extends AbstractFSAction { + + private ModifyContext modifyContext; + protected final ModifyContext getModifyContext() + { + return modifyContext; + } + + protected BeforeModifyAction(ModifyContext context) + { + modifyContext = context; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/modify/DefaultModifyAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/modify/DefaultModifyAction.java new file mode 100644 index 0000000..c5cc8ad --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/modify/DefaultModifyAction.java @@ -0,0 +1,41 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.modify; + +import com.inspur.edp.bff.api.manager.context.ModifyContext; +import com.inspur.edp.bff.spi.utils.BffActionNames; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; + +import java.util.ArrayList; + +public class DefaultModifyAction extends AbstractModifyAction{ + + public DefaultModifyAction(ModifyContext context) + { + super(context); + } + + @Override + protected void execute() { + ArrayList defaultChange = getModifyContext().getMappedChange().get(BffActionNames.DefaultName); + if(defaultChange == null) + throw new RuntimeException("修改操作执行异常:没有获取到变更集"); + + IChangeDetail beChange = defaultChange.get(0); + getLcp().modify(beChange); + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/AbstractQueryAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/AbstractQueryAction.java new file mode 100644 index 0000000..924230f --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/AbstractQueryAction.java @@ -0,0 +1,38 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.query; + +import com.inspur.edp.bff.api.manager.context.QueryContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.ArrayList; +import java.util.HashMap; + +public abstract class AbstractQueryAction extends AbstractFSAction>> { + + private QueryContext queryContext; + protected final QueryContext getQueryContext() + { + return queryContext; + } + + protected AbstractQueryAction(QueryContext context) + { + queryContext = context; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/AfterQueryAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/AfterQueryAction.java new file mode 100644 index 0000000..eaf4ab0 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/AfterQueryAction.java @@ -0,0 +1,35 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.query; + +import com.inspur.edp.bff.api.manager.context.QueryContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class AfterQueryAction extends AbstractFSAction { + + private QueryContext queryContext; + protected final QueryContext getQueryContext() + { + return queryContext; + } + + protected AfterQueryAction(QueryContext context) + { + queryContext = context; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/BaseQueryConditionAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/BaseQueryConditionAction.java new file mode 100644 index 0000000..c986b8b --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/BaseQueryConditionAction.java @@ -0,0 +1,89 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.query; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.inspur.edp.bff.api.manager.context.QueryContext; +import com.inspur.edp.cef.entity.condition.FilterCondition; +import com.inspur.edp.cef.entity.condition.SortCondition; +import com.inspur.edp.cef.spi.jsonser.base.StringUtils; + +import java.io.IOException; +import java.util.ArrayList; + +public abstract class BaseQueryConditionAction extends BeforeQueryAction { + + private ArrayList defaultFilterCondition; + private ArrayList defaultOrderByCondition; + + public BaseQueryConditionAction(QueryContext context) { + super(context); + } + + public BaseQueryConditionAction(String filterStr, String sortStr, QueryContext context) { + super(context); + + ObjectMapper mapper=new ObjectMapper(); + try { + if(!StringUtils.isNullOrEmpty(filterStr)) + defaultFilterCondition=mapper.readValue(filterStr,new TypeReference>(){}); + } + catch (IOException e) { + throw new RuntimeException("过滤条件反序列化失败:"+filterStr); + } + + try { + if(!StringUtils.isNullOrEmpty(sortStr)) + defaultOrderByCondition=mapper.readValue(sortStr,new TypeReference>(){}); + } + catch (IOException e) { + throw new RuntimeException("排序条件反序列化失败:"+sortStr); + } + + } + + public ArrayList getDefaultOrderByCondition() { + return defaultOrderByCondition; + } + + public ArrayList getDefaultFilterCondition() { + return defaultFilterCondition; + } + + @Override + protected void execute() { + //默认的filter + ArrayList sortConditions = getDefaultOrderByCondition(); + ArrayList filterConditions = getDefaultFilterCondition(); + + //获取外部传进来的filter + ArrayList sortConditions1 = getQueryContext().getFilter().getSortConditions(); + ArrayList filterConditions1 = getQueryContext().getFilter().getFilterConditions(); + //默认的filter + getQueryContext().getFilter().setSortConditions(sortConditions); + getQueryContext().getFilter().setFilterConditions(filterConditions); + + //加上外部传进来的filter + if (sortConditions1 != null) { + getQueryContext().getFilter().addSortConditions(sortConditions1); + } + if (filterConditions1 != null) { + getQueryContext().getFilter().addFilterConditions(filterConditions1); + } + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/BeforeQueryAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/BeforeQueryAction.java new file mode 100644 index 0000000..de6e0f4 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/BeforeQueryAction.java @@ -0,0 +1,35 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.query; + +import com.inspur.edp.bff.api.manager.context.QueryContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class BeforeQueryAction extends AbstractFSAction { + + private QueryContext queryContext; + protected final QueryContext getQueryContext() + { + return queryContext; + } + + protected BeforeQueryAction(QueryContext context) + { + queryContext = context; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/DefaultQueryAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/DefaultQueryAction.java new file mode 100644 index 0000000..0f0ab04 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/query/DefaultQueryAction.java @@ -0,0 +1,87 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.query; + +import com.inspur.edp.bef.api.lcp.IStandardLcp; +import com.inspur.edp.bff.api.manager.SourceType; +import com.inspur.edp.bff.api.manager.context.QueryContext; +import com.inspur.edp.bff.spi.utils.AuthUtils; +import com.inspur.edp.bff.spi.utils.BffActionNames; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.ArrayList; +import java.util.HashMap; + +public class DefaultQueryAction extends AbstractQueryAction{ + + + public DefaultQueryAction(QueryContext context) + { + super(context); + } + + @Override + protected void execute() { + if (getContext().getSourceConfigs() == null || getContext().getSourceConfigs().get(0).getSourceType() == SourceType.Be) + { + IStandardLcp lcp =getLcp(); + if(getQueryContext().getUseCustomAuth()&&getQueryContext().getAuthInfo()!=null) { + + AuthUtils.buildAuthInfo( + lcp.getBefContext().getAuthInfo(), + getQueryContext().getAuthInfo().getExtType(), + getQueryContext().getAuthInfo().getExtend1(), + getQueryContext().getAuthInfo().getExtend2(), + getQueryContext().getAuthInfo().getExtend3(), + getQueryContext().getAuthInfo().getExtend4(), + getQueryContext().getAuthInfo().getExtend5() + ); + } + ArrayList queryResult; + //兼容之前 + if(this.getContext().getRootEntityPropertyMapper()!=null){ + + String voNodeCode=getContext().getBECodeFromVM(getContext().getRootEntityPropertyMapper().getVOCode()); + queryResult= new ArrayList(lcp.query(voNodeCode,getQueryContext().getFilter())); + } + else { + + queryResult=new ArrayList(lcp.query(this.getQueryContext().getFilter())); + } + + getQueryContext().setQueryResult(queryResult); + if (queryResult == null) + { + setResult(null); + } + HashMap> result = new HashMap<>(); + result.put(BffActionNames.DefaultName, queryResult); + setResult(result); + } + else + { + //var queryResult = ServiceManager.GetService().GetQueryManager(Context.SourceConfigs[0].SourceConfigId).Query(QueryContext.Param, QueryContext.PageInfo, QueryContext.ExtendCond).Data; + //QueryContext.QueryResult = queryResult; + //if (queryResult == null) + // Result = null; + //Dictionary> result = new Dictionary>(); + //result.Add("Default", queryResult); + //Result = result; + } + } + +} -- Gitee From 1554a6d0c3fe609a31c19971c238adf0171db7f4 Mon Sep 17 00:00:00 2001 From: Jakeem Date: Fri, 28 Oct 2022 18:11:56 +0800 Subject: [PATCH 53/81] =?UTF-8?q?1.=20=E6=B7=BB=E5=8A=A0retrieve=20?= =?UTF-8?q?=E5=92=8C=20retrieveDefault=E5=8A=A8=E4=BD=9C=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E7=B1=BB;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../retrieve/AbstractRetrieveAction.java | 35 +++ .../action/retrieve/AfterRetrieveAction.java | 35 +++ .../action/retrieve/BeforeRetrieveAction.java | 36 +++ .../retrieve/DefaultRetrieveAction.java | 62 ++++++ .../AbstractRetrieveDefaultAction.java | 36 +++ .../AfterRetrieveDefaultAction.java | 35 +++ .../BeforeRetrieveDefaultAction.java | 35 +++ .../DefaultRetrieveDefaultAction.java | 207 ++++++++++++++++++ 8 files changed, 481 insertions(+) create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrieve/AbstractRetrieveAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrieve/AfterRetrieveAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrieve/BeforeRetrieveAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrieve/DefaultRetrieveAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrievedefault/AbstractRetrieveDefaultAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrievedefault/AfterRetrieveDefaultAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrievedefault/BeforeRetrieveDefaultAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrievedefault/DefaultRetrieveDefaultAction.java diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrieve/AbstractRetrieveAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrieve/AbstractRetrieveAction.java new file mode 100644 index 0000000..ef69d72 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrieve/AbstractRetrieveAction.java @@ -0,0 +1,35 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.retrieve; + +import com.inspur.edp.bff.api.manager.context.RetrieveContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class AbstractRetrieveAction extends AbstractFSAction { + + private RetrieveContext retrieveContext; + protected final RetrieveContext getRetrieveContext() + { + return retrieveContext; + } + + protected AbstractRetrieveAction(RetrieveContext context) + { + retrieveContext = context; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrieve/AfterRetrieveAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrieve/AfterRetrieveAction.java new file mode 100644 index 0000000..9740bcc --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrieve/AfterRetrieveAction.java @@ -0,0 +1,35 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.retrieve; + +import com.inspur.edp.bff.api.manager.context.RetrieveContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class AfterRetrieveAction extends AbstractFSAction { + + private RetrieveContext retrieveContext; + protected final RetrieveContext getRetrieveContext() + { + return retrieveContext; + } + + protected AfterRetrieveAction(RetrieveContext context) + { + retrieveContext = context; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrieve/BeforeRetrieveAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrieve/BeforeRetrieveAction.java new file mode 100644 index 0000000..29835e2 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrieve/BeforeRetrieveAction.java @@ -0,0 +1,36 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.retrieve; + +import com.inspur.edp.bff.api.manager.context.RetrieveContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class BeforeRetrieveAction extends AbstractFSAction { + + private RetrieveContext retrieveContext; + protected final RetrieveContext getRetrieveContext() + { + return retrieveContext; + } + + protected BeforeRetrieveAction(RetrieveContext context) + { + retrieveContext = context; + } + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrieve/DefaultRetrieveAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrieve/DefaultRetrieveAction.java new file mode 100644 index 0000000..97feb32 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrieve/DefaultRetrieveAction.java @@ -0,0 +1,62 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.retrieve; + +import com.inspur.edp.bef.api.parameter.retrieve.RespectiveRetrieveResult; +import com.inspur.edp.bef.api.parameter.retrieve.RetrieveParam; +import com.inspur.edp.bef.api.parameter.retrieve.RetrieveResult; +import com.inspur.edp.bff.api.manager.context.RetrieveContext; +import com.inspur.edp.bff.spi.utils.BffActionNames; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.ArrayList; +import java.util.Arrays; + +public class DefaultRetrieveAction extends AbstractRetrieveAction{ + + public DefaultRetrieveAction(RetrieveContext context) + { + super(context); + } + + @Override + protected void execute() + { + ArrayList dataIds = getRetrieveContext().getDataIds(); + RetrieveParam param = getRetrieveContext().getParam(); + if (param == null) { + RetrieveParam tempVar = new RetrieveParam(); + tempVar.setNeedLock(false); + param = tempVar; + } + if (dataIds.size() == 1) { + RespectiveRetrieveResult retriveResult = getLcp().retrieve(dataIds.get(0), param); + if (retriveResult.getData() == null) { + return; + } + getRetrieveContext().getRetrieveData().put(BffActionNames.DefaultName, new ArrayList(Arrays.asList(new IEntityData[]{retriveResult.getData()}))); + } + else { + RetrieveResult retriveResult = getLcp().retrieve(dataIds, param); + if (retriveResult.getDatas() == null) { + return; + } + getRetrieveContext().getRetrieveData().put(BffActionNames.DefaultName, new ArrayList(retriveResult.getDatas().values())); + } + } + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrievedefault/AbstractRetrieveDefaultAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrievedefault/AbstractRetrieveDefaultAction.java new file mode 100644 index 0000000..c587884 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrievedefault/AbstractRetrieveDefaultAction.java @@ -0,0 +1,36 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.retrievedefault; + +import com.inspur.edp.bff.api.manager.context.RetrieveDefaultContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class AbstractRetrieveDefaultAction extends AbstractFSAction { + + private RetrieveDefaultContext retrieveDefaultContext; + protected final RetrieveDefaultContext getRetrieveDefaultContext() + { + return retrieveDefaultContext; + } + + protected AbstractRetrieveDefaultAction(RetrieveDefaultContext context) + { + retrieveDefaultContext = context; + } + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrievedefault/AfterRetrieveDefaultAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrievedefault/AfterRetrieveDefaultAction.java new file mode 100644 index 0000000..8796a8e --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrievedefault/AfterRetrieveDefaultAction.java @@ -0,0 +1,35 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.retrievedefault; + +import com.inspur.edp.bff.api.manager.context.RetrieveDefaultContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class AfterRetrieveDefaultAction extends AbstractFSAction { + + private RetrieveDefaultContext retrieveDefaultContext; + protected final RetrieveDefaultContext getRetrieveDefaultContext() + { + return retrieveDefaultContext; + } + + protected AfterRetrieveDefaultAction(RetrieveDefaultContext context) + { + retrieveDefaultContext = context; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrievedefault/BeforeRetrieveDefaultAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrievedefault/BeforeRetrieveDefaultAction.java new file mode 100644 index 0000000..0d70241 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrievedefault/BeforeRetrieveDefaultAction.java @@ -0,0 +1,35 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.retrievedefault; + +import com.inspur.edp.bff.api.manager.context.RetrieveDefaultContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class BeforeRetrieveDefaultAction extends AbstractFSAction { + + private RetrieveDefaultContext retrieveDefaultContext; + protected final RetrieveDefaultContext getRetrieveDefaultContext() + { + return retrieveDefaultContext; + } + + protected BeforeRetrieveDefaultAction(RetrieveDefaultContext context) + { + retrieveDefaultContext = context; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrievedefault/DefaultRetrieveDefaultAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrievedefault/DefaultRetrieveDefaultAction.java new file mode 100644 index 0000000..16aa084 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/retrievedefault/DefaultRetrieveDefaultAction.java @@ -0,0 +1,207 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.retrievedefault; + +import com.inspur.edp.bef.api.lcp.IStandardLcp; +import com.inspur.edp.bff.api.dataprocessor.IDefaultValueConvertor; +import com.inspur.edp.bff.api.extend.IBffEntityExtend; +import com.inspur.edp.bff.api.extend.IBffManagerExtend; +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.bff.api.manager.context.RetrieveDefaultContext; +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; +import com.inspur.edp.bff.spi.builtin.BffEntityResInfoImpl; +import com.inspur.edp.bff.spi.builtin.BffModelResInfoImpl; +import com.inspur.edp.bff.spi.builtin.BffPropertyInfo; +import com.inspur.edp.bff.spi.defaultvalue.DefaultValueUtil; +import com.inspur.edp.bff.spi.utils.BffActionNames; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import com.inspur.edp.cef.entity.changeset.ModifyChangeDetail; +import com.inspur.edp.cef.entity.entity.IEntityData; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.DataTypePropertyInfo; +import com.inspur.edp.cef.spi.entity.resourceInfo.ModelResInfo; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefEntityResInfoImpl; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefModelResInfoImpl; +import com.inspur.edp.cef.spi.jsonser.base.StringUtils; + +import com.inspur.edp.udt.entity.IUdtData; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DefaultRetrieveDefaultAction extends AbstractRetrieveDefaultAction{ + + + public DefaultRetrieveDefaultAction(RetrieveDefaultContext context) + { + super(context); + } + + @Override + protected void execute() { + + VoDefaultValue defaultValue = getRetrieveDefaultContext().getVoDefaultValue(); + String dataId = getRetrieveDefaultContext().getDataId(); + IEntityData beData = null; + IDefaultValueConvertor convertor = getContext().getDefaultValueConvertor(); + if(this.getModelInfo() instanceof BffModelResInfoImpl){ + beData= retrieveDefaultNew(defaultValue,dataId,convertor); + }else { + beData= retrieveDefaultOld(defaultValue,dataId,convertor); + } + getRetrieveDefaultContext().getRetrieveDefaultData().put(BffActionNames.DefaultName, new ArrayList(Arrays.asList(new IEntityData[] { beData }))); + } + + private ModelResInfo getModelInfo(){ + return this.getContext().getModelResourceInfo(); + } + + private IEntityData retrieveDefaultOld(VoDefaultValue defaultValue,String dataId, IDefaultValueConvertor convertor){ + if (defaultValue != null && convertor != null) { + Map beDefault = null; + ModelResInfo info = getContext().getBffManager().getModelInfo(); + if(info != null && info instanceof CefModelResInfoImpl){ + BffEntityResInfoImpl resInfo = (BffEntityResInfoImpl)info.getCustomResource(info.getRootNodeCode()); + BffPropertyInfo propertyInfo = (BffPropertyInfo)resInfo.getEntityTypeInfo().getPropertyInfos().values().toArray()[0]; + if(StringUtils.isNullOrEmpty(propertyInfo.getBeLabelId())){ + beDefault = convertor.convertFromVo(defaultValue); + }else{ + beDefault = DefaultValueUtil.transVoDefaultValueToBe(getContext(),defaultValue,null); + } + } + else + beDefault = convertor.convertFromVo(defaultValue); + return getLcp().retrieveDefault(beDefault); + } + else if (!StringUtils.isNullOrEmpty(dataId)) { + return getLcp().retrieveDefault(dataId); + } + else { + return getLcp().retrieveDefault(); + } + } + + private IEntityData retrieveDefaultNew(VoDefaultValue defaultValue,String dataId, IDefaultValueConvertor convertor){ + Map defaultValues=new HashMap<>(); + Map beDefault = null; + initDefaultValue(getContext().getBffManager(),getContext().getLcp(),defaultValues,null); + if ((defaultValue != null && convertor != null)) { + ModelResInfo info = getContext().getBffManager().getModelInfo(); + if(info != null && info instanceof CefModelResInfoImpl){ + BffEntityResInfoImpl resInfo = (BffEntityResInfoImpl)info.getCustomResource(info.getRootNodeCode()); + BffPropertyInfo propertyInfo = (BffPropertyInfo)resInfo.getEntityTypeInfo().getPropertyInfos().values().toArray()[0]; + if(StringUtils.isNullOrEmpty(propertyInfo.getBeLabelId())){ + beDefault = convertor.convertFromVo(defaultValue); + }else{ + beDefault = DefaultValueUtil.transVoDefaultValueToBe(getContext(),defaultValue,null); + } + } + else{ + beDefault = convertor.convertFromVo(defaultValue); + } + } + //合并默认值 + mergeDefaultValue(beDefault,defaultValues); + + if (!StringUtils.isNullOrEmpty(dataId)) { + return getLcp().retrieveDefault(dataId,defaultValues); + } + else { + return getLcp().retrieveDefault(defaultValues); + } + } + public void mergeDefaultValue(Map outerValue,Map innerDefaultValue){ + if (outerValue==null || outerValue.size()==0) + return; + for (Map.Entry defaultValue:outerValue.entrySet()){ + innerDefaultValue.put(defaultValue.getKey(),defaultValue.getValue()); + } + } + private void initDefaultValue(IFSManager manager, IStandardLcp lcp,Map values,ArrayList nodeCodes) { + initBasicDefaultValue(manager,lcp,values,nodeCodes); + List extendList=manager.getBffContext().getExtList(); + if(extendList==null ||extendList.size()==0) + return; + initChangedDefaultValue(manager,lcp,values,extendList,nodeCodes); + mapExtendDefaultValue(manager,extendList,values); + } + + private void mapExtendDefaultValue(IFSManager manager,List extendList,Map values) { + Map extendDefaultValues=new HashMap<>(); + Map beDefaultValues=new HashMap<>(); + for (IBffManagerExtend bffManagerExtend:extendList){ + IBffEntityExtend bffEntityExtend=bffManagerExtend.getDataTypeExtend(); + //处理变更默认值 + initExtendDefaultValue(manager,bffEntityExtend,extendDefaultValues); + //转换扩展默认值 + bffManagerExtend.mapDefaultValuesFromVo(extendDefaultValues,beDefaultValues); + //合并默认值 + mergeDefaultValue(beDefaultValues,values); + } + } + + private void initExtendDefaultValue(IFSManager manager, IBffEntityExtend extend, Map values) { + CefEntityResInfoImpl entityResInfo=extend.getEntityResInfo(); + if(entityResInfo==null || entityResInfo.getEntityTypeInfo()==null ||entityResInfo.getEntityTypeInfo().getPropertyInfos()==null) + return; + Map propertyInfos=entityResInfo.getEntityTypeInfo().getPropertyInfos(); + for (Map.Entry propInfo:propertyInfos.entrySet() ){ + DataTypePropertyInfo propertyInfo=propInfo.getValue(); + if(propertyInfo.getDefaultValue()==null ||("".equals(propertyInfo.getDefaultValue().getRealValue()) ||propertyInfo.getDefaultValue().getRealValue()==null)) + continue; + DefaultValueUtil.dealExtendValue(manager,propertyInfo,null,values); + } + } + private void initBasicDefaultValue(IFSManager manager,IStandardLcp lcp, Map values,ArrayList nodeCodes){ + CefEntityResInfoImpl resInfo= (CefEntityResInfoImpl) manager.getModelInfo().getCustomResource(getContext().getBffManager().getModelInfo().getRootNodeCode()); + if(resInfo.getEntityTypeInfo()==null ||resInfo.getEntityTypeInfo().getPropertyInfos()==null|| resInfo.getEntityTypeInfo().getPropertyInfos().size()==0) + return ; + dealBasicPropDefaultValue(manager,lcp,resInfo.getEntityTypeInfo().getPropertyInfos(),values,nodeCodes); + } + private void initChangedDefaultValue(IFSManager manager, IStandardLcp lcp,Map values,List extendList,ArrayList nodeCodes){ + for (IBffManagerExtend bffManagerExtend:extendList){ + IBffEntityExtend bffEntityExtend=bffManagerExtend.getDataTypeExtend(); + dealChangePropertyValue(manager,lcp,bffEntityExtend,values,nodeCodes); + } + } + + private void dealChangePropertyValue(IFSManager manager,IStandardLcp lcp,IBffEntityExtend bffEntityDataExtend,Map values,ArrayList nodeCodes) { + bffEntityDataExtend.mapChangedDefaultValuesFromVo(manager,lcp,nodeCodes,values); + } + + private void dealBasicPropDefaultValue(IFSManager manager, IStandardLcp lcp,Map prpertyInfos,Map values,ArrayList nodeCodes){ + for (Map.Entry propertyInfo:prpertyInfos.entrySet()){ + DataTypePropertyInfo propertyInfoTemp=propertyInfo.getValue(); + String beLabelId=((BffPropertyInfo)propertyInfoTemp).getBeLabelId(); + if(defaultValueIsNull(propertyInfoTemp)) + continue; + if(beLabelId==null || "".equals(beLabelId)) + continue; + DefaultValueUtil.dealDefaultValue(manager,lcp,propertyInfoTemp,nodeCodes,values); + } + } + + private boolean defaultValueIsNull(DataTypePropertyInfo propertyInfo) { + if(propertyInfo.getDefaultValue()==null) + return true; + Object value=propertyInfo.getDefaultValue().getRealValue(); + if(value==null ||"".equals(value)) + return true; + return false; + } +} -- Gitee From 5925143d71bb2cc61043716025e8366a5e617ad7 Mon Sep 17 00:00:00 2001 From: Jakeem Date: Fri, 28 Oct 2022 18:18:17 +0800 Subject: [PATCH 54/81] =?UTF-8?q?1.=20=E6=B7=BB=E5=8A=A0=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=8A=A8=E4=BD=9C=E7=9A=84Assembler=E5=AE=9E=E4=BD=93=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../builtin/DefaultChangeMapperAssembler.java | 44 ++++++++++ .../builtin/DefaultDataMapperAssembler.java | 43 ++++++++++ .../builtin/DefaultExtendDeleteAssembler.java | 83 +++++++++++++++++++ .../builtin/DefaultExtendModifyAssembler.java | 52 ++++++++++++ .../builtin/DefaultExtendQueryAssembler.java | 53 ++++++++++++ .../DefaultExtendRetrieveAssembler.java | 53 ++++++++++++ .../builtin/DefaultExtendSaveAssembler.java | 44 ++++++++++ .../DefaultRetrieveDefaultAssembler.java | 53 ++++++++++++ 8 files changed, 425 insertions(+) create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultChangeMapperAssembler.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultDataMapperAssembler.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendDeleteAssembler.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendModifyAssembler.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendQueryAssembler.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendRetrieveAssembler.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendSaveAssembler.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultRetrieveDefaultAssembler.java diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultChangeMapperAssembler.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultChangeMapperAssembler.java new file mode 100644 index 0000000..c1fd9cd --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultChangeMapperAssembler.java @@ -0,0 +1,44 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.assembler.builtin; + +import com.inspur.edp.bff.api.manager.context.ChangeMapperContext; +import com.inspur.edp.bff.spi.action.changemapping.ChangeMappingAction; +import com.inspur.edp.bff.spi.action.changemapping.ChangeReversalMappingAction; +import com.inspur.edp.bff.spi.assembler.AbstractChangeMapperAssembler; + +import java.util.ArrayList; + +public class DefaultChangeMapperAssembler extends AbstractChangeMapperAssembler { + + private ArrayList changeMappingActions; + private ArrayList changeReversalMappingActions; + + @Override + protected ArrayList getChangeMappingActions(ChangeMapperContext mappingContext) { + if(changeMappingActions == null) + changeMappingActions = new ArrayList<>(); + return changeMappingActions; + } + + @Override + protected ArrayList getChangeReversalMappingActions(ChangeMapperContext mappingContext) { + if(changeReversalMappingActions == null) + changeReversalMappingActions = new ArrayList<>(); + return changeReversalMappingActions; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultDataMapperAssembler.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultDataMapperAssembler.java new file mode 100644 index 0000000..3bce8f5 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultDataMapperAssembler.java @@ -0,0 +1,43 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.assembler.builtin; + +import com.inspur.edp.bff.api.manager.context.DataMapperContext; +import com.inspur.edp.bff.spi.action.datamapping.DataMappingAction; +import com.inspur.edp.bff.spi.action.datamapping.DataReversalMappingAction; +import com.inspur.edp.bff.spi.assembler.AbstractDataMapperAssembler; + +import java.util.ArrayList; + +public class DefaultDataMapperAssembler extends AbstractDataMapperAssembler { + + private ArrayList dataMappingActions; + private ArrayList dataReversalMappingActions; + @Override + protected ArrayList getDataMappingActions(DataMapperContext mappingContext) { + if(dataMappingActions == null) + dataMappingActions = new ArrayList<>(); + return dataMappingActions; + } + + @Override + protected ArrayList getDataReversalMappingActions(DataMapperContext mappingContext) { + if(dataReversalMappingActions == null) + dataReversalMappingActions = new ArrayList<>(); + return dataReversalMappingActions; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendDeleteAssembler.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendDeleteAssembler.java new file mode 100644 index 0000000..da959d7 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendDeleteAssembler.java @@ -0,0 +1,83 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.assembler.builtin; + +import com.inspur.edp.bff.api.manager.context.DeleteContext; +import com.inspur.edp.bff.spi.action.delete.AbstractDeleteAction; +import com.inspur.edp.bff.spi.action.delete.AfterDeleteAction; +import com.inspur.edp.bff.spi.action.delete.BeforeDeleteAction; +import com.inspur.edp.bff.spi.action.multidelete.AbstractMultiDeleteAction; +import com.inspur.edp.bff.spi.action.multidelete.AfterMultiDeleteAction; +import com.inspur.edp.bff.spi.action.multidelete.BeforeMultiDeleteAction; +import com.inspur.edp.bff.spi.assembler.AbstractExtendDeleteAssembler; + +import java.util.ArrayList; + +public class DefaultExtendDeleteAssembler extends AbstractExtendDeleteAssembler { + + private ArrayList beforeDeleteActions; + private ArrayList deleteActions; + private ArrayList afterDeleteActions; + private ArrayList multiDeleteActions; + private ArrayList beforeMultiDeleteActions; + private ArrayList afterMultiDeleteActions; + + @Override + protected ArrayList getBeforeDeleteActions(DeleteContext delContext) { + if(beforeDeleteActions == null) + beforeDeleteActions = new ArrayList<>(); + return beforeDeleteActions; + } + + @Override + protected ArrayList getDeleteActions(DeleteContext delContext) { + if(deleteActions == null) + deleteActions = new ArrayList<>(); + return deleteActions; + } + + @Override + protected ArrayList getAfterDeleteActions(DeleteContext delContext) { + if(afterDeleteActions == null) + afterDeleteActions = new ArrayList<>(); + return afterDeleteActions; + } + + @Override + protected ArrayList getMultiDeleteActions(DeleteContext deleteContext) { + if(multiDeleteActions == null) + multiDeleteActions = new ArrayList<>(); + return multiDeleteActions; + } + + + @Override + protected ArrayList getBeforeMultiDeleteActions(DeleteContext deleteContext) { + if(beforeMultiDeleteActions == null) + beforeMultiDeleteActions = new ArrayList<>(); + return beforeMultiDeleteActions; + } + + + @Override + protected ArrayList getAfterMultiDeleteActions(DeleteContext deleteContext) { + if(afterMultiDeleteActions == null) + afterMultiDeleteActions = new ArrayList<>(); + return afterMultiDeleteActions; + } + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendModifyAssembler.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendModifyAssembler.java new file mode 100644 index 0000000..5a4f278 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendModifyAssembler.java @@ -0,0 +1,52 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.assembler.builtin; + +import com.inspur.edp.bff.api.manager.context.ModifyContext; +import com.inspur.edp.bff.spi.action.modify.AbstractModifyAction; +import com.inspur.edp.bff.spi.action.modify.AfterModifyAction; +import com.inspur.edp.bff.spi.action.modify.BeforeModifyAction; +import com.inspur.edp.bff.spi.assembler.AbstractExtendModifyAssembler; + +import java.util.ArrayList; + +public class DefaultExtendModifyAssembler extends AbstractExtendModifyAssembler { + private ArrayList beforeModifyActions; + private ArrayList modifyActions; + private ArrayList afterModifyActions; + + @Override + protected ArrayList getBeforeModifyActions(ModifyContext modifyContext) { + if(beforeModifyActions == null) + beforeModifyActions = new ArrayList<>(); + return beforeModifyActions; + } + + @Override + protected ArrayList getModifyActions(ModifyContext modifyContext) { + if(modifyActions == null) + modifyActions = new ArrayList<>(); + return modifyActions; + } + + @Override + protected ArrayList getAfterModifyActions(ModifyContext modifyContext) { + if(afterModifyActions == null) + afterModifyActions = new ArrayList<>(); + return afterModifyActions; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendQueryAssembler.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendQueryAssembler.java new file mode 100644 index 0000000..e5e9496 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendQueryAssembler.java @@ -0,0 +1,53 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.assembler.builtin; + +import com.inspur.edp.bff.api.manager.context.QueryContext; +import com.inspur.edp.bff.spi.action.query.AbstractQueryAction; +import com.inspur.edp.bff.spi.action.query.AfterQueryAction; +import com.inspur.edp.bff.spi.action.query.BeforeQueryAction; +import com.inspur.edp.bff.spi.assembler.AbstractExtendQueryAssembler; + +import java.util.ArrayList; + +public class DefaultExtendQueryAssembler extends AbstractExtendQueryAssembler { + + private ArrayList beforeQueryActions; + private ArrayList queryActions; + private ArrayList afterQueryActions; + + @Override + protected ArrayList getBeforeQueryActions(QueryContext queryContext) { + if(beforeQueryActions == null) + beforeQueryActions = new ArrayList<>(); + return beforeQueryActions; + } + + @Override + protected ArrayList getQueryActions(QueryContext queryContext) { + if(queryActions == null) + queryActions = new ArrayList<>(); + return queryActions; + } + + @Override + protected ArrayList getAfterQueryActions(QueryContext queryContext) { + if(afterQueryActions == null) + afterQueryActions = new ArrayList<>(); + return afterQueryActions; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendRetrieveAssembler.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendRetrieveAssembler.java new file mode 100644 index 0000000..9725aaa --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendRetrieveAssembler.java @@ -0,0 +1,53 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.assembler.builtin; + +import com.inspur.edp.bff.api.manager.context.RetrieveContext; +import com.inspur.edp.bff.spi.action.retrieve.AbstractRetrieveAction; +import com.inspur.edp.bff.spi.action.retrieve.AfterRetrieveAction; +import com.inspur.edp.bff.spi.action.retrieve.BeforeRetrieveAction; +import com.inspur.edp.bff.spi.assembler.AbstractExtendRetrieveAssembler; + +import java.util.ArrayList; + +public class DefaultExtendRetrieveAssembler extends AbstractExtendRetrieveAssembler { + + private ArrayList beforeRetrieveActions; + private ArrayList retrieveActions; + private ArrayList afterRetrieveActions; + + @Override + protected ArrayList getBeforeRetrieveActions(RetrieveContext retrieveContext) { + if(beforeRetrieveActions == null) + beforeRetrieveActions = new ArrayList<>(); + return beforeRetrieveActions; + } + + @Override + protected ArrayList getRetrieveActions(RetrieveContext retrieveContext) { + if(retrieveActions == null) + retrieveActions = new ArrayList<>(); + return retrieveActions; + } + + @Override + protected ArrayList getAfterRetrieveActions(RetrieveContext retrieveContext) { + if(afterRetrieveActions == null) + afterRetrieveActions = new ArrayList<>(); + return afterRetrieveActions; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendSaveAssembler.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendSaveAssembler.java new file mode 100644 index 0000000..25abc38 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultExtendSaveAssembler.java @@ -0,0 +1,44 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.assembler.builtin; + +import com.inspur.edp.bff.api.manager.context.SaveContext; +import com.inspur.edp.bff.spi.action.save.AfterSaveAction; +import com.inspur.edp.bff.spi.action.save.BeforeSaveAction; +import com.inspur.edp.bff.spi.assembler.AbstractExtendSaveAssembler; + +import java.util.ArrayList; + +public class DefaultExtendSaveAssembler extends AbstractExtendSaveAssembler { + + private ArrayList beforeSaveActions; + private ArrayList afterSaveActions; + + @Override + protected ArrayList getBeforeSaveActions(SaveContext saveContext) { + if(beforeSaveActions == null) + beforeSaveActions = new ArrayList<>(); + return beforeSaveActions; + } + + @Override + protected ArrayList getAfterSaveActions(SaveContext saveContext) { + if(afterSaveActions == null) + afterSaveActions = new ArrayList<>(); + return afterSaveActions; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultRetrieveDefaultAssembler.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultRetrieveDefaultAssembler.java new file mode 100644 index 0000000..d53ce98 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/builtin/DefaultRetrieveDefaultAssembler.java @@ -0,0 +1,53 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.assembler.builtin; + +import com.inspur.edp.bff.api.manager.context.RetrieveDefaultContext; +import com.inspur.edp.bff.spi.action.retrievedefault.AbstractRetrieveDefaultAction; +import com.inspur.edp.bff.spi.action.retrievedefault.AfterRetrieveDefaultAction; +import com.inspur.edp.bff.spi.action.retrievedefault.BeforeRetrieveDefaultAction; +import com.inspur.edp.bff.spi.assembler.AbstractRetrieveDefaultAssembler; + +import java.util.ArrayList; + +public class DefaultRetrieveDefaultAssembler extends AbstractRetrieveDefaultAssembler { + + private ArrayList beforeCreateActions; + private ArrayList createActions; + private ArrayList afterCreateActions; + + @Override + protected ArrayList getBeforeRetrieveDefaultActions(RetrieveDefaultContext createContext) { + if(beforeCreateActions == null) + beforeCreateActions = new ArrayList<>(); + return beforeCreateActions; + } + + @Override + protected ArrayList getRetrieveDefaultActions(RetrieveDefaultContext createContext) { + if(createActions == null) + createActions = new ArrayList<>(); + return createActions; + } + + @Override + protected ArrayList getAfterRetrieveDefaultActions(RetrieveDefaultContext createContext) { + if(afterCreateActions == null) + afterCreateActions = new ArrayList<>(); + return afterCreateActions; + } +} -- Gitee From 4cd89b28c2a610d3e570f3289d6ac4144d0c8ed6 Mon Sep 17 00:00:00 2001 From: Jakeem Date: Fri, 28 Oct 2022 18:28:51 +0800 Subject: [PATCH 55/81] =?UTF-8?q?1.=20=E6=B7=BB=E5=8A=A0=E5=8A=A8=E4=BD=9C?= =?UTF-8?q?=E7=9A=84Assembler=E6=8A=BD=E8=B1=A1=E7=B1=BB=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assembler/AbstractAssemblerManager.java | 25 +++ .../AbstractChangeMapperAssembler.java | 66 ++++++++ .../AbstractDataMapperAssembler.java | 79 +++++++++ .../AbstractExtendDeleteAssembler.java | 134 +++++++++++++++ .../AbstractExtendModifyAssembler.java | 80 +++++++++ .../AbstractExtendQueryAssembler.java | 155 ++++++++++++++++++ .../AbstractExtendRetrieveAssembler.java | 82 +++++++++ .../AbstractExtendSaveAssembler.java | 59 +++++++ .../AbstractMessageMapperAssembler.java | 49 ++++++ .../AbstractRetrieveDefaultAssembler.java | 150 +++++++++++++++++ 10 files changed, 879 insertions(+) create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractAssemblerManager.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractChangeMapperAssembler.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractDataMapperAssembler.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractExtendDeleteAssembler.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractExtendModifyAssembler.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractExtendQueryAssembler.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractExtendRetrieveAssembler.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractExtendSaveAssembler.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractMessageMapperAssembler.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractRetrieveDefaultAssembler.java diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractAssemblerManager.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractAssemblerManager.java new file mode 100644 index 0000000..cbf1d06 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractAssemblerManager.java @@ -0,0 +1,25 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.assembler; + +import com.inspur.edp.bff.api.manager.assembler.IAssemblerManager; +import com.inspur.edp.bff.api.manager.assembler.IMessageMapperAssembler; + +public abstract class AbstractAssemblerManager implements IAssemblerManager { + + public IMessageMapperAssembler getMessageMapperAssembler(){return null;} +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractChangeMapperAssembler.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractChangeMapperAssembler.java new file mode 100644 index 0000000..fef8004 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractChangeMapperAssembler.java @@ -0,0 +1,66 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.assembler; + +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.assembler.IChangeMapperAssembler; +import com.inspur.edp.bff.api.manager.context.ChangeMapperContext; +import com.inspur.edp.bff.spi.action.changemapping.ChangeMappingAction; +import com.inspur.edp.bff.spi.action.changemapping.ChangeReversalMappingAction; +import com.inspur.edp.bff.spi.action.changemapping.DefaultChangeMapAction; +import com.inspur.edp.bff.spi.action.changemapping.DefaultChangeReversalAction; + +import java.util.ArrayList; + +public abstract class AbstractChangeMapperAssembler implements IChangeMapperAssembler { + + protected abstract ArrayList getChangeMappingActions(ChangeMapperContext mappingContext); + protected abstract ArrayList getChangeReversalMappingActions(ChangeMapperContext mappingContext); + + public final void doChangeMappingFromVo(IFSManagerContext context, ChangeMapperContext mappingContext) + { + ArrayList actions = getChangeReversalMappingActions(mappingContext); + if (actions == null || actions.size() < 1) + { + actions = new ArrayList(); + DefaultChangeReversalAction action = new DefaultChangeReversalAction(mappingContext); + actions.add(action); + } + + for (ChangeReversalMappingAction action : actions) + { + action.deal(context); + } + } + + public final void doChangeMapping2Vo(IFSManagerContext context, ChangeMapperContext mappingContext) + { + ArrayList actions = getChangeMappingActions(mappingContext); + if (actions == null || actions.size() < 1) + { + actions = new ArrayList(); + DefaultChangeMapAction action = new DefaultChangeMapAction(mappingContext); + actions.add(action); + } + + for (ChangeMappingAction action : actions) + { + action.deal(context); + } + } + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractDataMapperAssembler.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractDataMapperAssembler.java new file mode 100644 index 0000000..ecfb153 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractDataMapperAssembler.java @@ -0,0 +1,79 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.assembler; + +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.assembler.IDataMapperAssembler; +import com.inspur.edp.bff.api.manager.context.DataMapperContext; +import com.inspur.edp.bff.spi.action.datamapping.DataMappingAction; +import com.inspur.edp.bff.spi.action.datamapping.DataReversalMappingAction; +import com.inspur.edp.bff.spi.action.datamapping.DefaultDataMappingAction; +import com.inspur.edp.bff.spi.action.datamapping.DefaultDataReversalAction; +import com.inspur.edp.bff.spi.event.datamapping.BffDataMappingEventBroker; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.ArrayList; + +public abstract class AbstractDataMapperAssembler implements IDataMapperAssembler { + + protected abstract ArrayList getDataMappingActions(DataMapperContext mappingContext); + protected abstract ArrayList getDataReversalMappingActions(DataMapperContext mappingContext); + public final void doDataMappingFromVo(IFSManagerContext context, DataMapperContext mappingContext) + { + ArrayList actions = getDataReversalMappingActions(mappingContext); + if (actions == null || actions.size() < 1) + { + actions = new ArrayList(); + DefaultDataReversalAction detaultAction = new DefaultDataReversalAction(mappingContext); + actions.add(detaultAction); + } + + for (DataReversalMappingAction action : actions) + { + action.deal(context); + } + } + + public final ArrayList doDataMapping2Vo(IFSManagerContext context, DataMapperContext mappingContext) + { + ArrayList actions = getDataMappingActions(mappingContext); + if (actions == null || actions.size() < 1) + { + actions = new ArrayList(); + DefaultDataMappingAction detaultAction = new DefaultDataMappingAction(mappingContext); + actions.add(detaultAction); + } + try { + BffDataMappingEventBroker.fireBeforeTotalDataMapping(mappingContext, context); + for (DataMappingAction action : actions) { + try { + BffDataMappingEventBroker.fireBeforeDataMapping(action, mappingContext, context); + action.deal(context); + BffDataMappingEventBroker.fireAfterDataMapping(mappingContext, context); + } catch (Exception e) { + BffDataMappingEventBroker.fireQueryUnnormalStop(e); + throw new RuntimeException(e); + } + } + BffDataMappingEventBroker.fireAfterTotalDataMapping(mappingContext, context, actions.size()); + } catch (Exception e) { + BffDataMappingEventBroker.fireQueryUnnormalStop(e); + throw new RuntimeException(e); + } + return mappingContext.getTargetResult(); + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractExtendDeleteAssembler.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractExtendDeleteAssembler.java new file mode 100644 index 0000000..895ce23 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractExtendDeleteAssembler.java @@ -0,0 +1,134 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.assembler; + +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.assembler.IExtendDeleteAssembler; +import com.inspur.edp.bff.api.manager.context.DeleteContext; +import com.inspur.edp.bff.spi.action.delete.AbstractDeleteAction; +import com.inspur.edp.bff.spi.action.delete.AfterDeleteAction; +import com.inspur.edp.bff.spi.action.delete.BeforeDeleteAction; +import com.inspur.edp.bff.spi.action.delete.DefaultDeleteAction; +import com.inspur.edp.bff.spi.action.multidelete.AbstractMultiDeleteAction; +import com.inspur.edp.bff.spi.action.multidelete.AfterMultiDeleteAction; +import com.inspur.edp.bff.spi.action.multidelete.BeforeMultiDeleteAction; +import com.inspur.edp.bff.spi.action.multidelete.DefaultMultiDeleteAction; + +import java.util.ArrayList; + +public abstract class AbstractExtendDeleteAssembler implements IExtendDeleteAssembler { + + + protected abstract ArrayList getBeforeDeleteActions(DeleteContext delContext); + protected abstract ArrayList getDeleteActions(DeleteContext delContext); + protected abstract ArrayList getAfterDeleteActions(DeleteContext delContext); + + protected ArrayList getMultiDeleteActions(DeleteContext deleteContext) { return new ArrayList(); } + + + + protected ArrayList getBeforeMultiDeleteActions(DeleteContext deleteContext) { return new ArrayList(); } + + + + protected ArrayList getAfterMultiDeleteActions(DeleteContext deleteContext) { return new ArrayList(); } + + + public final void doBeforeMultiDelete(IFSManagerContext context, DeleteContext delContext) { + ArrayList actions = getBeforeMultiDeleteActions(delContext); + if (actions == null || actions.size() < 1) { + return; + } + + + for (BeforeMultiDeleteAction action : actions) + { + action.deal(context); + } + } + + + public final void doMultiDelete(IFSManagerContext context, DeleteContext delContext) { + ArrayList actions = getMultiDeleteActions(delContext); + if (actions == null || actions.size() < 1) { + + actions = new ArrayList(); + DefaultMultiDeleteAction detaultAction = new DefaultMultiDeleteAction(delContext); + actions.add(detaultAction); + } + + for (AbstractMultiDeleteAction action : actions) + { + action.deal(context); + } + } + + + public final void doAfterMultiDelete(IFSManagerContext context, DeleteContext delContext) { + ArrayList actions = getAfterMultiDeleteActions(delContext); + if (actions == null || actions.size() < 1) { + return; + } + + for (AfterMultiDeleteAction action : actions) + { + action.deal(context); + } + } + public final void doBeforeDelete(IFSManagerContext context, DeleteContext delContext) + { + ArrayList actions = getBeforeDeleteActions(delContext); + if (actions == null || actions.size() < 1) + { + return; + } + + for (BeforeDeleteAction action : actions) + { + action.deal(context); + } + } + + public final void doDelete(IFSManagerContext context, DeleteContext delContext) + { + ArrayList actions = getDeleteActions(delContext); + if (actions == null || actions.size() < 1) + { + actions = new ArrayList(); + DefaultDeleteAction detaultAction = new DefaultDeleteAction(delContext); + actions.add(detaultAction); + } + + for (AbstractDeleteAction action : actions) + { + action.deal(context); + } + } + + public final void doAfterDelete(IFSManagerContext context, DeleteContext delContext) + { + ArrayList actions = getAfterDeleteActions(delContext); + if (actions == null || actions.size() < 1) + { + return; + } + for (AfterDeleteAction action : actions) + { + action.deal(context); + } + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractExtendModifyAssembler.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractExtendModifyAssembler.java new file mode 100644 index 0000000..62b150d --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractExtendModifyAssembler.java @@ -0,0 +1,80 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.assembler; + +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.assembler.IExtendModifyAssembler; +import com.inspur.edp.bff.api.manager.context.ModifyContext; +import com.inspur.edp.bff.spi.action.modify.AbstractModifyAction; +import com.inspur.edp.bff.spi.action.modify.AfterModifyAction; +import com.inspur.edp.bff.spi.action.modify.BeforeModifyAction; +import com.inspur.edp.bff.spi.action.modify.DefaultModifyAction; + +import java.util.ArrayList; + +public abstract class AbstractExtendModifyAssembler implements IExtendModifyAssembler { + + protected abstract ArrayList getBeforeModifyActions(ModifyContext modifyContext); + protected abstract ArrayList getModifyActions(ModifyContext modifyContext); + protected abstract ArrayList getAfterModifyActions(ModifyContext modifyContext); + + + public final void doBeforeModify(IFSManagerContext context, ModifyContext modifyContext) + { + ArrayList actions = getBeforeModifyActions(modifyContext); + if (actions == null || actions.size() < 1) + { + return; + } + + for (BeforeModifyAction action : actions) + { + action.deal(context); + } + } + + public final void doModify(IFSManagerContext context, ModifyContext modifyContext) + { + ArrayList actions = getModifyActions(modifyContext); + if (actions == null || actions.size() < 1) + { + actions = new ArrayList(); + DefaultModifyAction action = new DefaultModifyAction(modifyContext); + actions.add(action); + } + + for (AbstractModifyAction action : actions) + { + action.deal(context); + } + } + + public final void doAfterModify(IFSManagerContext context, ModifyContext modifyContext) + { + ArrayList actions = getAfterModifyActions(modifyContext); + if (actions == null || actions.size() < 1) + { + return; + } + + for (AfterModifyAction action : actions) + { + action.deal(context); + } + } + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractExtendQueryAssembler.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractExtendQueryAssembler.java new file mode 100644 index 0000000..ec69838 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractExtendQueryAssembler.java @@ -0,0 +1,155 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.assembler; + +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.assembler.IExtendQueryAssembler; +import com.inspur.edp.bff.api.manager.context.QueryContext; +import com.inspur.edp.bff.spi.action.query.AbstractQueryAction; +import com.inspur.edp.bff.spi.action.query.AfterQueryAction; +import com.inspur.edp.bff.spi.action.query.BeforeQueryAction; +import com.inspur.edp.bff.spi.action.query.DefaultQueryAction; +import com.inspur.edp.bff.spi.event.query.BffQueryEventBroker; +import com.inspur.edp.cef.entity.entity.IEntityData; +import com.inspur.edp.debugtool.api.Tracer; + +import java.util.ArrayList; +import java.util.HashMap; + +public abstract class AbstractExtendQueryAssembler implements IExtendQueryAssembler { + + protected abstract ArrayList getBeforeQueryActions(QueryContext queryContext); + + protected abstract ArrayList getQueryActions(QueryContext queryContext); + + protected abstract ArrayList getAfterQueryActions(QueryContext queryContext); + + public final void doBeforeQuery(IFSManagerContext context, QueryContext queryContext) { + ArrayList actions = getBeforeQueryActions(queryContext); + if (actions == null || actions.size() < 1) { + try { + BffQueryEventBroker.firebeforeTotalCXQAssembler(queryContext); + BffQueryEventBroker.fireafterTotalCXQAssembler(context, queryContext, 0); + }catch (Exception e) { + BffQueryEventBroker.fireQueryUnnormalStop(e); + } + return; + } + try { + BffQueryEventBroker.firebeforeTotalCXQAssembler(queryContext); + for (BeforeQueryAction action : actions) { + try { + BffQueryEventBroker.fireBeforeCXQAssembler(action, queryContext, context); + action.deal(context); + BffQueryEventBroker.fireAfterCXQAssembler(context, queryContext); + }catch (Exception e) { + BffQueryEventBroker.fireQueryUnnormalStop(e); + throw new RuntimeException(e); + } + + } + BffQueryEventBroker.fireafterTotalCXQAssembler(context, queryContext,actions.size()); + } catch (Exception e) { + BffQueryEventBroker.fireQueryUnnormalStop(e); + throw new RuntimeException(e); + } + + } + + public final HashMap> doQuery(IFSManagerContext context, QueryContext queryContext) { + HashMap> result = new HashMap>(); + ArrayList actions = getQueryActions(queryContext); + if (actions == null || actions.size() < 1) { + //兼容原有VO没有设置内置Query,但设置了BeforeQuery或AfterQuery + actions = new ArrayList(); + DefaultQueryAction detaultAction = new DefaultQueryAction(queryContext); + actions.add(detaultAction); + } + try { + BffQueryEventBroker.firebeforeTotalCoreQuery(queryContext); + for (AbstractQueryAction action : actions) { + try { + BffQueryEventBroker.firebeforeCoreQuery(action, queryContext, context); + HashMap> queryData = action.deal(context); + mergeQueryData(result, queryData); + BffQueryEventBroker.fireafterCoreQuery(context, result, queryContext); + } catch (Exception e) { + BffQueryEventBroker.fireQueryUnnormalStop(e); + throw new RuntimeException(e); + } + } + BffQueryEventBroker.fireafterTotalCoreQuery(context, result, queryContext, actions.size()); + } catch (Exception e) { + BffQueryEventBroker.fireQueryUnnormalStop(e); + throw new RuntimeException(e); + } + return result; + } + + private void mergeQueryData(HashMap> result, HashMap> queryData) { + if (queryData == null || queryData.size() < 1) { + return; + } + for (String node : queryData.keySet()) { + ArrayList data = queryData.get(node); + if (result.containsKey(node)) { + result.get(node).addAll(data); + } else { + result.put(node, data); + } + } + } + + public final void doAfterQuery(IFSManagerContext context, QueryContext queryContext) { + ArrayList actions = getAfterQueryActions(queryContext); + if (actions == null || actions.size() < 1) { + try { + BffQueryEventBroker.firebeforeTotalCXHAssembler(queryContext, context); + BffQueryEventBroker.fireafterTotalCXHAssembler(queryContext, context, 0); + } catch (Exception e) { + BffQueryEventBroker.fireQueryUnnormalStop(e); + } + return; + } + try { + BffQueryEventBroker.firebeforeTotalCXHAssembler(queryContext, context); + for (AfterQueryAction action : actions) { + try { + BffQueryEventBroker.firebeforeCXHAssembler(action, queryContext, context); + action.deal(context); + BffQueryEventBroker.fireafterCXHAssembler(queryContext, context); + } catch (Exception e) { + BffQueryEventBroker.fireQueryUnnormalStop(e); + throw new RuntimeException(e); + } + } + BffQueryEventBroker.fireafterTotalCXHAssembler(queryContext, context, actions.size()); + } catch (Exception e) { + BffQueryEventBroker.fireQueryUnnormalStop(e); + throw new RuntimeException(e); + } + } + + public final ArrayList cloneResultList(ArrayList result){ + ArrayList newresult = new ArrayList(); + for(int i=0;i getBeforeRetrieveActions(RetrieveContext retrieveContext); + protected abstract ArrayList getRetrieveActions(RetrieveContext retrieveContext); + protected abstract ArrayList getAfterRetrieveActions(RetrieveContext retrieveContext); + + public final void doBeforeRetrieve(IFSManagerContext context, RetrieveContext retrieveContext) + { + ArrayList actions = getBeforeRetrieveActions(retrieveContext); + if (actions == null || actions.size() < 1) + { + return; + } + + for (BeforeRetrieveAction action : actions) + { + action.deal(context); + } + } + + public final void doRetrieve(IFSManagerContext context, RetrieveContext retrieveContext) + { + //Dictionary> result = new Dictionary>(); + ArrayList actions = getRetrieveActions(retrieveContext); + if (actions == null || actions.size() < 1) + { + //兼容原有VO没有设置内置Retrieve,但设置了BeforeRetrieve或AfterRetrieve + actions = new ArrayList(); + DefaultRetrieveAction detaultAction = new DefaultRetrieveAction(retrieveContext); + actions.add(detaultAction); + } + + for (AbstractRetrieveAction action : actions) + { + action.deal(context); + //MergeQueryData(result, retrieveContext.RetrieveData); + } + + //return result; + } + + public final void doAfterRetrieve(IFSManagerContext context, RetrieveContext retrieveContext) + { + ArrayList actions = getAfterRetrieveActions(retrieveContext); + if (actions == null || actions.size() < 1) + { + return; + } + for (AfterRetrieveAction action : actions) + { + action.deal(context); + } + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractExtendSaveAssembler.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractExtendSaveAssembler.java new file mode 100644 index 0000000..f9ef380 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractExtendSaveAssembler.java @@ -0,0 +1,59 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.assembler; + +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.assembler.IExtendSaveAssembler; +import com.inspur.edp.bff.api.manager.context.SaveContext; +import com.inspur.edp.bff.spi.action.save.AfterSaveAction; +import com.inspur.edp.bff.spi.action.save.BeforeSaveAction; + +import java.util.ArrayList; + +public abstract class AbstractExtendSaveAssembler implements IExtendSaveAssembler { + + protected abstract ArrayList getBeforeSaveActions(SaveContext saveContext); + protected abstract ArrayList getAfterSaveActions(SaveContext saveContext); + + public final void doBeforeSave(IFSManagerContext context, SaveContext saveContext) + { + ArrayList actions = getBeforeSaveActions(saveContext); + if (actions == null || actions.size() < 1) + { + return; + } + + for (BeforeSaveAction action : actions) + { + action.deal(context); + } + } + + public final void doAfterSave(IFSManagerContext context, SaveContext saveContext) + { + ArrayList actions = getAfterSaveActions(saveContext); + if (actions == null || actions.size() < 1) + { + return; + } + + for (AfterSaveAction action : actions) + { + action.deal(context); + } + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractMessageMapperAssembler.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractMessageMapperAssembler.java new file mode 100644 index 0000000..55f0994 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractMessageMapperAssembler.java @@ -0,0 +1,49 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.assembler; + +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.assembler.IMessageMapperAssembler; +import com.inspur.edp.bff.api.manager.context.MessageMapperContext; +import com.inspur.edp.bff.spi.action.changemapping.DefaultMessageMapAction; +import com.inspur.edp.bff.spi.action.changemapping.MessageMappingAction; +import com.inspur.edp.cef.api.message.IBizMessage; +import com.inspur.edp.cef.api.message.MessageLevel; +import java.util.ArrayList; +import java.util.List; + +public abstract class AbstractMessageMapperAssembler implements IMessageMapperAssembler { + + protected abstract List getMessageMappingActions( + MessageMapperContext mappingContext); + + @Override + public final void doMessageMapping2Vo(IFSManagerContext context, + MessageMapperContext mappingContext) { + List actions = getMessageMappingActions(mappingContext); + if (actions == null || actions.isEmpty()) { + actions = new ArrayList(); + DefaultMessageMapAction action = new DefaultMessageMapAction(mappingContext); + actions.add(action); + } + + for (MessageMappingAction action : actions) { + action.deal(context); + } + } + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractRetrieveDefaultAssembler.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractRetrieveDefaultAssembler.java new file mode 100644 index 0000000..7905223 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/assembler/AbstractRetrieveDefaultAssembler.java @@ -0,0 +1,150 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.assembler; + +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.assembler.IExtendRetrieveDefaultAssembler; +import com.inspur.edp.bff.api.manager.context.RetrieveDefaultContext; +import com.inspur.edp.bff.spi.action.retrievedefault.AbstractRetrieveDefaultAction; +import com.inspur.edp.bff.spi.action.retrievedefault.AfterRetrieveDefaultAction; +import com.inspur.edp.bff.spi.action.retrievedefault.BeforeRetrieveDefaultAction; +import com.inspur.edp.bff.spi.action.retrievedefault.DefaultRetrieveDefaultAction; + +import com.inspur.edp.bff.spi.event.retrievedefault.BffRetrieveDefaultEventBroker; +import java.util.ArrayList; + +public abstract class AbstractRetrieveDefaultAssembler implements IExtendRetrieveDefaultAssembler { + + protected abstract ArrayList getBeforeRetrieveDefaultActions(RetrieveDefaultContext createContext); + protected abstract ArrayList getRetrieveDefaultActions(RetrieveDefaultContext createContext); + protected abstract ArrayList getAfterRetrieveDefaultActions(RetrieveDefaultContext createContext); + + public final void doBeforeRetrieveDefault(IFSManagerContext context, RetrieveDefaultContext createContext) + { + ArrayList actions = getBeforeRetrieveDefaultActions(createContext); + if (actions == null || actions.size() < 1) + { + dealNoneBeforeAction(actions,context); + return; + } + try { + BffRetrieveDefaultEventBroker.fireB4ExecuteRetrieveDefaultActions(context.getBffManager(),actions); + dealBeforeRetrieveDefault(actions,context,createContext); + BffRetrieveDefaultEventBroker.fireAfterExecuteRetrieveDefaultActions(context.getBffManager(),actions); + }catch (Exception e){ + BffRetrieveDefaultEventBroker.fireExceptionStop(e); + throw new RuntimeException(e); + } + + } + private final void dealNoneBeforeAction(ArrayList actions,IFSManagerContext context){ + try { + BffRetrieveDefaultEventBroker.fireB4ExecuteRetrieveDefaultActions(context.getBffManager(),actions); + BffRetrieveDefaultEventBroker.fireAfterExecuteRetrieveDefaultActions(context.getBffManager(),actions); + }catch (Exception e){ + BffRetrieveDefaultEventBroker.fireExceptionStop(e); + throw new RuntimeException(e); + } + } + private final void dealBeforeRetrieveDefault(ArrayList actions,IFSManagerContext context, RetrieveDefaultContext createContext){ + for (BeforeRetrieveDefaultAction action : actions) + { + try { + BffRetrieveDefaultEventBroker.fireB4BeforeRetrieveDefaultAction(context.getBffManager(),action,createContext); + action.deal(context); + BffRetrieveDefaultEventBroker.fireAfterBeforeRetrieveDefaultAction(context.getBffManager(),createContext); + }catch (Exception e){ + BffRetrieveDefaultEventBroker.fireExceptionStop(e); + throw new RuntimeException(e); + } + + } + } + public final void doRetrieveDefault(IFSManagerContext context, RetrieveDefaultContext createContext) + { + ArrayList actions = getRetrieveDefaultActions(createContext); + if (actions == null || actions.size() < 1) + { + //兼容原有VO没有设置内置Retrieve,但设置了BeforeRetrieve或AfterRetrieve + actions = new ArrayList(); + DefaultRetrieveDefaultAction detaultAction = new DefaultRetrieveDefaultAction(createContext); + actions.add(detaultAction); + } + + try { + BffRetrieveDefaultEventBroker.fireB4ExecuteAbstractRetrieveDefaultActions(context.getBffManager(),actions); + dealRetrieveDefault( actions, context, createContext); + BffRetrieveDefaultEventBroker.fireAfterExecuteAbstractRetrieveDefaultActions(context.getBffManager(),actions); + }catch (Exception e){ + BffRetrieveDefaultEventBroker.fireExceptionStop(e); + throw new RuntimeException(e); + } + + } + private final void dealRetrieveDefault(ArrayList actions, IFSManagerContext context, RetrieveDefaultContext createContext){ + for (AbstractRetrieveDefaultAction action : actions) { + try { + BffRetrieveDefaultEventBroker.fireB4AbstractRetrieveDefaultAction(context.getBffManager(),action,createContext); + action.deal(context); + BffRetrieveDefaultEventBroker.fireAfterAbstractRetrieveDefaultAction(context.getBffManager(),createContext); + }catch (Exception e){ + BffRetrieveDefaultEventBroker.fireExceptionStop(e); + throw new RuntimeException(e); + } + } + } + + public final void doAfterRetrieveDefault(IFSManagerContext context, RetrieveDefaultContext createContext) + { + ArrayList actions = getAfterRetrieveDefaultActions(createContext); + if (actions == null || actions.size() < 1) + { + dealNoneAfterAction(actions,context); + return; + } + try { + BffRetrieveDefaultEventBroker.fireB4ExecuteAfterRetrieveDefaultActions(context.getBffManager(),actions); + dealAfterRetrieveDefault(actions,context,createContext); + BffRetrieveDefaultEventBroker.fireAfterExecuteAfterRetrieveDefaultActions(context.getBffManager(),actions); + }catch (Exception e){ + BffRetrieveDefaultEventBroker.fireExceptionStop(e); + throw new RuntimeException(e); + } + + } + private final void dealNoneAfterAction(ArrayList actions,IFSManagerContext context){ + try { + BffRetrieveDefaultEventBroker.fireB4ExecuteAfterRetrieveDefaultActions(context.getBffManager(),actions); + BffRetrieveDefaultEventBroker.fireAfterExecuteAfterRetrieveDefaultActions(context.getBffManager(),actions); + }catch (Exception e){ + BffRetrieveDefaultEventBroker.fireExceptionStop(e); + throw new RuntimeException(e); + } + } + private final void dealAfterRetrieveDefault(ArrayList actions,IFSManagerContext context, RetrieveDefaultContext createContext){ + for (AfterRetrieveDefaultAction action : actions) { + try { + BffRetrieveDefaultEventBroker.fireB4AfterRetrieveDefaultAction(context.getBffManager(),action,createContext); + action.deal(context); + BffRetrieveDefaultEventBroker.fireAfterAfterRetrieveDefaultAction(context.getBffManager(),createContext); + }catch (Exception e){ + BffRetrieveDefaultEventBroker.fireExceptionStop(e); + throw new RuntimeException(e); + } + } + } +} -- Gitee From 83f18053fd147c799df85f60ccc91e1767fca1b1 Mon Sep 17 00:00:00 2001 From: Jakeem Date: Fri, 28 Oct 2022 21:01:22 +0800 Subject: [PATCH 56/81] =?UTF-8?q?1.=20=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E5=92=8C=E5=AE=9E=E4=BD=93=E7=9A=84=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E7=B1=BB=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bff/spi/builtin/BffEntityResInfoImpl.java | 270 ++++++++++++++++++ .../bff/spi/builtin/BffModelResInfoImpl.java | 30 ++ .../edp/bff/spi/builtin/BffPropertyInfo.java | 115 ++++++++ 3 files changed, 415 insertions(+) create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/builtin/BffEntityResInfoImpl.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/builtin/BffModelResInfoImpl.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/builtin/BffPropertyInfo.java diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/builtin/BffEntityResInfoImpl.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/builtin/BffEntityResInfoImpl.java new file mode 100644 index 0000000..9852ecb --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/builtin/BffEntityResInfoImpl.java @@ -0,0 +1,270 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.builtin; + +import com.fasterxml.jackson.databind.JsonSerializer; +import com.inspur.edp.bff.spi.BffEntitySerConvertor; +import com.inspur.edp.cef.api.repository.GspDbDataType; +import com.inspur.edp.cef.entity.entity.FieldType; +import com.inspur.edp.cef.spi.entity.PropertyDefaultValue; +import com.inspur.edp.cef.spi.entity.info.EnumValueInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.AssocationPropertyInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.BasePropertyInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.ComplexUdtPropertyInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.DataTypePropertyInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.EnumPropertyInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.ObjectType; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.SimpleAssoUdtPropertyInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.SimpleEnumUdtPropertyInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.SimpleUdtPropertyInfo; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefEntityResInfoImpl; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefModelResInfoImpl; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefValueObjModelResInfo; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefValueObjResInfo; +import com.inspur.edp.udt.api.Manager.IUdtManager; +import com.inspur.edp.udt.api.UdtManagerUtils; +import java.lang.reflect.InvocationTargetException; + +public abstract class BffEntityResInfoImpl extends CefEntityResInfoImpl { + private BffEntitySerConvertor bffEntitySerConvertor; + + @Override + public JsonSerializer getEntitySerConvertor() { + if (bffEntitySerConvertor == null) { + bffEntitySerConvertor = new BffEntitySerConvertor(getEntityTypeInfo().getEntityCode(), isRoot(), getConfigId(), this); + } + return bffEntitySerConvertor; + } + public BffEntityResInfoImpl(String entityCode, String displayValueKey, CefModelResInfoImpl modelResInfo, String entityId) { + super(entityCode, displayValueKey, modelResInfo, entityId); + } + + + protected DataTypePropertyInfo addStringPropertyInfo(String propertyName,boolean required,boolean enableRtrim,int length) { + return addStringPropertyInfo(propertyName, getFieldPropertyDisplayValue(propertyName), + required, enableRtrim, length, null, false, false,propertyName); + } + protected DataTypePropertyInfo addStringPropertyInfo(String propertyName,String displayValueKey,boolean required,boolean enableRtrim,int length, + PropertyDefaultValue defaultValue,boolean defaultNull,boolean isMulti,String beLabelId) { + return addBffPropertyInfo(propertyName,displayValueKey,required,enableRtrim,length,0, + com.inspur.edp.cef.entity.entity.FieldType.String,ObjectType.Normal,null,defaultValue,isMulti,false,beLabelId,false); + } + + private BffPropertyInfo addBffPropertyInfo(String propertyName, String displayValueKey, boolean required, boolean enableRtrim, int length, int precision, FieldType fieldType, ObjectType objectType, BasePropertyInfo objectInfo, PropertyDefaultValue defaultValue, boolean isMulti, boolean bigNumber,String beLabelId,boolean enableStdTimeFormat) + { + BffPropertyInfo bffPropertyInfo= new BffPropertyInfo(propertyName,displayValueKey,required,enableRtrim,length,precision,fieldType,objectType,objectInfo,defaultValue,isMulti,bigNumber,beLabelId,enableStdTimeFormat); + addPropertyInfo(bffPropertyInfo); + return bffPropertyInfo; + } + + protected DataTypePropertyInfo addTextPropertyInfo(String propertyName,boolean required,boolean enableRtrim) { + return addTextPropertyInfo(propertyName, getFieldPropertyDisplayValue(propertyName), + required, + enableRtrim, null, false, false,propertyName); + } + + protected DataTypePropertyInfo addTextPropertyInfo(String propertyName,String displayValueKey,boolean requried,boolean enableRtrim,PropertyDefaultValue defaultValue,boolean isDefaultNull, + boolean isMulti,String beLabelId) { + return addBffPropertyInfo(propertyName,displayValueKey,requried,enableRtrim,0,0, + FieldType.Text,ObjectType.Normal,null,defaultValue,isMulti,false,beLabelId,false); + } + + protected DataTypePropertyInfo addDatePropertyInfo(String propertyName,boolean required) { + return addDatePropertyInfo(propertyName, getFieldPropertyDisplayValue(propertyName), + required, null,false,propertyName); + } + + protected DataTypePropertyInfo addDatePropertyInfo(String propertyName,String displayValueKey,boolean required,PropertyDefaultValue defaultValue + ,boolean defaultNull,String beLabelID) { + return addBffPropertyInfo(propertyName,displayValueKey,required,false,0,0, + FieldType.Date,ObjectType.Normal,null,defaultValue,false,false,beLabelID,false); + } + + protected DataTypePropertyInfo addDateTimePropertyInfo(String propertyName,boolean required,boolean enableStdTime) { + return addDateTimePropertyInfo(propertyName, getFieldPropertyDisplayValue(propertyName), + required, null, false,propertyName,enableStdTime); + } + + protected DataTypePropertyInfo addDateTimePropertyInfo(String propertyName,String displayValueKey,boolean required,PropertyDefaultValue defaultValue, + boolean defaultNull,String beLabelID,boolean enableStdTime) { + return addBffPropertyInfo(propertyName,displayValueKey,required,false,0,0, + FieldType.DateTime,ObjectType.Normal,null,defaultValue,false,false,beLabelID,enableStdTime); + } + + protected DataTypePropertyInfo addIntPropertyInfo(String propertyName,boolean required) { + return addIntPropertyInfo(propertyName, getFieldPropertyDisplayValue(propertyName), + required, null, false,propertyName); + } + + protected DataTypePropertyInfo addIntPropertyInfo(String propertyName,String displayValueKey,boolean required,PropertyDefaultValue defaultValue, + boolean defaultNull,String beLabelID) { + return addBffPropertyInfo(propertyName,displayValueKey,required,false,0,0, + FieldType.Integer,ObjectType.Normal,null,defaultValue,false,false,beLabelID,false); + } + + protected DataTypePropertyInfo addDecimalPropertyInfo(String propertyName,boolean requried,int length,int pricision) { + return addDecimalPropertyInfo(propertyName, getFieldPropertyDisplayValue(propertyName), + requried, length, pricision, null, false,propertyName,false); + } + + protected DataTypePropertyInfo addDecimalPropertyInfo(String propertyName,String propertyDispalyKey,boolean requried,int length,int pricision, + PropertyDefaultValue defaultValue,boolean defaultNull,String beLabelID,boolean isBigNumber) { + return addBffPropertyInfo(propertyName,propertyDispalyKey,requried,false,0,0, + FieldType.Decimal,ObjectType.Normal,null,defaultValue,false,isBigNumber,beLabelID,false); + } + + protected DataTypePropertyInfo addBooleanPropertyInfo(String propertyName,boolean requried) { + return addBooleanPropertyInfo(propertyName, getFieldPropertyDisplayValue(propertyName),requried, null, false,propertyName); + } + + protected DataTypePropertyInfo addBooleanPropertyInfo(String propertyName,String propertyDisplayValue,boolean required,PropertyDefaultValue defaultValue, + boolean defaultNull,String beLabeID) { + return addBffPropertyInfo(propertyName,propertyDisplayValue,required,false,0,0, + FieldType.Boolean,ObjectType.Normal,null,defaultValue,false,false,beLabeID,false); + } + + protected DataTypePropertyInfo addBytesPropertyInfo(String propertyName,boolean required) { + return addBytesPropertyInfo(propertyName, getFieldPropertyDisplayValue(propertyName), required, null,false,propertyName); + } + + protected DataTypePropertyInfo addBytesPropertyInfo(String propertyName,String displayValueKey,boolean required,PropertyDefaultValue defaultValue, + boolean defaultNull,String beLabeID) { + return addBffPropertyInfo(propertyName,displayValueKey,required,false,0,0, + FieldType.Binary,ObjectType.Normal,null,defaultValue,false,false,beLabeID,false); + } + protected final DataTypePropertyInfo addAssoUdtPropertyInfo(String propertyName, boolean requried, + boolean enableRtrim, SimpleAssoUdtPropertyInfo associationInfo) { + return addAssoUdtPropertyInfo(propertyName, getFieldPropertyDisplayValue(propertyName), + requried, enableRtrim, 36, false,associationInfo,propertyName); + } + + protected final DataTypePropertyInfo addAssoUdtPropertyInfo(String propertyName, boolean requried, + boolean enableRtrim, SimpleAssoUdtPropertyInfo associationInfo,boolean enableStdTimeFormat) { + return addAssoUdtPropertyInfo(propertyName, getFieldPropertyDisplayValue(propertyName), + requried, enableRtrim, 36, false,associationInfo,propertyName,enableStdTimeFormat); + } + + protected String getFieldPropertyDisplayValue(String propertyName) { + return this.getDisplayPrefix() + "." + propertyName + "." + "Name"; + } + + protected final DataTypePropertyInfo addAssoUdtPropertyInfo(String propertyName, + String propertyDisplayKey, boolean required, boolean enableRtrim, int length, + boolean isDefaultNull, SimpleAssoUdtPropertyInfo associationInfo,String beLabelID) { + return addBffPropertyInfo(propertyName,propertyDisplayKey,required,enableRtrim,length,0,FieldType.Udt,ObjectType.UDT,associationInfo,null,false,false,beLabelID,false); + } + + protected final DataTypePropertyInfo addAssoUdtPropertyInfo(String propertyName, + String propertyDisplayKey, boolean required, boolean enableRtrim, int length, + boolean isDefaultNull, SimpleAssoUdtPropertyInfo associationInfo,String beLabelID,boolean enableStdTimeFormat) { + return addBffPropertyInfo(propertyName,propertyDisplayKey,required,enableRtrim,length,0,FieldType.Udt,ObjectType.UDT,associationInfo,null,false,false,beLabelID,enableStdTimeFormat); + } + + protected final DataTypePropertyInfo addComplexUdtPropertyInfo(String propertyName, + ComplexUdtPropertyInfo udtPropertyInfo) + { + return addComplexUdtPropertyInfo(propertyName,getFieldPropertyDisplayValue(propertyName),udtPropertyInfo,propertyName); + } + + protected final DataTypePropertyInfo addComplexUdtPropertyInfo(String propertyName,String propertyDisplayValueKey, + ComplexUdtPropertyInfo udtPropertyInfo,String beLabelID) { + return addBffPropertyInfo(propertyName, propertyDisplayValueKey, false, false, 0, 0, + FieldType.Udt, ObjectType.UDT, udtPropertyInfo, null, false, false, beLabelID, udtPropertyInfo.getEnableStdTimeFormat()); + } + + protected final DataTypePropertyInfo addAssociationProperyInfo(String propertyName, boolean required, + boolean enableRtrim, + AssocationPropertyInfo associationInfo) { + return addAssociationProperyInfo(propertyName, getFieldPropertyDisplayValue(propertyName), + required, enableRtrim, 36, false, associationInfo, + propertyName); + } + + protected final DataTypePropertyInfo addAssociationProperyInfo(String propertyName, boolean required, + boolean enableRtrim, + AssocationPropertyInfo associationInfo,boolean enableStdTimeFormat) + { + return addAssociationProperyInfo(propertyName, getFieldPropertyDisplayValue(propertyName), + required, enableRtrim, 36, false, associationInfo, + propertyName,enableStdTimeFormat); + } + + protected final DataTypePropertyInfo addAssociationProperyInfo(String propertyName, + String propertyDisplayKey, boolean required, boolean enableRtrim, int length, + boolean isDefaultNull, AssocationPropertyInfo associationInfo,String beLabelID) { + return addBffPropertyInfo(propertyName,propertyDisplayKey,required,enableRtrim,length,0,FieldType.String,ObjectType.Association,associationInfo,null,false,false,beLabelID,false); + } + protected final DataTypePropertyInfo addAssociationProperyInfo(String propertyName, + String propertyDisplayKey, boolean required, boolean enableRtrim, int length, + boolean isDefaultNull, AssocationPropertyInfo associationInfo,String beLabelID,boolean enableStdTimeFormat) + { + return addBffPropertyInfo(propertyName,propertyDisplayKey,required,enableRtrim,length,0,FieldType.String,ObjectType.Association,associationInfo,null,false,false,beLabelID,enableStdTimeFormat); + } + protected final DataTypePropertyInfo addSimpleUdtPropertyInfo(String propertyName,boolean requried,boolean enableRtrim,String udtConfigId) + { + return addSimpleUdtPropertyInfo(propertyName,getFieldPropertyDisplayValue(propertyName),requried,enableRtrim,false,udtConfigId,propertyName,false,false); + } + + protected final DataTypePropertyInfo addSimpleUdtPropertyInfo(String propertyName,boolean requried,boolean enableRtrim,String udtConfigId,boolean enableStdTimeFormat) + { + return addSimpleUdtPropertyInfo(propertyName,getFieldPropertyDisplayValue(propertyName),requried,enableRtrim,false,udtConfigId,propertyName,enableStdTimeFormat,false); + } + + protected final DataTypePropertyInfo addSimpleUdtPropertyInfo(String propertyName,String propertyDisplayKey,boolean requried,boolean enableRtrim,boolean isMulti,String udtConfigId,String beLabelID,boolean enableStdTimeFormat,boolean isBigNumber) { + IUdtManager udtManager = (IUdtManager) UdtManagerUtils.getUdtFactory() + .createUdtManager(udtConfigId); + try { + CefValueObjModelResInfo valueObjModelResInfo = (CefValueObjModelResInfo) udtManager + .getClass().getMethod("getUdtModelInfo").invoke(udtManager); + CefValueObjResInfo valueObjResInfo = (CefValueObjResInfo) valueObjModelResInfo + .getCustomResource(valueObjModelResInfo.getRootNodeCode()); + DataTypePropertyInfo udtPropInfo = valueObjResInfo.getEntityTypeInfo() + .getPropertyInfo(valueObjResInfo.getEntityCode()); + + if (udtPropInfo.getObjectInfo() instanceof EnumPropertyInfo) { + SimpleEnumUdtPropertyInfo simpleEnumUdtPropertyInfo = new SimpleEnumUdtPropertyInfo( + udtConfigId, false); + EnumPropertyInfo enumPropertyInfo = new EnumPropertyInfo(); + for (EnumValueInfo enumValueInfo : ((EnumPropertyInfo) udtPropInfo.getObjectInfo()) + .getEnumValueInfos()) { + enumPropertyInfo.addEnumValueInfo( + propertyDisplayKey.substring(0, propertyDisplayKey.lastIndexOf(".")), + enumValueInfo.getEnumCode(), enumValueInfo.getDefaultName(), + enumValueInfo.getStringIndex(), enumValueInfo.getIndex()); + } + simpleEnumUdtPropertyInfo.setEnumInfo(enumPropertyInfo); + return addBffPropertyInfo(propertyName, propertyDisplayKey, requried, enableRtrim, + udtPropInfo.getLength(), udtPropInfo.getPrecision(), FieldType.Udt, ObjectType.UDT, + simpleEnumUdtPropertyInfo, null, isMulti, isBigNumber, beLabelID, + enableStdTimeFormat); + } else { + SimpleUdtPropertyInfo simpleUdtPropertyInfo = new SimpleUdtPropertyInfo(udtConfigId, + false); + return addBffPropertyInfo(propertyName, propertyDisplayKey, requried, enableRtrim, + udtPropInfo.getLength(), udtPropInfo.getPrecision(), FieldType.Udt, ObjectType.UDT, + simpleUdtPropertyInfo, null, isMulti, isBigNumber, beLabelID, enableStdTimeFormat); + } + + } catch (IllegalAccessException var10) { + throw new RuntimeException(); + } catch (InvocationTargetException var11) { + throw new RuntimeException(); + } catch (NoSuchMethodException var12) { + throw new RuntimeException(); + } + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/builtin/BffModelResInfoImpl.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/builtin/BffModelResInfoImpl.java new file mode 100644 index 0000000..d5400c5 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/builtin/BffModelResInfoImpl.java @@ -0,0 +1,30 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.builtin; + +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefModelResInfoImpl; + +public class BffModelResInfoImpl extends CefModelResInfoImpl { + + public BffModelResInfoImpl(String currentSu, String resMetaDataId, String metaDataId, String displayKey) { + super(currentSu, resMetaDataId, metaDataId, displayKey); + } + + public BffModelResInfoImpl(String currentSu, String resMetadataId, String displayKey) { + this(currentSu, resMetadataId, "", displayKey); + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/builtin/BffPropertyInfo.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/builtin/BffPropertyInfo.java new file mode 100644 index 0000000..23279be --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/builtin/BffPropertyInfo.java @@ -0,0 +1,115 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.builtin; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.inspur.edp.cef.api.manager.serialize.CefSerializeContext; +import com.inspur.edp.cef.entity.entity.FieldType; +import com.inspur.edp.cef.spi.entity.PropertyDefaultValue; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.BasePropertyInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.DataTypePropertyInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.ObjectType; +import com.inspur.edp.cef.spi.jsonser.util.SerializerUtil; + +public class BffPropertyInfo extends DataTypePropertyInfo { + + private String beLabelId; + private boolean enableStdTimeFormat; + + public String getBeLabelId(){ + return this.beLabelId; + } + + public boolean isEnableStdTimeFormat() { + return enableStdTimeFormat; + } + + public BffPropertyInfo(String propertyName, String displayValueKey, boolean required, boolean enableRtrim, int length, int precision, FieldType fieldType, ObjectType objectType, BasePropertyInfo objectInfo, PropertyDefaultValue defaultValue) { + super(propertyName, displayValueKey, required, enableRtrim, length, precision, fieldType, objectType, objectInfo, defaultValue); + } + + public BffPropertyInfo(String propertyName, String displayValueKey, boolean required, boolean enableRtrim, int length, int precision, FieldType fieldType, ObjectType objectType, BasePropertyInfo objectInfo, PropertyDefaultValue defaultValue, boolean isMulti) { + super(propertyName, displayValueKey, required, enableRtrim, length, precision, fieldType, objectType, objectInfo, defaultValue, isMulti); + } + + public BffPropertyInfo(String propertyName, String displayValueKey, boolean required, boolean enableRtrim, int length, int precision, FieldType fieldType, ObjectType objectType, BasePropertyInfo objectInfo, PropertyDefaultValue defaultValue, boolean isMulti, boolean bigNumber) { + super(propertyName, displayValueKey, required, enableRtrim, length, precision, fieldType, objectType, objectInfo, defaultValue, isMulti, bigNumber); + } + public BffPropertyInfo(String propertyName, String displayValueKey, boolean required, boolean enableRtrim, int length, int precision, FieldType fieldType, ObjectType objectType, BasePropertyInfo objectInfo, PropertyDefaultValue defaultValue, boolean isMulti, boolean bigNumber,String beLabelId) { + super(propertyName, displayValueKey, required, enableRtrim, length, precision, fieldType, objectType, objectInfo, defaultValue, isMulti, bigNumber); + this.beLabelId=beLabelId; + } + public BffPropertyInfo(String propertyName, String displayValueKey, boolean required, boolean enableRtrim, int length, int precision, FieldType fieldType, ObjectType objectType, BasePropertyInfo objectInfo, PropertyDefaultValue defaultValue, boolean isMulti,String beLabelId) { + super(propertyName, displayValueKey, required, enableRtrim, length, precision, fieldType, objectType, objectInfo, defaultValue, isMulti); + this.beLabelId=beLabelId; + } + + public BffPropertyInfo(String propertyName, String displayValueKey, boolean required, boolean enableRtrim, int length, int precision, FieldType fieldType, ObjectType objectType, BasePropertyInfo objectInfo, PropertyDefaultValue defaultValue, boolean isMulti, boolean bigNumber,String beLabelId,boolean enableStdTimeFormat) { + super(propertyName, displayValueKey, required, enableRtrim, length, precision, fieldType, objectType, objectInfo, defaultValue, isMulti, bigNumber); + this.beLabelId=beLabelId; + this.enableStdTimeFormat=enableStdTimeFormat; + } + private CefSerializeContext getCefSerializeContext(CefSerializeContext serContext){ + if(serContext==null) + serContext=new CefSerializeContext(); + return serContext; + } + // + public void write(JsonGenerator writer, Object value, SerializerProvider serializer, CefSerializeContext serContext){ + serContext=getCefSerializeContext(serContext); + + if(enableStdTimeFormat){ + serContext.setEnableStdTimeFormat(enableStdTimeFormat); + } + super.write(writer,value,serializer,serContext); + } + + public Object read(JsonParser reader, DeserializationContext serializer, CefSerializeContext serContext) { + serContext=getCefSerializeContext(serContext) ; + + if(enableStdTimeFormat){ + serContext.setEnableStdTimeFormat(enableStdTimeFormat); + } + return super.read(reader,serializer,serContext); + } + + public void writeChange(JsonGenerator writer, Object value, SerializerProvider serializer, CefSerializeContext serContext) { + serContext=getCefSerializeContext(serContext) ; + + if(enableStdTimeFormat){ + serContext.setEnableStdTimeFormat(enableStdTimeFormat); + } + super.writeChange(writer,value,serializer,serContext); + } + + public Object readChange(JsonParser reader, DeserializationContext serializer, CefSerializeContext serContext) { + serContext=getCefSerializeContext(serContext); + + if(enableStdTimeFormat){ + serContext.setEnableStdTimeFormat(enableStdTimeFormat); + } + return super.readChange(reader,serializer,serContext); + } + + @Override + protected final void writeDecimalProp(JsonGenerator writer, Object value, SerializerProvider serializer, CefSerializeContext serContext) { + SerializerUtil.writeDecimal(writer, value, this.getPropertyName(), serializer, this.getIsBigNumber()); + } +} -- Gitee From bee87492e823bf22ba685d9f4c3cf736d5552c95 Mon Sep 17 00:00:00 2001 From: Jakeem Date: Fri, 28 Oct 2022 21:25:01 +0800 Subject: [PATCH 57/81] =?UTF-8?q?1.=20=E6=B7=BB=E5=8A=A0=E4=BA=86=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E9=9B=86=E5=92=8C=E6=8A=BD=E8=B1=A1=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractBffChangeJsonDeserializer.java | 94 +++++++++++++++++++ .../AbstractBffChangeJsonSerializer.java | 33 +++++++ .../changeset/AbstractVMChangeConvertor.java | 72 ++++++++++++++ 3 files changed, 199 insertions(+) create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/changeset/AbstractBffChangeJsonDeserializer.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/changeset/AbstractBffChangeJsonSerializer.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/changeset/AbstractVMChangeConvertor.java diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/changeset/AbstractBffChangeJsonDeserializer.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/changeset/AbstractBffChangeJsonDeserializer.java new file mode 100644 index 0000000..dae260f --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/changeset/AbstractBffChangeJsonDeserializer.java @@ -0,0 +1,94 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.changeset; + +import com.inspur.edp.bff.api.manager.IFSManagerFactory; +import com.inspur.edp.bff.spi.AbstractBffEntityDeserConvertor; +import com.inspur.edp.cef.entity.entity.IEntityDataCollection; +import com.inspur.edp.cef.spi.jsonser.abstractcefchange.AbstractCefDataDeSerializer; +import com.inspur.edp.cef.spi.jsonser.base.StringUtils; +import com.inspur.edp.cef.spi.jsonser.entity.AbstractEntityChangeJsonDeSerializer; +import com.inspur.edp.cef.spi.jsonser.entity.AbstractEntitySerializerItem; +import com.inspur.edp.commonmodel.api.ICMManager; +import com.inspur.edp.commonmodel.spi.AbstractCMEntityChangeJsonDeSerializer; +import io.iec.edp.caf.runtime.config.CefBeanUtil; + +import java.lang.reflect.Method; +import java.util.List; + +public abstract class AbstractBffChangeJsonDeserializer extends AbstractCMEntityChangeJsonDeSerializer{ + + private String fsType; + private ICMManager manager; + public AbstractBffChangeJsonDeserializer(String nodeCode, boolean isRoot, String fsType, List serializers) { + super(nodeCode, isRoot, serializers); + this.fsType =fsType; + } + + private IFSManagerFactory fsMgrFactory; + private IFSManagerFactory getFsMgrFactory(){ + if(fsMgrFactory == null){ + fsMgrFactory = CefBeanUtil.getAppCtx().getBean(IFSManagerFactory.class); + } + return fsMgrFactory; + } + @Override + protected ICMManager getCMManager() { + if(manager ==null) + manager = getFsMgrFactory().getFSManager(fsType); + return manager; + } + + public void setManager(ICMManager manager){ + this.manager = manager; + } + + @Override + protected AbstractCefDataDeSerializer createDataDeSerializer() { + AbstractBffEntityDeserConvertor deSerializer = (AbstractBffEntityDeserConvertor)this.getCefDataDeSerializer(); + deSerializer.setManager(manager); + return deSerializer; + } + + @Override + protected AbstractEntityChangeJsonDeSerializer buildChildConvertor(String nodeCode){ + AbstractBffChangeJsonDeserializer childConvertor = (AbstractBffChangeJsonDeserializer)getChildEntityConvertor(nodeCode); + childConvertor.setManager(manager); + return childConvertor; + } + + @Override + protected String getRealChildCode(String propertyName) { + + Class entityType =getFsMgrFactory().getFSManager(fsType).createData().getClass(); + String transNodeCode = propertyName.substring(0, propertyName.length() - 1); + if (!propertyName.equals(StringUtils.toCamelCase(propertyName))) + return transNodeCode; + + for(Method method :entityType.getMethods()) { + //if (!propertyInfo.GetCustomAttributes(typeof(VMChildAttribute), true).Any()) + // continue; + if(method.getReturnType() != IEntityDataCollection.class) + continue; + String methodName = method.getName(); + String tansCode = methodName.substring(0, methodName.length() - 1).substring(3); + if (StringUtils.toCamelCase(tansCode).equals(transNodeCode )|| tansCode.equals(transNodeCode)) + return tansCode; + } + return propertyName.substring(0, propertyName.length() - 1); + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/changeset/AbstractBffChangeJsonSerializer.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/changeset/AbstractBffChangeJsonSerializer.java new file mode 100644 index 0000000..6988b30 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/changeset/AbstractBffChangeJsonSerializer.java @@ -0,0 +1,33 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.changeset; + +import com.inspur.edp.cef.spi.jsonser.entity.AbstractEntitySerializerItem; +import com.inspur.edp.commonmodel.spi.AbstractCMEntityChangeJsonSerializer; + +import java.util.List; + +public abstract class AbstractBffChangeJsonSerializer extends AbstractCMEntityChangeJsonSerializer { + + private String fsType; + + public AbstractBffChangeJsonSerializer(String nodeCode, boolean isRoot, String fsType, List serializers) { + super(nodeCode, isRoot, serializers); + this.fsType = fsType; + } + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/changeset/AbstractVMChangeConvertor.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/changeset/AbstractVMChangeConvertor.java new file mode 100644 index 0000000..d416b1d --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/changeset/AbstractVMChangeConvertor.java @@ -0,0 +1,72 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.changeset; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.bff.entity.changeset.ViewModelChangeset; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; + +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefEntityResInfoImpl; +import java.io.IOException; + +public abstract class AbstractVMChangeConvertor extends JsonDeserializer { + + @Override + public ViewModelChangeset deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { + ViewModelChangeset change = createChange(); + IChangeDetail changeDetail = getChangeDeserializer().readJson(jsonParser, deserializationContext);// .ReadJson(reader, objectType, existingValue, serializer); + change.setChange(changeDetail);// = (IChangeDetail)((tempVar instanceof IChangeDetail) ? tempVar : null); + return change; + } + + /** + * 创建对象实例方法,用来创建VM变更集数据实例。 + * + * @return 得到的VM变更集数据实例 + * + * @see ViewModelChangeset + */ + protected abstract ViewModelChangeset createChange(); + + /** + * 获取主节点变更集转换器 + * + * @return 得到的根节点的变更集转换器 + * + * @see AbstractBffChangeJsonDeserializer + */ + protected abstract AbstractBffChangeJsonDeserializer getChangeDeserializer(); + + + /** + * 表单运行时调用 + * + * @param ifsManager 视图对象FSManager管理器 + * @param nodeCode 视图对象节点编号 + + * @return 实体资源信息 + * + * @see CefEntityResInfoImpl + */ + protected CefEntityResInfoImpl cefEntityResInfo(IFSManager ifsManager, String nodeCode) { + return (CefEntityResInfoImpl) ifsManager.getModelInfo().getCustomResource(nodeCode); + } +} -- Gitee From 91899e528641d0675bc603c02211a7f84f62d72f Mon Sep 17 00:00:00 2001 From: Jakeem Date: Sat, 29 Oct 2022 07:17:25 +0800 Subject: [PATCH 58/81] =?UTF-8?q?1.=20=E6=B7=BB=E5=8A=A0=E4=BA=86=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=80=BC=E5=BA=8F=E5=88=97=E5=8C=96=E5=8F=8D=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8C=96=E5=AE=9E=E4=BD=93=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spi/defaultvalue/DefaultValueUtil.java | 394 ++++++++++++++++++ .../VoBuiltInDefaultValueDeserializer.java | 106 +++++ .../VoDefaultValueChildDeserializer.java | 43 ++ .../VoDefaultValueDeserializer.java | 150 +++++++ 4 files changed, 693 insertions(+) create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/defaultvalue/DefaultValueUtil.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/defaultvalue/VoBuiltInDefaultValueDeserializer.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/defaultvalue/VoDefaultValueChildDeserializer.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/defaultvalue/VoDefaultValueDeserializer.java diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/defaultvalue/DefaultValueUtil.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/defaultvalue/DefaultValueUtil.java new file mode 100644 index 0000000..687668d --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/defaultvalue/DefaultValueUtil.java @@ -0,0 +1,394 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.defaultvalue; + +import com.inspur.edp.bef.api.lcp.ILcpFactory; +import com.inspur.edp.bef.api.lcp.IStandardLcp; +import com.inspur.edp.bef.api.parameter.retrieve.RespectiveRetrieveResult; +import com.inspur.edp.bef.api.parameter.retrieve.RetrieveParam; +import com.inspur.edp.bef.spi.entity.builtinimpls.BefEntityResInfoImpl; +import com.inspur.edp.bef.spi.entity.builtinimpls.BefPropertyInfo; +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; +import com.inspur.edp.bff.spi.builtin.BffEntityResInfoImpl; +import com.inspur.edp.bff.spi.builtin.BffPropertyInfo; +import com.inspur.edp.cef.entity.accessor.base.AccessorBase; +import com.inspur.edp.cef.entity.entity.AssoInfoBase; +import com.inspur.edp.cef.entity.entity.IEntityData; +import com.inspur.edp.cef.entity.entity.IValuesContainer; +import com.inspur.edp.cef.spi.entity.AssociationInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.AssocationPropertyInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.DataTypePropertyInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.EnumPropertyInfo; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.ObjectType; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.RefDataTypePropertyInfo; +import com.inspur.edp.cef.spi.entity.resourceInfo.ModelResInfo; +import com.inspur.edp.udt.entity.IUdtData; + +import io.iec.edp.caf.commons.utils.SpringBeanUtils; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DefaultValueUtil { + + public static Map transVoDefaultValueToBe(IFSManagerContext context,VoDefaultValue voDefaultValue, + ArrayList nodeCodes){ + Map beDefaultValue=new HashMap<>(); + Map voDefalutValueMap=voDefaultValue.getDefaultValue(); + //获取vo上的资源info + BffEntityResInfoImpl voResInfo= getBffEntityResInfo(context,nodeCodes); + //获取be上的资源info + BefEntityResInfoImpl beResInfo= getBefEntityResInfo(context,nodeCodes); + + //遍历vo上的默认值 + for(Map.Entry item:voDefalutValueMap.entrySet()){ + //获取vo字段vo上的PropertyInfo信息 + BffPropertyInfo bffPropertyInfo=(BffPropertyInfo)voResInfo.getEntityTypeInfo().getPropertyInfos().get(item.getKey().toString()); + //获取vo字段对应的be字段LabelId + String beLabelId=bffPropertyInfo.getBeLabelId(); + //获取字段的对应的be上的PropertyInfo信息 + DataTypePropertyInfo befPropertyInfo=(beResInfo.getEntityTypeInfo().getPropertyInfos().get(beLabelId)); + //获取字段对象类型,分基本,枚举,关联,udt 动态属性 + ObjectType objectType=bffPropertyInfo.getObjectType(); + switch (objectType){ + case Normal: + beDefaultValue.put(beLabelId,item.getValue()); + break; + case UDT: + beDefaultValue.put(beLabelId,((IUdtData)item.getValue()).copySelf()); + break; + case Enum: + Class enumType = ((EnumPropertyInfo)befPropertyInfo.getObjectInfo()).getEnumType(); + if(enumType == null){ + beDefaultValue.put(beLabelId, item.getValue()==null?null:item.getValue().toString()); + }else{ + beDefaultValue.put(beLabelId, item.getValue()==null?null:Enum.valueOf(enumType, item.getValue().toString())); + } + break; + case Association: + //创建一个子对象data, + IEntityData data; + if(nodeCodes == null) + data = context.getLcp().createData(""); + else + data = context.getLcp().createChildData(nodeCodes.get(nodeCodes.size()-1),""); + //创建一个关联的实例 + AssoInfoBase assoInstance= (AssoInfoBase) ((AccessorBase)data).createValue(beLabelId); + assoInstance.setValue(beLabelId,((AssoInfoBase)item.getValue()).getValue(item.getKey())); + //获取关联的默认值 + getAssoValueByDataTypePropInfo(item.getValue(),befPropertyInfo,beLabelId,bffPropertyInfo,assoInstance,beDefaultValue); + break; + case DynamicProp: + throw new RuntimeException("暂不支持动态列赋默认值!"); + default: + throw new RuntimeException("当前字段:"+item.getKey()+"对应的数据类型"+"不支持!"); + } + } + return beDefaultValue; + } + + private static BffEntityResInfoImpl getBffEntityResInfo(IFSManagerContext context,ArrayList nodeCodes) { + ModelResInfo modelResInfo = context.getBffManager().getModelInfo(); + BffEntityResInfoImpl voResInfo; + if(nodeCodes == null) + voResInfo = (BffEntityResInfoImpl)modelResInfo.getCustomResource(modelResInfo.getRootNodeCode()); + else + voResInfo =(BffEntityResInfoImpl)context.getBffManager().getModelInfo().getCustomResource(nodeCodes.get(nodeCodes.size()-1)); + return voResInfo; + } + + private static BefEntityResInfoImpl getBefEntityResInfo(IFSManagerContext context,List nodeCodes) { + ModelResInfo modelResInfo = context.getLcp().getModelInfo(); + BefEntityResInfoImpl beResInfo; + if(nodeCodes == null){ + beResInfo=(BefEntityResInfoImpl)modelResInfo.getCustomResource(modelResInfo.getRootNodeCode()); + } + else + beResInfo=(BefEntityResInfoImpl)context.getLcp().getModelInfo().getCustomResource(nodeCodes.get(nodeCodes.size()-1)); + return beResInfo; + } + + public static void getAssoValueByDataTypePropInfo(Object assoValue,DataTypePropertyInfo befPropertyInfo,String beLabelId,BffPropertyInfo bffPropertyInfo,AssoInfoBase assoInstance, Map beDefaultValue){ + // vo上的关联的字段集合 + Map map=((AssocationPropertyInfo) bffPropertyInfo.getObjectInfo()).getAssociationInfo().getRefPropInfos(); + for (Map.Entry item:map.entrySet()) { + + //todo 临时处理,关联带出字段,解析型objectInfo不是BffPropertyInfo类型,考虑到带出字段labelId不会变,临时如下处理 + DataTypePropertyInfo objectInfo = item.getValue(); + String beId = objectInfo.getPropertyName(); +// //获取当前关联字段带出字段的BffPropertyInfo信息 +// BffPropertyInfo objectInfo = (BffPropertyInfo) item.getValue(); +// //获取带出字段对应的beLabelId +// String beId = objectInfo.getBeLabelId(); + + + //根据belabelId获取BefPropertyInfo + DataTypePropertyInfo befPropertyInfo1= ((AssocationPropertyInfo) befPropertyInfo.getObjectInfo()).getAssociationInfo().getRefPropInfos().get(beId); + //获取带出字段的类型基本 关联 udt 枚举 动态????? + ObjectType objectType = objectInfo.getObjectType(); + switch (objectType) { + case Normal: + //给be上的关联普通字段赋值 + assoInstance + .setValue(beId, ((AssoInfoBase) assoValue).getValue(item.getKey())); + break; + case UDT: + break; + case Enum: + //给枚举字段赋值 + if(((AssoInfoBase) assoValue).getValue(item.getKey())==null) { + assoInstance.setValue(beId, null); + } + else { + Class enumType = ((EnumPropertyInfo) (befPropertyInfo1.getObjectInfo())) + .getEnumType(); + if(enumType==null){ + assoInstance.setValue(beId, + ((AssoInfoBase) assoValue).getValue(item.getKey()).toString()); + }else { + assoInstance.setValue(beId, Enum.valueOf(enumType, + ((AssoInfoBase) assoValue).getValue(item.getKey()).toString())); + } + } + break; + case Association: + assoInstance.setValue(beId,((AssoInfoBase) assoValue).getValue(item.getKey())); + break; + case DynamicProp: + throw new RuntimeException("暂不支持动态列赋默认值!"); + default: + throw new RuntimeException("当前字段:"+item.getKey()+"对应的数据类型"+"不支持!"); + } + + } + beDefaultValue.put(beLabelId, assoInstance); + } + + public static void getAssoValue(Object assoValue,BefPropertyInfo befPropertyInfo,String beLabelId,BffPropertyInfo bffPropertyInfo,AssoInfoBase assoInstance, Map beDefaultValue) { + getAssoValueByDataTypePropInfo(assoValue, befPropertyInfo, beLabelId, bffPropertyInfo, assoInstance, beDefaultValue); + } + public static IStandardLcp getAssoLcp(String configId){ + IStandardLcp lcp= SpringBeanUtils.getBean(ILcpFactory.class).createLcp(configId); + return lcp; + } + public static IEntityData getAssoData(String dataId,IStandardLcp lcp){ + RetrieveParam param=new RetrieveParam(); + param.setNeedLock(false); + RespectiveRetrieveResult data= lcp.retrieve(dataId,param); + if (data==null){ + throw new RuntimeException(String.format("ID为%1$s的实体数据不存在,请重新选择其他数据",dataId)); + } + return data.getData(); + } + public static void dealBasicTypeDefaultValue(BffPropertyInfo propertyInfo,String beLabelId,Map values){ + if(propertyInfo.getDefaultValue()==null || propertyInfo.getDefaultValue().getRealValue()==null) + return; + values.put(beLabelId,propertyInfo.getDefaultValue().getRealValue()); + } + public static void dealEnumDefaultValue(BffPropertyInfo bffPropertyInfo,BefPropertyInfo befPropertyInfo,String beLabelId,Map values){ + if(bffPropertyInfo.getDefaultValue()==null || bffPropertyInfo.getDefaultValue().getRealValue()==null) + return; + Object value=bffPropertyInfo.getDefaultValue().getRealValue(); + Class enumType = ((EnumPropertyInfo)befPropertyInfo.getObjectInfo()).getEnumType(); + if(enumType == null){ + values.put(beLabelId, value==null?null:value.toString()); + }else{ + values.put(beLabelId,value==null?null:Enum.valueOf(enumType, value.toString())); + } + } + public static void dealAssoDefaultValue(IStandardLcp lcp,BffPropertyInfo bffPropertyInfo,BefPropertyInfo befPropertyInfo,String beLabelId,Map values, + List nodeCodes){ + if(bffPropertyInfo.getDefaultValue()==null || bffPropertyInfo.getDefaultValue().getRealValue()==null) + return; + Object value=bffPropertyInfo.getDefaultValue().getRealValue(); + IEntityData data; + if(nodeCodes == null) + data = lcp.createData(""); + else + data = lcp.createChildData(nodeCodes.get(nodeCodes.size()-1),""); + IValuesContainer assoInstance= (IValuesContainer) ((AccessorBase)data).createValue(beLabelId); + assoInstance.setValue(beLabelId,value); + if(!(bffPropertyInfo.getObjectInfo() instanceof AssocationPropertyInfo)) { + StringBuilder builder=new StringBuilder(); + builder.append("报错原因:获取到的关联字段的resourceInfo类型不匹配,正确类型为:AssocationPropertyInfo,当前获取到的类型:").append(bffPropertyInfo.getObjectInfo()). + append("当前字段标签为:").append(bffPropertyInfo.getPropertyName()).append(",出现该问题的原因可能是:修改了该字段的信息,由关联改为了其他;修改后元数据没有更新或者生成的部署物没有更新并部署到环境中。").append("请确认后更新或者找开发人员确认"); + throw new RuntimeException(builder.toString()); + } + AssociationInfo info=((AssocationPropertyInfo)bffPropertyInfo.getObjectInfo()).getAssociationInfo(); + String configId=info.getConfig(); + IStandardLcp assoLcp=getAssoLcp(configId); + IEntityData assoData=getAssoData(value.toString(),assoLcp); + dealAssoValueByAssociatedData(assoData,befPropertyInfo,beLabelId,bffPropertyInfo,assoInstance,values); + } + public static void dealAssoValueByAssociatedData(IEntityData data,BefPropertyInfo befPropertyInfo,String beLabelId,BffPropertyInfo bffPropertyInfo,IValuesContainer assoInstance, Map values){ + Map map=((AssocationPropertyInfo) befPropertyInfo.getObjectInfo()).getAssociationInfo().getRefPropInfos(); + if(map==null || map.size()==0) + return; + for (Map.Entry item:map.entrySet()) { + DataTypePropertyInfo objectInfo = item.getValue(); + if(!(objectInfo instanceof RefDataTypePropertyInfo )) + continue; + String beId = objectInfo.getPropertyName(); + String refPropName=((RefDataTypePropertyInfo) objectInfo).getRefPropertyName(); + DataTypePropertyInfo befPropertyInfo1= ((AssocationPropertyInfo) befPropertyInfo.getObjectInfo()).getAssociationInfo().getRefPropInfos().get(beId); + ObjectType objectType = objectInfo.getObjectType(); + switch (objectType) { + case Normal: + assoInstance + .setValue(beId, data.getValue(refPropName)); + break; + case UDT: + throw new RuntimeException(String.format("暂不支持UDT类型的字段设置默认值!当前字段标签为:%1$s",beId)); + case Enum: + if(data.getValue(refPropName)==null) { + assoInstance.setValue(beId, null); + } + else { + Class enumType = ((EnumPropertyInfo) (befPropertyInfo1.getObjectInfo())) + .getEnumType(); + if(enumType==null){ + assoInstance.setValue(beId, + data.getValue(refPropName).toString()); + }else { + assoInstance.setValue(beId, Enum.valueOf(enumType, + data.getValue(refPropName).toString())); + } + } + break; + case Association: + assoInstance.setValue(beId,data.getValue(refPropName)); + break; + case DynamicProp: + throw new RuntimeException(String.format("暂不支持动态属性类型的字段设置默认值!当前字段标签为:%1$s",beId)); + default: + throw new RuntimeException(String.format("%1$s类型的字段不支持设置默认值!当前字段标签为:%2$s",objectType,beId)); + } + + } + values.put(beLabelId, assoInstance); + } + public static void dealDefaultValue(IFSManager manager, IStandardLcp lcp,DataTypePropertyInfo propertyInfo,List nodeCodes,Map values){ + BffPropertyInfo bffPropertyInfo= (BffPropertyInfo) propertyInfo; + String beLabelId=bffPropertyInfo.getBeLabelId(); + BefEntityResInfoImpl beResInfo=getBefEntityResInfo(manager.getBffContext(),nodeCodes); + DataTypePropertyInfo befPropertyInfo=(beResInfo.getEntityTypeInfo().getPropertyInfos().get(beLabelId)); + ObjectType objectType=bffPropertyInfo.getObjectType(); + switch (objectType){ + case Normal: + dealBasicTypeDefaultValue(bffPropertyInfo,beLabelId,values); + break; + case UDT: + throw new RuntimeException(String.format("暂不支持UDT类型的字段设置默认值!当前字段标签为:%1$s",propertyInfo.getPropertyName())); + case Enum: + dealEnumDefaultValue(bffPropertyInfo, (BefPropertyInfo) befPropertyInfo,beLabelId,values); + break; + case Association: + dealAssoDefaultValue(lcp,bffPropertyInfo, (BefPropertyInfo) befPropertyInfo,beLabelId,values, nodeCodes); + break; + case DynamicProp: + throw new RuntimeException(String.format("暂不支持动态属性类型的字段设置默认值!当前字段标签为:%1$s",propertyInfo.getPropertyName())); + default: + throw new RuntimeException(String.format("%1$s类型的字段不支持设置默认值!当前字段标签为:%2$s",objectType,propertyInfo.getPropertyName())); + + } + } + public static void dealExtendValue(IFSManager manager,DataTypePropertyInfo propertyInfo,ArrayList nodeCodes,Map values){ + BffPropertyInfo bffPropertyInfo= (BffPropertyInfo) propertyInfo; + String propName=bffPropertyInfo.getPropertyName(); + ObjectType objectType=bffPropertyInfo.getObjectType(); + switch (objectType){ + case Normal: + case Enum: + dealBasicTypeDefaultValue(bffPropertyInfo,propName,values); + break; + case UDT: + throw new RuntimeException(String.format("暂不支持UDT类型的字段设置默认值!当前字段标签为:%1$s",propertyInfo.getPropertyName())); + case Association: + dealExtendAssoValue(manager,bffPropertyInfo,propName,values,nodeCodes); + break; + case DynamicProp: + throw new RuntimeException(String.format("暂不支持动态属性类型的字段设置默认值!当前字段标签为:%1$s",propertyInfo.getPropertyName())); + default: + throw new RuntimeException(String.format("%1$s类型的字段不支持设置默认值!当前字段标签为:%2$s",objectType,propertyInfo.getPropertyName())); + } + } + + public static void dealExtendAssoValue(IFSManager manager,BffPropertyInfo bffPropertyInfo,String beLabelId,Map values,ArrayList nodeCodes){ + if(bffPropertyInfo.getDefaultValue()==null || bffPropertyInfo.getDefaultValue().getRealValue()==null) + return; + Object value=bffPropertyInfo.getDefaultValue().getRealValue(); + IEntityData data; + if(nodeCodes == null) + data = manager.createData(""); + else + data = manager.createChildData(nodeCodes.get(nodeCodes.size()-1),""); + AssoInfoBase assoInstance= (AssoInfoBase) ((AccessorBase)data).createValue(beLabelId); + assoInstance.setValue(beLabelId,value); + if(!(bffPropertyInfo.getObjectInfo() instanceof AssocationPropertyInfo)) { + StringBuilder builder=new StringBuilder(); + builder.append("报错原因:获取到的关联字段的resourceInfo类型不匹配,正确类型为:AssocationPropertyInfo,当前获取到的类型:").append(bffPropertyInfo.getObjectInfo()). + append("当前字段标签为:").append(bffPropertyInfo.getPropertyName()).append(",出现该问题的原因可能是:修改了该字段的信息,由关联改为了其他;修改后元数据没有更新或者生成的部署物没有更新并部署到环境中。").append("请确认后更新或者找开发人员确认"); + throw new RuntimeException(builder.toString()); + } + AssociationInfo info=((AssocationPropertyInfo)bffPropertyInfo.getObjectInfo()).getAssociationInfo(); + String configId=info.getConfig(); + IStandardLcp assoLcp=getAssoLcp(configId); + IEntityData assoData=getAssoData(value.toString(),assoLcp); + dealEntendAssoValueByAssoData(assoData,beLabelId,bffPropertyInfo,assoInstance,values); + } + public static void dealEntendAssoValueByAssoData(IEntityData data,String beLabelId,BffPropertyInfo bffPropertyInfo,AssoInfoBase assoInstance, Map values){ + Map map=((AssocationPropertyInfo) bffPropertyInfo.getObjectInfo()).getAssociationInfo().getRefPropInfos(); + if(map==null || map.size()==0) + return; + for (Map.Entry item:map.entrySet()) { + DataTypePropertyInfo objectInfo = item.getValue(); + if(!(objectInfo instanceof RefDataTypePropertyInfo )) + continue; + String beId = objectInfo.getPropertyName(); + String refPropName=((RefDataTypePropertyInfo) objectInfo).getRefPropertyName(); + ObjectType objectType = objectInfo.getObjectType(); + switch (objectType) { + case Normal: + assoInstance.setValue(beId, data.getValue(refPropName)); + break; + case UDT: + throw new RuntimeException(String.format("暂不支持UDT类型的字段设置默认值!当前字段标签为:%1$s",beId)); + case Enum: + if(data.getValue(refPropName)==null) { + assoInstance.setValue(beId, null); + } + else { + assoInstance.setValue(beId, data.getValue(refPropName).toString()); + } + break; + case Association: + assoInstance.setValue(beId,data.getValue(refPropName)); + break; + case DynamicProp: + throw new RuntimeException(String.format("暂不支持动态属性类型的字段设置默认值!当前字段标签为:%1$s",beId)); + default: + throw new RuntimeException(String.format("%1$s类型的字段不支持设置默认值!当前字段标签为:%2$s",objectType,beId)); + } + } + values.put(beLabelId, assoInstance); + } + + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/defaultvalue/VoBuiltInDefaultValueDeserializer.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/defaultvalue/VoBuiltInDefaultValueDeserializer.java new file mode 100644 index 0000000..3255050 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/defaultvalue/VoBuiltInDefaultValueDeserializer.java @@ -0,0 +1,106 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.defaultvalue; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; +import com.inspur.edp.bff.spi.builtin.BffEntityResInfoImpl; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.DataTypePropertyInfo; +import com.inspur.edp.cef.spi.entity.resourceInfo.ModelResInfo; +import com.inspur.edp.cef.spi.jsonser.base.StringUtils; + +import java.io.IOException; +import java.lang.reflect.Method; + +public class VoBuiltInDefaultValueDeserializer extends JsonDeserializer { + + protected IFSManager manager; + + public VoBuiltInDefaultValueDeserializer(IFSManager manager) { + this.manager = manager; + } + + + @Override + public VoDefaultValue deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException { + VoDefaultValue voDefaultValue = new VoDefaultValue(); + + if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) { + throw new RuntimeException("json结构异常"); + } + + jsonParser.nextToken(); + while (jsonParser.getCurrentToken() == JsonToken.FIELD_NAME) { + + if (jsonParser.getCurrentToken() == JsonToken.END_OBJECT) { + break; + } + String propertyName = jsonParser.getValueAsString(); + jsonParser.nextToken(); + BffEntityResInfoImpl resInfo = getCefEntityResInfo(); +// Map map = resInfo.getEntityTypeInfo().getPropertyInfos(); + +// Object value = map.get(getPropertyName(propertyName)).read(jsonParser, ctxt, null); +// voDefaultValue.getDefaultValue().put(getPropertyName(propertyName), value); + + DataTypePropertyInfo info = resInfo.getEntityTypeInfo().getPropertyInfo(propertyName); + Object value = info.read(jsonParser, ctxt, null); + voDefaultValue.getDefaultValue().put(info.getPropertyName(), value); + + jsonParser.nextToken(); + } + return voDefaultValue; + } + + protected BffEntityResInfoImpl getCefEntityResInfo() { + ModelResInfo modelResInfo = manager.getModelInfo(); + BffEntityResInfoImpl resInfo = (BffEntityResInfoImpl) modelResInfo.getCustomResource(modelResInfo.getRootNodeCode()); + return resInfo; + } + + protected Class getEntityType(){ + return manager.createData().getClass(); + } + + private String getPropertyName(String propertyName) { + Class entityType = getEntityType(); + if (!propertyName.equals(StringUtils.toCamelCase(propertyName))) { + return propertyName; + } + + Method[] methods = entityType.getMethods(); + for (Method method : methods) { + JsonProperty annotation = method.getAnnotation(JsonProperty.class); + if (annotation == null) + continue; + if (!method.getName().startsWith("get")) + continue; + String propName = method.getName().substring(3, method.getName().length()); + if (propertyName.equals(StringUtils.toCamelCase(propName)) || propertyName.equals(propName)) { + return propName; + } + } + + return propertyName; + } + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/defaultvalue/VoDefaultValueChildDeserializer.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/defaultvalue/VoDefaultValueChildDeserializer.java new file mode 100644 index 0000000..f639e50 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/defaultvalue/VoDefaultValueChildDeserializer.java @@ -0,0 +1,43 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.defaultvalue; + +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.bff.spi.builtin.BffEntityResInfoImpl; + +import java.util.ArrayList; + +public class VoDefaultValueChildDeserializer extends VoBuiltInDefaultValueDeserializer { + + private ArrayList nodeCodes; + + public VoDefaultValueChildDeserializer(IFSManager manager, ArrayList nodeCodes) { + super(manager); + this.nodeCodes = nodeCodes; + } + + @Override + protected BffEntityResInfoImpl getCefEntityResInfo() { + BffEntityResInfoImpl resInfo = (BffEntityResInfoImpl) manager.getModelInfo().getCustomResource(nodeCodes.get(nodeCodes.size() - 1)); + return resInfo; + } + + protected Class getEntityType() { + return manager.createChildData(nodeCodes.get(nodeCodes.size() - 1), "").getClass(); + } + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/defaultvalue/VoDefaultValueDeserializer.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/defaultvalue/VoDefaultValueDeserializer.java new file mode 100644 index 0000000..03e7446 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/defaultvalue/VoDefaultValueDeserializer.java @@ -0,0 +1,150 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.defaultvalue; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.bff.api.manager.IFSManagerFactory; +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; +import com.inspur.edp.bff.spi.utils.VoJsonDeserializer; +import com.inspur.edp.cef.spi.jsonser.base.StringUtils; +import io.iec.edp.caf.runtime.config.CefBeanUtil; + +import java.io.IOException; +import java.lang.reflect.Method; + +public abstract class VoDefaultValueDeserializer extends VoJsonDeserializer { + + private Class entityType; + + protected VoDefaultValueDeserializer() + { + entityType = getManager().createData().getClass(); + } + + @Override + public VoDefaultValue deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) + throws IOException, JsonProcessingException { + + VoDefaultValue defaultValue = createDefaultValue(); + if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) + { + throw new RuntimeException("json结构异常"); + } + //reader.Read(); + jsonParser.nextToken(); + while (jsonParser.getCurrentToken()== JsonToken.FIELD_NAME)//reader.Read()) + { + + if (jsonParser.getCurrentToken() == JsonToken.END_OBJECT) + { + break; + } + String propertyName = jsonParser.getValueAsString();//(String)reader.getValue(); + jsonParser.nextToken(); ;//reader.Read(); + readPropertyDefaultValue(jsonParser, deserializationContext, defaultValue, propertyName); + jsonParser.nextToken(); + } + return defaultValue; + } + + private void readPropertyDefaultValue(JsonParser jsonParser, DeserializationContext deserializationContext, VoDefaultValue defaultValue, String propertyName) throws IOException { +// Object value = jsonParser.getCurrentValue();//reader.getValue(); +// if (jsonParser.getCurrentToken()== JsonToken.START_OBJECT) +// { +// ObjectMapper mapper = new ObjectMapper(); +// value = mapper.readValue(jsonParser, JsonNode.class); +// readObject(jsonParser); +// } + + Object transValue = getDefaultValue(propertyName, jsonParser); + + defaultValue.getDefaultValue().put(getPropertyName(entityType, propertyName), transValue); + } + private String getPropertyName(Class entityType, String propertyName) + { + if (!propertyName.equals(StringUtils.toCamelCase(propertyName))) + { + return propertyName; + } + + Method[] methods = entityType.getMethods(); + for (Method method : methods) + { + JsonProperty annotation = method.getAnnotation(JsonProperty.class); + if(annotation == null) + continue; + if(!method.getName().startsWith("get")) + continue; + String propName = method.getName().substring(3, method.getName().length()); + if (propertyName.equals(StringUtils.toCamelCase(propName)) || propertyName.equals(propName)) + { + return propName; + } + } + + return propertyName; + } + + private void readObject(JsonParser reader) throws IOException { + if (reader.getCurrentToken() == JsonToken.START_OBJECT) + { + reader.nextToken(); + } + while (reader.getCurrentToken() == JsonToken.FIELD_NAME) + { + reader.nextToken(); + reader.nextToken(); + } + //if (reader.TokenType == JsonToken.EndObject) + //{ + // reader.Read(); + //} + } + /** + 创建对象实例方法,用来创建Vo默认值实例。 + + @return 得到的Vo默认值实例 + */ + protected abstract VoDefaultValue createDefaultValue(); + + + private IFSManagerFactory fsMgrFactory; + private IFSManagerFactory getFsMgrFactory(){ + if(fsMgrFactory == null){ + fsMgrFactory = CefBeanUtil.getAppCtx().getBean(IFSManagerFactory.class); + } + return fsMgrFactory; + } + private IFSManager getManager() + { + return getFsMgrFactory().getFSManager(getFSType()); + } + //TODO这个地方临时使用,需要尽快抽取到VM的转换器里面。 + /** + 获取VM的类型。 + + @return 得到的VM类型。 + */ + protected abstract String getFSType(); + + protected abstract Object getDefaultValue(String propertyName, Object propertyValue); +} -- Gitee From 4308252f24018e62edfc88a294c8360614d2a9b1 Mon Sep 17 00:00:00 2001 From: Jakeem Date: Sat, 29 Oct 2022 07:27:17 +0800 Subject: [PATCH 59/81] =?UTF-8?q?1.=20=E6=B7=BB=E5=8A=A0=E4=BA=86dataMappi?= =?UTF-8?q?ng=E5=92=8Cquery=E7=9A=84Listener=E5=92=8CBroker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BffDataMappingEventBroker.java | 73 ++++++++ .../IBffDataMappingEventListener.java | 37 +++++ .../spi/event/query/BffQueryEventBroker.java | 156 ++++++++++++++++++ .../event/query/IBffQueryEventListener.java | 72 ++++++++ 4 files changed, 338 insertions(+) create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/datamapping/BffDataMappingEventBroker.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/datamapping/IBffDataMappingEventListener.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/query/BffQueryEventBroker.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/query/IBffQueryEventListener.java diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/datamapping/BffDataMappingEventBroker.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/datamapping/BffDataMappingEventBroker.java new file mode 100644 index 0000000..7aa9f7d --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/datamapping/BffDataMappingEventBroker.java @@ -0,0 +1,73 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.event.datamapping; + +import com.inspur.edp.bff.api.manager.IFSAction; +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.context.DataMapperContext; + +import java.util.ArrayList; +import java.util.List; + +public class BffDataMappingEventBroker { + private static List eventLs = new ArrayList() {{ + //add(getBffDataMappingEventListener("com.inspur.edp.bff.debugtool.listener.impl.mapping.BffDataMappingEventListener")); + }}; + private static IBffDataMappingEventListener getBffDataMappingEventListener(String className){ + try { + Class cls=Class.forName(className); + IBffDataMappingEventListener listener= (IBffDataMappingEventListener) cls.newInstance(); + return listener; + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { + throw new RuntimeException("listener实例初始化失败",e); + } + + } + + public static final void fireBeforeTotalDataMapping(DataMapperContext mappingContext, IFSManagerContext bffcontext) { + for (IBffDataMappingEventListener el : eventLs) { + el.beforeTotalDataMapping(mappingContext,bffcontext); + } + } + + + public static final void fireBeforeDataMapping(IFSAction datamapping, DataMapperContext mappingContext, IFSManagerContext bffcontext) { + for (IBffDataMappingEventListener el : eventLs) { + el.beforeDataMapping(datamapping,mappingContext,bffcontext); + } + } + + public static final void fireAfterDataMapping(DataMapperContext mappingContext, IFSManagerContext bffcontext) { + for (IBffDataMappingEventListener el : eventLs) { + el.afterDataMapping(mappingContext, bffcontext); + } + } + + public static final void fireAfterTotalDataMapping(DataMapperContext mappingContext, IFSManagerContext bffcontext, int TotalCount) { + for (IBffDataMappingEventListener el : eventLs) { + el.afterTotalDataMapping(mappingContext, bffcontext, TotalCount); + } + } + + public static final void fireQueryUnnormalStop(Exception e) { + for (IBffDataMappingEventListener el : eventLs) { + el.queryUnnormalStop(e); + } + } + + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/datamapping/IBffDataMappingEventListener.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/datamapping/IBffDataMappingEventListener.java new file mode 100644 index 0000000..631ea0d --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/datamapping/IBffDataMappingEventListener.java @@ -0,0 +1,37 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.event.datamapping; + +import com.inspur.edp.bff.api.manager.IFSAction; +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.context.DataMapperContext; + + +public interface IBffDataMappingEventListener { + + //datamaping + public void beforeTotalDataMapping(DataMapperContext mappingContext, IFSManagerContext bffcontext); + + public void beforeDataMapping(IFSAction datamapping, DataMapperContext mappingContext, IFSManagerContext bffcontext); + + public void afterDataMapping(DataMapperContext mappingContext, IFSManagerContext bffcontext); + + public void afterTotalDataMapping(DataMapperContext mappingContext, IFSManagerContext bffcontext, int TotalCount); + + public void queryUnnormalStop(Exception e); + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/query/BffQueryEventBroker.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/query/BffQueryEventBroker.java new file mode 100644 index 0000000..231f5a1 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/query/BffQueryEventBroker.java @@ -0,0 +1,156 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.event.query; + +import com.inspur.edp.bef.api.lcp.AuthInfo; +import com.inspur.edp.bff.api.manager.IFSAction; +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.context.QueryContext; +import com.inspur.edp.cef.entity.condition.EntityFilter; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class BffQueryEventBroker { + private static List eventLs = new ArrayList() {{ + //add(getBffQueryEventListener("com.inspur.edp.bff.debugtool.listener.impl.query.BffQueryEventListener")); + }}; + private static IBffQueryEventListener getBffQueryEventListener(String className){ + try { + Class cls=Class.forName(className); + IBffQueryEventListener listener= (IBffQueryEventListener) cls.newInstance(); + return listener; + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { + throw new RuntimeException("listener实例初始化失败",e); + } + + } + public static final void fireBeforeQuery(IFSManagerContext bffcontext, EntityFilter filter, AuthInfo authInfo) { + for (IBffQueryEventListener el : eventLs) { + el.beforeQuery( bffcontext, filter, authInfo); + } + } + + public static final void firebeforeTotalCXQAssembler(QueryContext querycontext) { + for (IBffQueryEventListener el : eventLs) { + el.beforeTotalCXQAssembler(querycontext); + } + } + + public static final void fireBeforeCXQAssembler(IFSAction beforeaction, QueryContext querycontext, IFSManagerContext bffcontext) { + for (IBffQueryEventListener el : eventLs) { + el.beforeCXQAssembler(beforeaction,querycontext,bffcontext); + } + } + + public static final void fireAfterCXQAssembler(IFSManagerContext bffcontext, QueryContext queryContext) { + for (IBffQueryEventListener el : eventLs) { + el.afterCXQAssembler(bffcontext,queryContext); + } + } + + public static final void fireafterTotalCXQAssembler(IFSManagerContext bffcontext, QueryContext querycontext, int TotalCount) { + for (IBffQueryEventListener el : eventLs) { + el.afterTotalCXQAssembler(bffcontext,querycontext, TotalCount); + } + } + + public static final void firebeforeTotalCoreQuery(QueryContext querycontext) { + for (IBffQueryEventListener el : eventLs) { + el.beforeTotalCoreQuery(querycontext); + } + } + + public static final void firebeforeWKZTotalCoreQuery(EntityFilter filter) { + for (IBffQueryEventListener el : eventLs) { + el.beforeWKZTotalCoreQuery(filter); + } + } + + public static final void fireafterWKZTotalCoreQuery(IFSManagerContext bffcontext, List queryResult, List vmdatas){ + for (IBffQueryEventListener el : eventLs) { + el.afterWKZTotalCoreQuery(bffcontext,queryResult,vmdatas); + } + } + + public static final void firebeforeCoreQuery(IFSAction queryaction, QueryContext querycontext, IFSManagerContext bffcontext) { + for (IBffQueryEventListener el : eventLs) { + el.beforeCoreQuery(queryaction,querycontext,bffcontext); + } + } + + public static final void fireprocessGetAuth(AuthInfo auth) { + for (IBffQueryEventListener el : eventLs) { + el.processGetAuth(auth); + } + } + + + public static final void fireafterCoreQuery(IFSManagerContext context, HashMap> queryResult, QueryContext queryContext) { + for (IBffQueryEventListener el : eventLs) { + el.afterCoreQuery(context,queryResult,queryContext); + } + } + + + public static final void fireafterTotalCoreQuery(IFSManagerContext context, HashMap> queryResult, QueryContext queryContext, int TotalCount) { + for (IBffQueryEventListener el : eventLs) { + el.afterTotalCoreQuery(context,queryResult,queryContext, TotalCount); + } + } + + public static final void firebeforeTotalCXHAssembler(QueryContext queryContext, IFSManagerContext bffcontext) { + for (IBffQueryEventListener el : eventLs) { + el.beforeTotalCXHAssembler(queryContext,bffcontext); + } + } + + + public static final void firebeforeCXHAssembler(IFSAction cxhassembler, QueryContext queryContext, IFSManagerContext bffcontext) { + for (IBffQueryEventListener el : eventLs) { + el.beforeCXHAssembler(cxhassembler,queryContext,bffcontext); + } + } + + public static final void fireafterCXHAssembler(QueryContext queryContext, IFSManagerContext bffcontext) { + for (IBffQueryEventListener el : eventLs) { + el.afterCXHAssembler(queryContext, bffcontext); + } + } + + public static final void fireafterTotalCXHAssembler(QueryContext queryContext, IFSManagerContext bffcontext, int TotalCount) { + for (IBffQueryEventListener el : eventLs) { + el.afterTotalCXHAssembler(queryContext, bffcontext, TotalCount); + } + } + + public static final void fireAfterQuery(IFSManagerContext context, EntityFilter filter, List result) { + for (IBffQueryEventListener el : eventLs) { + el.afterQuery(context, filter, result); + } + } + public static final void fireQueryUnnormalStop(Exception e) { + for (IBffQueryEventListener el : eventLs) { + el.queryUnnormalStop(e); + } + } + + + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/query/IBffQueryEventListener.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/query/IBffQueryEventListener.java new file mode 100644 index 0000000..846bf1b --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/query/IBffQueryEventListener.java @@ -0,0 +1,72 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.event.query; + +import com.inspur.edp.bef.api.lcp.AuthInfo; +import com.inspur.edp.bff.api.manager.IFSAction; +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.context.QueryContext; +import com.inspur.edp.cef.entity.condition.EntityFilter; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public interface IBffQueryEventListener { + public void beforeQuery(IFSManagerContext bffcontext, EntityFilter filter, AuthInfo authInfo); + + //查询前扩展动作 + public void beforeTotalCXQAssembler(QueryContext querycontext); + + public void beforeCXQAssembler(IFSAction beforeaction, QueryContext querycontext, IFSManagerContext bffcontext); + + public void afterCXQAssembler(IFSManagerContext bffcontext, QueryContext queryContext); + + public void afterTotalCXQAssembler(IFSManagerContext bffcontext, QueryContext queryContext, int TotalCount); + + //查询 + public void beforeWKZTotalCoreQuery(EntityFilter filter); + + public void afterWKZTotalCoreQuery(IFSManagerContext bffcontext, List queryResult, List vmdatas); + + public void beforeTotalCoreQuery(QueryContext querycontext); + + public void beforeCoreQuery(IFSAction queryaction, QueryContext querycontext, IFSManagerContext bffcontext); + + public void processGetAuth(AuthInfo auth); + + public void afterCoreQuery(IFSManagerContext context, HashMap> queryResult, QueryContext queryContext); + + public void afterTotalCoreQuery(IFSManagerContext context, HashMap> queryResult, QueryContext queryContext, int TotalCount); + + + + //查询后扩展动作 + public void beforeTotalCXHAssembler(QueryContext queryContext, IFSManagerContext bffcontext); + + public void beforeCXHAssembler(IFSAction cxhassembler, QueryContext queryContext, IFSManagerContext bffcontext); + + public void afterCXHAssembler(QueryContext queryContext, IFSManagerContext bffcontext); + + public void afterTotalCXHAssembler(QueryContext queryContext, IFSManagerContext bffcontext, int TotalCount); + + public void afterQuery(IFSManagerContext context, EntityFilter filter, List result); + + public void queryUnnormalStop(Exception e); + +} -- Gitee From bdbe7958fca426dbc39663c8b2c1836ffcf8cba5 Mon Sep 17 00:00:00 2001 From: zhangjintr <1234qwer> Date: Sat, 29 Oct 2022 11:06:44 +0800 Subject: [PATCH 60/81] feature(bff-framework-entity):add ViewModelChangeset --- .../entity/changeset/ViewModelChangeset.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 bff-framework-entity/src/main/java/com/inspur/edp/bff/entity/changeset/ViewModelChangeset.java diff --git a/bff-framework-entity/src/main/java/com/inspur/edp/bff/entity/changeset/ViewModelChangeset.java b/bff-framework-entity/src/main/java/com/inspur/edp/bff/entity/changeset/ViewModelChangeset.java new file mode 100644 index 0000000..5debf87 --- /dev/null +++ b/bff-framework-entity/src/main/java/com/inspur/edp/bff/entity/changeset/ViewModelChangeset.java @@ -0,0 +1,36 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.entity.changeset; + +import com.inspur.edp.cef.entity.changeset.IChangeDetail; + +public class ViewModelChangeset { + /** + 变更集明细 + + */ + private IChangeDetail changeDetail; + + public final IChangeDetail getChange() + { + return changeDetail; + } + public final void setChange(IChangeDetail value) + { + changeDetail = value; + } +} -- Gitee From 3f3a716c481f77a8c498f8993aa00bff147574ad Mon Sep 17 00:00:00 2001 From: zhangjintr <1234qwer> Date: Sat, 29 Oct 2022 11:07:38 +0800 Subject: [PATCH 61/81] feature(bff-framework-entity):add VoDefaultValue --- .../entity/defaultvalue/VoDefaultValue.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 bff-framework-entity/src/main/java/com/inspur/edp/bff/entity/defaultvalue/VoDefaultValue.java diff --git a/bff-framework-entity/src/main/java/com/inspur/edp/bff/entity/defaultvalue/VoDefaultValue.java b/bff-framework-entity/src/main/java/com/inspur/edp/bff/entity/defaultvalue/VoDefaultValue.java new file mode 100644 index 0000000..a885ae7 --- /dev/null +++ b/bff-framework-entity/src/main/java/com/inspur/edp/bff/entity/defaultvalue/VoDefaultValue.java @@ -0,0 +1,36 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.entity.defaultvalue; + +import java.util.HashMap; + +public class VoDefaultValue { + + private HashMap defaultValue = new HashMap(); + + /** + * 新增默认值map,key为字段标签,value为字段对应的值 + * + * @return 返回一个Map结构 + * @see HashMap + */ + public final HashMap getDefaultValue() { + return defaultValue; + } + +} + -- Gitee From f6de93ba93e4400e2234606a779e64b50399fd1f Mon Sep 17 00:00:00 2001 From: zhangjintr <1234qwer> Date: Sat, 29 Oct 2022 11:08:16 +0800 Subject: [PATCH 62/81] feature(bff-framework-entity):add RetrieveDefaultParam --- .../edp/bff/entity/RetrieveDefaultParam.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 bff-framework-entity/src/main/java/com/inspur/edp/bff/entity/RetrieveDefaultParam.java diff --git a/bff-framework-entity/src/main/java/com/inspur/edp/bff/entity/RetrieveDefaultParam.java b/bff-framework-entity/src/main/java/com/inspur/edp/bff/entity/RetrieveDefaultParam.java new file mode 100644 index 0000000..90f8f30 --- /dev/null +++ b/bff-framework-entity/src/main/java/com/inspur/edp/bff/entity/RetrieveDefaultParam.java @@ -0,0 +1,58 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.entity; + +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; +import java.util.ArrayList; + +public class RetrieveDefaultParam { + + /** + * 传入的id字段列表,目前暂不支持 + * + * @return + */ + public ArrayList getIds() { + return ids; + } + + /** + * 默认值列表,每个元素对应的{@link VoDefaultValue}中记录了每条数据要新增的字段及其默认值 + * + * @return + */ + public ArrayList getVoDefaultValues() { + return defaultValues; + } + + /** + * 设置是否批量新增 + * + * @param batch + */ + public void setBatch(boolean batch) { + isBatch = batch; + } + + public boolean isBatch() { + return isBatch; + } + + private ArrayList ids = new ArrayList<>(); + private ArrayList defaultValues = new ArrayList<>(); + private boolean isBatch = false; +} -- Gitee From d9702a2a9722b42aedc0a7ee83094afb35ac0dd2 Mon Sep 17 00:00:00 2001 From: zhangjintr <1234qwer> Date: Sat, 29 Oct 2022 11:09:47 +0800 Subject: [PATCH 63/81] =?UTF-8?q?style(bff-framework-entity):ViewModelChan?= =?UTF-8?q?geset=E8=A7=84=E8=8C=83=E4=BB=A3=E7=A0=81=E7=BC=A9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/changeset/ViewModelChangeset.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/bff-framework-entity/src/main/java/com/inspur/edp/bff/entity/changeset/ViewModelChangeset.java b/bff-framework-entity/src/main/java/com/inspur/edp/bff/entity/changeset/ViewModelChangeset.java index 5debf87..eb98237 100644 --- a/bff-framework-entity/src/main/java/com/inspur/edp/bff/entity/changeset/ViewModelChangeset.java +++ b/bff-framework-entity/src/main/java/com/inspur/edp/bff/entity/changeset/ViewModelChangeset.java @@ -19,18 +19,17 @@ package com.inspur.edp.bff.entity.changeset; import com.inspur.edp.cef.entity.changeset.IChangeDetail; public class ViewModelChangeset { - /** - 变更集明细 - */ - private IChangeDetail changeDetail; + /** + * 变更集明细 + */ + private IChangeDetail changeDetail; - public final IChangeDetail getChange() - { - return changeDetail; - } - public final void setChange(IChangeDetail value) - { - changeDetail = value; - } + public final IChangeDetail getChange() { + return changeDetail; + } + + public final void setChange(IChangeDetail value) { + changeDetail = value; + } } -- Gitee From 1c20557df088d2ef5f0c112004bbb9ddab4fbd44 Mon Sep 17 00:00:00 2001 From: qinxinyuan Date: Sat, 29 Oct 2022 11:13:02 +0800 Subject: [PATCH 64/81] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bff/core/action/query/QoQueryAction.java | 90 +++++++ .../bff/core/action/query/QueryAction.java | 228 ++++++++++++++++++ .../core/action/query/QueryChildAction.java | 87 +++++++ .../query/QueryChildWithCodeAction.java | 123 ++++++++++ 4 files changed, 528 insertions(+) create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QoQueryAction.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryAction.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryChildAction.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryChildWithCodeAction.java diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QoQueryAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QoQueryAction.java new file mode 100644 index 0000000..db00e0d --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QoQueryAction.java @@ -0,0 +1,90 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.query; + +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.api.manager.context.DataMapperContext; +import com.inspur.edp.bff.api.manager.context.QueryContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.entity.dependenceTemp.Pagination; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.ArrayList; +import java.util.HashMap; + +public class QoQueryAction extends AbstractFSAction> { + private IEntityData param; + private Pagination pageInfo; + private String extendCond; + + public QoQueryAction(IEntityData param, Pagination pageInfo, String extendCond) { + this.param = param; + this.pageInfo = pageInfo; + this.extendCond = extendCond; + } + + @Override + protected void execute() { + if (getContext().getAssemblerManager() == null) { + doDefaultQuery(); + return; + } + + QueryContext queryContext = new QueryContext(); + queryContext.setPageInfo(pageInfo); + queryContext.setParam(param); + queryContext.setExtendCond(extendCond); + + //① BeforeQuery + getContext().getAssemblerManager().getQueryAssembler().doBeforeQuery(getContext(), queryContext); + + //② DoQuery + HashMap> queryResult = getContext().getAssemblerManager(). + getQueryAssembler().doQuery(getContext(), queryContext); + //③ DataMapping + DataMapperContext mapperContext = new DataMapperContext(); + mapperContext.setSourceData(queryResult); + + ArrayList vmDatas = getContext().getAssemblerManager(). + getDataMapperAssembler().doDataMapping2Vo(getContext(), mapperContext); + queryContext.setQueryResult(vmDatas); + //④ AfterQuery + getContext().getAssemblerManager().getQueryAssembler().doAfterQuery(getContext(), queryContext); + setResult(vmDatas); + } + + private void doDefaultQuery() { +// var queryResult = ServiceManager.GetService().GetQueryManager(Context.SourceConfigs[0].SourceConfigId).Query(param, pageInfo, extendCond); +// if (queryResult == null || queryResult.Data == null) { +// setResult(null); +// } else { +// ArrayList vmDatas = new java.util.ArrayList(); +// +// IDataConvertor dataConvertor = getBffContext().getDataConvertor(); +// +// +// for (var entityData : queryResult.Data) { +// +// IEntityData vmData = getBffContext().createData(); +// dataConvertor.convertFromSourceData(entityData, vmData); +// vmDatas.add(vmData); +// } +// +// Result = vmDatas; +// } + } +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryAction.java new file mode 100644 index 0000000..c327c7b --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryAction.java @@ -0,0 +1,228 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.query; + +import com.inspur.edp.bef.api.lcp.IStandardLcp; +import com.inspur.edp.bef.auditconfig.api.BefAuditConfigService; +import com.inspur.edp.bef.auditconfig.entity.BefAuditConfig; +import com.inspur.edp.bef.auditconfig.entity.BefAuditConfigItem; +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.api.dataprocessor.IFilterFieldConvertor; +import com.inspur.edp.bff.api.manager.context.DataMapperContext; +import com.inspur.edp.bff.api.manager.context.QueryContext; +import com.inspur.edp.bff.core.manager.FSManagerContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.bff.api.extend.IBffManagerExtend; +import com.inspur.edp.bff.spi.event.query.BffQueryEventBroker; +import com.inspur.edp.cef.entity.condition.EntityFilter; +import com.inspur.edp.cef.entity.condition.FilterCondition; +import com.inspur.edp.cef.entity.condition.SortCondition; +import com.inspur.edp.cef.entity.entity.IEntityData; +import io.iec.edp.caf.audit.api.data.AuditType; +import io.iec.edp.caf.audit.api.data.EventResultType; +import io.iec.edp.caf.audit.api.data.GspAudit; +import io.iec.edp.caf.audit.api.manager.GspAuditManager; +import io.iec.edp.caf.boot.context.CAFContext; +import io.iec.edp.caf.commons.utils.SpringBeanUtils; +import lombok.var; + +import java.util.*; + +public class QueryAction extends AbstractFSAction> { + + private EntityFilter filter; + private Map filterMap=new HashMap<>(); + public QueryAction(EntityFilter filter) { + this.filter = filter; + } + + private void transFilter() { + if (filter == null) { + return; + } + + IFilterFieldConvertor convertor = getContext().getFilterConvertor(); + if (convertor == null) { + return; + } + if (filter.getFilterConditions() != null && filter.getFilterConditions().size() > 0) { + + transFilter(filter.getFilterConditions(), convertor); + } + if (filter.getSortConditions() != null && filter.getSortConditions().size() > 0) { + + transSort(filter.getSortConditions(), convertor); + } + } + + private void transFilter(ArrayList filterConditions, IFilterFieldConvertor convertor) { + for (FilterCondition filterCondition : filterConditions) { + if("".equals(filterCondition.getFilterField()) ||filterCondition.getFilterField()==null){ + throw new RuntimeException("当前查询过滤字段为空,请重新设置过滤字段。"); + } + filterCondition.setFilterField(convertor.transFilterField(filterCondition.getFilterField())); + if(filterCondition.getFilterNode()!=null&&"".equals(filterCondition.getFilterNode())==false) { + + filterCondition.setFilterNode( getContext().getBECodeFromVM(getContext().getVoCode( filterCondition.getFilterNode()))); + } + } + } + + private void transSort(ArrayList sortConditions, IFilterFieldConvertor convertor) { + for (SortCondition sortCondition : sortConditions) { + if("".equals(sortCondition.getSortField()) ||sortCondition.getSortField()==null){ + throw new RuntimeException("当前查询排序字段为空,请重新设置排序字段。"); + } + sortCondition.setSortField(convertor.transFilterField(sortCondition.getSortField())); + } + } + @Override + protected void execute() { + transFilter(); + if (getContext().getAssemblerManager() == null) { + doDefaultQuery(); + return; + } + + QueryContext queryContext = new QueryContext(); + queryContext.setFilter(filter); + setQueryContext(queryContext); + + //① BeforeQuery + getContext().getAssemblerManager().getQueryAssembler().doBeforeQuery(getContext(), queryContext); + //② DoQuery + HashMap> queryResult = getContext().getAssemblerManager(). + getQueryAssembler().doQuery(getContext(), queryContext); + //③ DataMapping + DataMapperContext mapperContext = new DataMapperContext(); + mapperContext.setSourceData(queryResult); + ArrayList vmDatas = getContext().getAssemblerManager(). + getDataMapperAssembler().doDataMapping2Vo(getContext(), mapperContext); + +// dealExtendMapping(vmDatas); + queryContext.setQueryResult(vmDatas); + //④ AfterQuery + getContext().getAssemblerManager().getQueryAssembler().doAfterQuery(getContext(), queryContext); + setResult(vmDatas); + auditLog(queryResult); + } + + private void auditLog(HashMap> queryResult) { + if(getContext().getVoId()==null||getContext().getVoId().equals("")) + return; + + List list = SpringBeanUtils.getBean(BefAuditConfigService.class).getBefAuditConfigsByVoId(this.getContext().getVoId()); + if(list==null||list.size()==0) + return; + for (BefAuditConfig config:list) + { + auditItem(config,queryResult); + } + } + + private void auditItem(BefAuditConfig auditConfig, HashMap> queryResult) { + if(auditConfig.getConfigItems()==null||auditConfig.getConfigItems().size()==0) + return; + for(var item:auditConfig.getConfigItems()) { + if("m_6xIwJwoUy7qzsuZ6_S5A".equals(item.getTargetVoActionId())==false) + continue; + GspAudit gspAudit = new GspAudit(); + gspAudit.setId(UUID.randomUUID().toString()); + gspAudit.setCategoryId(item.getAuditTypeId()); + gspAudit.setEventId(item.getAuditEventId()); + gspAudit.setDateTime(new Date()); + gspAudit.setType(AuditType.message); + gspAudit.setEventResult(EventResultType.success); + gspAudit.setGspAuditData(new ArrayList<>()); + gspAudit.setDescription(item.getAuditMessage().getAuditMessage()); + if(CAFContext.current.getFrameworkContext()!=null) { + gspAudit.setFunctionId(CAFContext.current.getFrameworkContext().getFuncId()); + gspAudit.setFunctionCode(CAFContext.current.getFrameworkContext().getFuncCode()); + if (CAFContext.current.getFrameworkContext().getItems().containsKey("menuName")) + gspAudit.setFunctionName( + String.valueOf( + CAFContext.current.getFrameworkContext().getItems().get("menuName"))); + } + setAuditMessage(gspAudit,item,queryResult); + SpringBeanUtils.getBean(GspAuditManager.class).addAuditSync(gspAudit); + } + } + + private void setAuditMessage(GspAudit gspAudit, BefAuditConfigItem item, + HashMap> vmDatas) { + Map> auditMessageDataFields=new HashMap<>(); + Map>> childAuditMessageDataFields=new HashMap<>(); + AuditUtils.getAuditMessageField(gspAudit,item,auditMessageDataFields,childAuditMessageDataFields); + for(Map.Entry> data:vmDatas.entrySet()) + { + if(data.getValue()!=null) + for(IEntityData dataItem :data.getValue()) + AuditUtils.addAuditMessageFieldValue(dataItem,"",auditMessageDataFields,childAuditMessageDataFields,this.getContext()); + } + AuditUtils.setAuditMessage(gspAudit,auditMessageDataFields,childAuditMessageDataFields); + } + + + private void dealExtendMapping(ArrayList voDatas){ + var extList = ((FSManagerContext)getContext()).getExtList(); + if( extList == null || extList.size() <1) + return; + for(var voData :voDatas){ + var beData = getLcp().retrieve(voData.getID()).getData(); + dealExtendMapping(voData, beData, extList); + } + + } + private void dealExtendMapping(IEntityData voData, IEntityData beData, List extList){ + for (var ext : extList) { + ext.mapData2Vo(voData, beData); + } + } + protected void setQueryContext(QueryContext queryContext) + {} + + protected IStandardLcp getQueryLcp() + {return getLcp(); + } + + + + + private void doDefaultQuery() { + try { + List queryResult = getQueryLcp().query(filter); + BffQueryEventBroker.firebeforeWKZTotalCoreQuery(filter); + if (queryResult == null) { + setResult(null); + } else { + ArrayList vmDatas = new ArrayList(); + IDataConvertor dataConvertor = getContext().getDataConvertor(); + for (IEntityData entityData : queryResult) { + IEntityData vmData = getContext().createData(); + dataConvertor.convertFromBEData(entityData, vmData); + vmDatas.add(vmData); + } + BffQueryEventBroker.fireafterWKZTotalCoreQuery(getContext(), queryResult, vmDatas); + setResult(vmDatas); + } + } catch (Exception e) { + BffQueryEventBroker.fireQueryUnnormalStop(e); + throw e; + } + } + +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryChildAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryChildAction.java new file mode 100644 index 0000000..2a68114 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryChildAction.java @@ -0,0 +1,87 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.query; + +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.spi.AbstractDataConvertor; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.bff.spi.builtin.BffEntityResInfoImpl; +import com.inspur.edp.cef.entity.condition.EntityFilter; +import com.inspur.edp.cef.entity.condition.SortCondition; +import com.inspur.edp.cef.entity.entity.IEntityData; +import java.util.ArrayList; +import java.util.List; + +public class QueryChildAction extends AbstractFSAction> { + private List nodeCodes; + private EntityFilter filter; + public QueryChildAction(List nodeCodes, EntityFilter filter){ + this.nodeCodes=nodeCodes; + this.filter=filter; + } + @Override + public void execute() { + transFilter(); + + List queryResult = getLcp().query(this.nodeCodes.get(nodeCodes.size()-1), this.filter); + if (queryResult == null) { + setResult(null); + } else { + ArrayList vmDatas=new ArrayList<>(); + for (IEntityData entityData:queryResult){ + IEntityData vmData = getContext().createData(this.nodeCodes.get(nodeCodes.size()-1)); + getDataConvertor().convertFromBEData(entityData, vmData); + vmDatas.add(vmData); + } + setResult(vmDatas); + } + } + + private void transFilter() { + if(filter==null) + filter=new EntityFilter(); + + ArrayList originalSort=filter.getSortConditions(); + + BffEntityResInfoImpl childEntityResInfo= (BffEntityResInfoImpl) getContext().getModelResourceInfo().getCustomResource(nodeCodes.get(nodeCodes.size()-1)); + if(childEntityResInfo!=null && childEntityResInfo.getSorts()!=null && childEntityResInfo.getSorts().size()>0){ + filter.setSortConditions(new ArrayList()); + for (SortCondition sort:childEntityResInfo.getSorts()){ + filter.getSortConditions().add(sort); + } + if(originalSort!=null && originalSort.size()>0){ + filter.addSortConditions(originalSort); + } + } + + } + + private AbstractDataConvertor getDataConvertor() { + IDataConvertor dataConvertor = getContext().getDataConvertor(); + AbstractDataConvertor rootConvertor = (AbstractDataConvertor)((dataConvertor instanceof AbstractDataConvertor) ? dataConvertor : null); + if (this.nodeCodes.isEmpty()) + { + return rootConvertor; + } + AbstractDataConvertor currentConvertor = rootConvertor; + for (int i = 0; i < this.nodeCodes.size(); i++) + { + currentConvertor = currentConvertor.getChildDataConvertor((String)this.nodeCodes.get(i)); + } + return currentConvertor; + } +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryChildWithCodeAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryChildWithCodeAction.java new file mode 100644 index 0000000..5f13155 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryChildWithCodeAction.java @@ -0,0 +1,123 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.query; + +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.spi.AbstractDataConvertor; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.bff.spi.builtin.BffEntityResInfoImpl; +import com.inspur.edp.bff.spi.builtin.BffModelResInfoImpl; +import com.inspur.edp.cef.entity.condition.EntityFilter; +import com.inspur.edp.cef.entity.condition.SortCondition; +import com.inspur.edp.cef.entity.entity.IEntityData; +import com.inspur.edp.cef.spi.entity.resourceInfo.EntityResInfo; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class QueryChildWithCodeAction extends AbstractFSAction> { + private String nodeCode; + private EntityFilter filter; + public QueryChildWithCodeAction(String nodeCode, EntityFilter filter) { + this.nodeCode=nodeCode; + this.filter=filter; + } + + @Override + public void execute() { + checkNodeCode(); + transFilter(); + List queryResult = getLcp().query(this.nodeCode, this.filter); + ArrayList nodeCodes=new ArrayList<>(); + initChildNodeCodes(nodeCodes); + IDataConvertor dataConvertor=getDataConvertor(nodeCodes); + if (queryResult == null) { + setResult(null); + } else { + ArrayList vmDatas=new ArrayList<>(); + for (IEntityData entityData:queryResult){ + IEntityData vmData = getContext().createData(this.nodeCode); + dataConvertor.convertFromBEData(entityData, vmData); + vmDatas.add(vmData); + } + setResult(vmDatas); + } + } + + private void checkNodeCode() { + if(this.nodeCode==null ||"".equals(this.nodeCode)) + throw new RuntimeException("查询子表方法的nodeCode参数不允许为空,请传入正确的子表或者其他子表的节点编号!"); + String rootNodeCode=this.getContext().getModelResourceInfo().getRootNodeCode(); + if(this.nodeCode.equals(rootNodeCode)) + throw new RuntimeException("传入的nodeCode参数为主表编号,请传入正确的子表或者其他子表的节点编号!"); + } + + private void transFilter() { + if(filter==null) + filter=new EntityFilter(); + + ArrayList originalSort=filter.getSortConditions(); + + BffEntityResInfoImpl childEntityResInfo= (BffEntityResInfoImpl) getContext().getModelResourceInfo().getCustomResource(nodeCode); + if(childEntityResInfo!=null && childEntityResInfo.getSorts()!=null && childEntityResInfo.getSorts().size()>0){ + filter.setSortConditions(new ArrayList<>()); + for (SortCondition sort:childEntityResInfo.getSorts()){ + filter.getSortConditions().add(sort); + } + if(originalSort!=null && originalSort.size()>0){ + filter.addSortConditions(originalSort); + } + } + + } + + private AbstractDataConvertor getDataConvertor(ArrayList nodeCodes) { + IDataConvertor dataConvertor = getContext().getDataConvertor(); + AbstractDataConvertor rootConvertor = (AbstractDataConvertor)((dataConvertor instanceof AbstractDataConvertor) ? dataConvertor : null); + if (nodeCodes.isEmpty()) { + return rootConvertor; + } + AbstractDataConvertor currentConvertor = rootConvertor; + for (int i = 0; i < nodeCodes.size(); i++) { + currentConvertor = currentConvertor.getChildDataConvertor(nodeCodes.get(i)); + } + return currentConvertor; + } + + private void initChildNodeCodes(ArrayList nodeCodes) { + BffEntityResInfoImpl rootEntityInfo= (BffEntityResInfoImpl) getContext().getModelResourceInfo().getCustomResource(getContext().getModelResourceInfo().getRootNodeCode()); + if(rootEntityInfo.getChildEntityResInfos()==null ||rootEntityInfo.getChildEntityResInfos().size()==0){ + StringBuilder builder=new StringBuilder(); + builder.append("请确认要查询的从表或者从从表数据是否存在编号为").append(this.nodeCode).append("对应的VO实体节点。"); + throw new RuntimeException(builder.toString()); + } + initNodeCodes(nodeCodes,rootEntityInfo.getChildEntityResInfos()); + } + + private void initNodeCodes(ArrayList codes, Map infos) { + for (Map.Entry childResInfo:infos.entrySet()){ + if (nodeCode.equals(childResInfo.getValue().getEntityCode())) { + codes.add(nodeCode); + break; + }else { + codes.add(childResInfo.getValue().getEntityCode()); + initNodeCodes(codes,childResInfo.getValue().getChildEntityResInfos()); + } + + } + } +} -- Gitee From 883d0a43ff5201b24ee5ce49206d1a96701bef11 Mon Sep 17 00:00:00 2001 From: qinxinyuan Date: Sat, 29 Oct 2022 11:17:14 +0800 Subject: [PATCH 65/81] =?UTF-8?q?=E5=B8=A6=E6=9D=83=E9=99=90=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E6=9F=A5=E8=AF=A2=EF=BC=8C=E6=A3=80=E7=B4=A2=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/query/QueryWithAuthInfoAction.java | 72 ++++++++ .../core/action/retrieve/RetrieveAction.java | 162 ++++++++++++++++++ 2 files changed, 234 insertions(+) create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryWithAuthInfoAction.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveAction.java diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryWithAuthInfoAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryWithAuthInfoAction.java new file mode 100644 index 0000000..ab4756e --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryWithAuthInfoAction.java @@ -0,0 +1,72 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.query; + +import com.inspur.edp.bef.api.lcp.AuthInfo; +import com.inspur.edp.bef.api.lcp.IStandardLcp; +import com.inspur.edp.bff.api.manager.context.QueryContext; +import com.inspur.edp.bff.spi.event.query.BffQueryEventBroker; +import com.inspur.edp.bff.spi.utils.AuthUtils; +import com.inspur.edp.cef.entity.condition.EntityFilter; + +public class QueryWithAuthInfoAction extends QueryAction { + private AuthInfo authorityInfo; + + public QueryWithAuthInfoAction(EntityFilter filter, AuthInfo authorityInfo) + {super(filter); + this.authorityInfo = authorityInfo; + } + + @Override + protected void setQueryContext(QueryContext queryContext) { + super.setQueryContext(queryContext); + if(authorityInfo!=null&&authorityInfo.getExtType()!=null&&"".equals(authorityInfo.getExtType())==false) + { + queryContext.setUseCustomAuth(true); + queryContext.setAuthInfo(new AuthInfo()); + AuthUtils.buildAuthInfo( + queryContext.getAuthInfo(), + authorityInfo.getExtType(), + authorityInfo.getExtend1(), + authorityInfo.getExtend2(), + authorityInfo.getExtend3(), + authorityInfo.getExtend4(), + authorityInfo.getExtend5() + ); + BffQueryEventBroker.fireprocessGetAuth(authorityInfo); + } + } + + @Override + protected IStandardLcp getQueryLcp() { + IStandardLcp lcp =super.getQueryLcp(); + if(authorityInfo!=null&&authorityInfo.getExtType()!=null&&"".equals(authorityInfo.getExtType())==false) + { + AuthUtils.buildAuthInfo( + lcp.getBefContext().getAuthInfo(), + authorityInfo.getExtType(), + authorityInfo.getExtend1(), + authorityInfo.getExtend2(), + authorityInfo.getExtend3(), + authorityInfo.getExtend4(), + authorityInfo.getExtend5() + ); + BffQueryEventBroker.fireprocessGetAuth(authorityInfo); + } + return lcp; + } +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveAction.java new file mode 100644 index 0000000..4e33f32 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveAction.java @@ -0,0 +1,162 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.retrieve; + +import com.inspur.edp.bef.api.parameter.retrieve.RespectiveRetrieveResult; +import com.inspur.edp.bef.api.parameter.retrieve.RetrieveParam; +import com.inspur.edp.bef.auditconfig.api.BefAuditConfigService; +import com.inspur.edp.bef.auditconfig.entity.BefAuditConfig; +import com.inspur.edp.bef.auditconfig.entity.BefAuditConfigItem; +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.api.manager.assembler.IAssemblerManager; +import com.inspur.edp.bff.api.manager.context.DataMapperContext; +import com.inspur.edp.bff.api.manager.context.RetrieveContext; +import com.inspur.edp.bff.core.action.query.AuditUtils; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.entity.entity.IEntityData; +import io.iec.edp.caf.audit.api.data.AuditType; +import io.iec.edp.caf.audit.api.data.EventResultType; +import io.iec.edp.caf.audit.api.data.GspAudit; +import io.iec.edp.caf.audit.api.manager.GspAuditManager; +import io.iec.edp.caf.boot.context.CAFContext; +import io.iec.edp.caf.commons.utils.SpringBeanUtils; +import lombok.var; + +import java.util.*; + +public class RetrieveAction extends AbstractFSAction { + + private String dataID; + private RetrieveParam param; + + public RetrieveAction(String dataID) { + this.dataID = dataID; + } + + public RetrieveAction(String dataID, RetrieveParam param) { + this.dataID = dataID; + this.param = param; + } + + @Override + protected void execute() { + IAssemblerManager assemblyManager = getContext().getAssemblerManager(); + if (assemblyManager == null) { + doDefaultRetrieve(); + return; + } + RetrieveContext retrieveContext = new RetrieveContext(); + retrieveContext.setDataIds(new ArrayList(Arrays.asList(new String[]{dataID}))); + retrieveContext.setParam(param); + //① BeforeRetrieve + assemblyManager.getRetrieveAssembler().doBeforeRetrieve(getContext(), retrieveContext); + + //② DoRetrieve + assemblyManager.getRetrieveAssembler().doRetrieve(getContext(), retrieveContext); + if (retrieveContext.getRetrieveData() == null || retrieveContext.getRetrieveData().size() < 1) { + setResult(null); + return; + } + //③ DataMapping + DataMapperContext mapperContext = new DataMapperContext(); + mapperContext.setSourceData(retrieveContext.getRetrieveData()); + + ArrayList vmDatas = assemblyManager. + getDataMapperAssembler().doDataMapping2Vo(getContext(), mapperContext); + retrieveContext.setRetrieveResult(vmDatas); + //④ AfterRetrieve + assemblyManager.getRetrieveAssembler().doAfterRetrieve(getContext(), retrieveContext); + + setResult(vmDatas.get(0)); + auditLog(retrieveContext.getRetrieveData()); + } + private void auditLog(HashMap> vmDatas) { + if(getContext().getVoId()==null||getContext().getVoId().equals("")) + return; + + List list = SpringBeanUtils.getBean(BefAuditConfigService.class).getBefAuditConfigsByVoId(this.getContext().getVoId()); + + if(list==null||list.size()==0) + return; + for (BefAuditConfig config:list) + { + auditItem(config,vmDatas); + } + } + + private void auditItem(BefAuditConfig auditConfig, HashMap> vmDatas) { + if(auditConfig.getConfigItems()==null||auditConfig.getConfigItems().size()==0) + return; + for(var item:auditConfig.getConfigItems()) { + if("fQbpcO7bIEGoRdTZZIyrag".equals(item.getTargetVoActionId())==false) + continue; + GspAudit gspAudit = new GspAudit(); + gspAudit.setId(UUID.randomUUID().toString()); + gspAudit.setCategoryId(item.getAuditTypeId()); + gspAudit.setEventId(item.getAuditEventId()); + gspAudit.setDateTime(new Date()); + gspAudit.setType(AuditType.message); + gspAudit.setEventResult(EventResultType.success); + gspAudit.setGspAuditData(new ArrayList<>()); + gspAudit.setDescription(item.getAuditMessage().getAuditMessage()); + setAuditMessage(gspAudit,item,vmDatas); + if(CAFContext.current.getFrameworkContext()!=null) { + gspAudit.setFunctionId(CAFContext.current.getFrameworkContext().getFuncId()); + gspAudit.setFunctionCode(CAFContext.current.getFrameworkContext().getFuncCode()); + if (CAFContext.current.getFrameworkContext().getItems().containsKey("menuName")) + gspAudit.setFunctionName( + String.valueOf( + CAFContext.current.getFrameworkContext().getItems().get("menuName"))); + } + SpringBeanUtils.getBean(GspAuditManager.class).addAuditSync(gspAudit); + } + } + private void doDefaultRetrieve() { + if (param == null) { + RetrieveParam param = new RetrieveParam(); + param.setNeedLock(false); + } + + RespectiveRetrieveResult retriveResult = getLcp().retrieve(dataID, param); + if (retriveResult.getData() == null) { + setResult(null); + } else { + + IDataConvertor dataConvertor = getContext().getDataConvertor(); + + IEntityData vmData = getContext().createData(); + + dataConvertor.convertFromBEData(retriveResult.getData(), vmData); + setResult(vmData); + } + } + + private void setAuditMessage(GspAudit gspAudit, BefAuditConfigItem item, + HashMap> vmDatas) { + Map> auditMessageDataFields=new HashMap<>(); + Map>> childAuditMessageDataFields=new HashMap<>(); + AuditUtils + .getAuditMessageField(gspAudit,item,auditMessageDataFields,childAuditMessageDataFields); + for(Map.Entry> data:vmDatas.entrySet()) + { + if(data.getValue()!=null) + for(IEntityData dataItem :data.getValue()) + AuditUtils.addAuditMessageFieldValue(dataItem,"",auditMessageDataFields,childAuditMessageDataFields,this.getContext()); + } + AuditUtils.setAuditMessage(gspAudit,auditMessageDataFields,childAuditMessageDataFields); + } +} -- Gitee From 1012e7e2b6776782770e78b2305f9860f9c46891 Mon Sep 17 00:00:00 2001 From: qinxinyuan Date: Sat, 29 Oct 2022 11:22:11 +0800 Subject: [PATCH 66/81] =?UTF-8?q?=E6=A3=80=E7=B4=A2=E5=AD=90=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E7=9B=B8=E5=85=B3=E5=8A=A8=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/retrieve/RetrieveChildAction.java | 110 +++++++++++++++ .../retrieve/RetrieveChildAndChildAction.java | 118 ++++++++++++++++ .../retrieve/RetrieveChildByIndexAction.java | 128 ++++++++++++++++++ 3 files changed, 356 insertions(+) create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveChildAction.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveChildAndChildAction.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveChildByIndexAction.java diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveChildAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveChildAction.java new file mode 100644 index 0000000..80611c7 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveChildAction.java @@ -0,0 +1,110 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.retrieve; + +import com.inspur.edp.bef.api.parameter.retrieve.RespectiveRetrieveResult; +import com.inspur.edp.bef.api.parameter.retrieve.RetrieveParam; +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.api.extend.IBffEntityExtend; +import com.inspur.edp.bff.api.extend.IBffManagerExtend; +import com.inspur.edp.bff.spi.AbstractDataConvertor; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.entity.accessor.base.IAccessor; +import com.inspur.edp.cef.entity.accessor.entity.IEntityAccessor; +import com.inspur.edp.cef.entity.entity.IEntityData; +import lombok.var; + +import java.util.ArrayList; +public class RetrieveChildAction + extends AbstractFSAction +{ + private ArrayList nodeCodes; + private ArrayList lierachyIds; + private RetrieveParam retrieveParam; + + public RetrieveChildAction(ArrayList nodeCodes, ArrayList lierachyIds, RetrieveParam retrieveParam) { + this.nodeCodes = nodeCodes; + this.lierachyIds = lierachyIds; + this.retrieveParam = retrieveParam; + } + protected void execute() { + if (this.retrieveParam == null) { + this.retrieveParam=new RetrieveParam(); + } + RespectiveRetrieveResult retriveResult = getLcp().retrieveChild(this.nodeCodes, this.lierachyIds, this.retrieveParam); + if (retriveResult.getData() == null) { + setResult(null); + } else { + IEntityData vmData=null; + boolean isHasExtend=isExtend(); + if(!isHasExtend) + vmData = getContext().createData((String)this.nodeCodes.get(this.nodeCodes.size() - 1)); + else { + Object tempVar = getContext().getBffManager().createChildData(nodeCodes.get(nodeCodes.size() - 1), ""); + IEntityAccessor vmAccessor = (IEntityAccessor) ((tempVar instanceof IEntityAccessor) ? tempVar : null); + vmData= (IEntityData) ((vmAccessor.getInnerData() instanceof IEntityData) ? vmAccessor.getInnerData() : null); + } + IEntityData beData=retriveResult.getData(); + getDataConvertor().convertFromBEData(beData, vmData); + if(isHasExtend){ + dealExtendMapping(vmData,beData); + } + setResult(vmData); + } + } + + private boolean isExtend(){ + if(this.getContext().getExtList()==null || this.getContext().getExtList().size()==0) + return false; + return true; + } + private void dealExtendMapping(IEntityData voData,IEntityData beData){ + var extList = getContext().getExtList(); + if(extList == null || extList.size() < 1) + return ; + for (var ext : extList){ + IBffEntityExtend entityExtend = getChildEntityExtend(ext); + if(entityExtend != null) + entityExtend.mapData2Vo(voData, beData); + } + } + + private IBffEntityExtend getChildEntityExtend(IBffManagerExtend mgrExtend){ + + IBffEntityExtend entityExtend = mgrExtend.getDataTypeExtend(); + for (String nodeCode : nodeCodes) { + entityExtend = entityExtend.getChildEntity(nodeCode); + if(entityExtend == null) + break; + } + return entityExtend; + } + private AbstractDataConvertor getDataConvertor() { + IDataConvertor dataConvertor = getContext().getDataConvertor(); + AbstractDataConvertor rootConvertor = (AbstractDataConvertor)((dataConvertor instanceof AbstractDataConvertor) ? dataConvertor : null); + if (this.nodeCodes.isEmpty()) + { + return rootConvertor; + } + AbstractDataConvertor currentConvertor = rootConvertor; + for (int i = 0; i < this.nodeCodes.size(); i++) + { + currentConvertor = currentConvertor.getChildDataConvertor((String)this.nodeCodes.get(i)); + } + return currentConvertor; + } +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveChildAndChildAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveChildAndChildAction.java new file mode 100644 index 0000000..b9a64cf --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveChildAndChildAction.java @@ -0,0 +1,118 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.retrieve; + +import com.inspur.edp.bef.api.parameter.retrieve.RetrieveChildResult; +import com.inspur.edp.bef.api.parameter.retrieve.RetrieveParam; +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.api.extend.IBffEntityExtend; +import com.inspur.edp.bff.api.extend.IBffManagerExtend; +import com.inspur.edp.bff.spi.AbstractDataConvertor; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.entity.accessor.base.IAccessor; +import com.inspur.edp.cef.entity.accessor.entity.IEntityAccessor; +import com.inspur.edp.cef.entity.entity.IEntityData; +import lombok.var; + +import java.util.ArrayList; + +public class RetrieveChildAndChildAction extends AbstractFSAction> { + private ArrayList nodeCodes; + private ArrayList lierachyIds; + private RetrieveParam retrieveParam; + private ArrayList ids; + + public RetrieveChildAndChildAction(ArrayList nodeCodes, ArrayList lierachyIds, ArrayList ids,RetrieveParam retrieveParam) { + this.nodeCodes = nodeCodes; + this.lierachyIds = lierachyIds; + this.retrieveParam = retrieveParam; + this.ids=ids; + } + protected void execute() { + if (this.retrieveParam == null) { + this.retrieveParam=new RetrieveParam(); + } + if(ids==null ||ids.isEmpty()){ + + throw new RuntimeException("检索参数id列表不能为空,请重新输入!"); + } + RetrieveChildResult retriveResult = getLcp().retrieveChild(this.nodeCodes, this.lierachyIds, this.ids,this.retrieveParam); + ArrayList mapResult=new ArrayList<>(); + if (retriveResult.getDatas() == null) { + setResult(null); + return; + } + IEntityData vmData=null; + boolean isHasExtend =isExtend(); + for(IEntityData value : retriveResult.getDatas().values()){ + if(!isHasExtend) + vmData = getContext().createData((String)this.nodeCodes.get(this.nodeCodes.size() - 1)); + else { + Object tempVar = getContext().getBffManager().createChildData(nodeCodes.get(nodeCodes.size() - 1), ""); + IEntityAccessor vmAccessor = (IEntityAccessor) ((tempVar instanceof IEntityAccessor) ? tempVar : null); + vmData= (IEntityData) ((vmAccessor.getInnerData() instanceof IEntityData) ? vmAccessor.getInnerData() : null); + } + getDataConvertor().convertFromBEData(value, vmData); + if(isHasExtend){ + dealExtendMapping(vmData,value); + } + mapResult.add(vmData); + } + setResult(mapResult); + } + + private boolean isExtend(){ + if(this.getContext().getExtList()==null || this.getContext().getExtList().size()==0) + return false; + return true; + } + private void dealExtendMapping(IEntityData voData,IEntityData beData){ + var extList = getContext().getExtList(); + if(extList == null || extList.size() < 1) + return ; + for (var ext : extList){ + IBffEntityExtend entityExtend = getChildEntityExtend(ext); + if(entityExtend != null) + entityExtend.mapData2Vo(voData, beData); + } + } + + private IBffEntityExtend getChildEntityExtend(IBffManagerExtend mgrExtend){ + + IBffEntityExtend entityExtend = mgrExtend.getDataTypeExtend(); + for (String nodeCode : nodeCodes) { + entityExtend = entityExtend.getChildEntity(nodeCode); + if(entityExtend == null) + break; + } + return entityExtend; + } + private AbstractDataConvertor getDataConvertor() { + IDataConvertor dataConvertor = getContext().getDataConvertor(); + AbstractDataConvertor rootConvertor = (AbstractDataConvertor)((dataConvertor instanceof AbstractDataConvertor) ? dataConvertor : null); + if (this.nodeCodes.isEmpty()) + { + return rootConvertor; + } + AbstractDataConvertor currentConvertor = rootConvertor; + for (String nodeCode: nodeCodes) + { + currentConvertor = currentConvertor.getChildDataConvertor(nodeCode); + } + return currentConvertor; + } +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveChildByIndexAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveChildByIndexAction.java new file mode 100644 index 0000000..bcc6a1d --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveChildByIndexAction.java @@ -0,0 +1,128 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.retrieve; + +import com.inspur.edp.bef.api.parameter.retrieve.RetrieveParam; +import com.inspur.edp.bff.api.param.retrieve.RetrieveChildResult; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.entity.dependenceTemp.Pagination; +import com.inspur.edp.cef.entity.entity.IEntityData; +import com.inspur.edp.cef.entity.entity.IEntityDataCollection; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class RetrieveChildByIndexAction extends AbstractFSAction { + private ArrayList nodeCodes, hierachyIds; + private Pagination pagination; + + public RetrieveChildByIndexAction(ArrayList nodeCodes, ArrayList hierachyIds, Pagination pagination) { + this.nodeCodes = nodeCodes; + this.hierachyIds = hierachyIds; + this.pagination = pagination; + } + + @Override + protected void execute() { + nodeCodes = coverterNodeCode(nodeCodes); + if (nodeCodes == null || hierachyIds == null || nodeCodes.size() != hierachyIds.size() || pagination == null) + throw new RuntimeException("传入子表参数不正确"); + + IEntityData entityData = getContext().getBffManager().retrieve(hierachyIds.get(0), new RetrieveParam());//考虑是否加锁 + if (entityData == null) + throw new RuntimeException("未检索到主表数据,请假查!"); + + IEntityDataCollection childCollection = entityData.getChilds().get(nodeCodes.get(0)); + for (int i = 1; i < nodeCodes.size(); i++) { + if(childCollection.tryGet(hierachyIds.get(i))==null) + throw new RuntimeException("找不到要查找的数据,数据ID为:"+hierachyIds.get(i)); + childCollection = childCollection.tryGet(hierachyIds.get(i)).getChilds().get(nodeCodes.get(i)); + if (childCollection == null) + break; + } + if (childCollection != null && childCollection.size() > 0 && pagination.getPageSize() != 0)//超出索引返回最后一页 + { + Integer rem = childCollection.size() % pagination.getPageSize(); + Integer newIndexTemp = childCollection.size() / pagination.getPageSize(); + Integer index = rem == 0 ? newIndexTemp : newIndexTemp + 1; + if (pagination.getPageIndex() - index >= 1) { + pagination.setPageIndex(index); + } + } + for (IEntityData child : childCollection) { + for (Map.Entry data : child.getChilds().entrySet()) { + data.getValue().clear(); + } + } + setResult(GetDataByIndex(childCollection, pagination)); + } + + private ArrayList coverterNodeCode(ArrayList nodeCodes) { + ArrayList codes = new ArrayList<>(); + for (String code : nodeCodes) { + String voKey = getContext().getVoCode(code); + codes.add(voKey); + } + return codes; + } + + private RetrieveChildResult GetDataByIndex(IEntityDataCollection childData, Pagination pagination) { + int pageIndex = pagination.getPageIndex(); + if (pageIndex >= 1) { + int pageSize = pagination.getPageSize(); + + int otherCount = childData.size() - (pageIndex - 1) * pageSize; + int pageCount = pageIndex * pageSize; + if (otherCount < pageSize) + pageCount = childData.size(); + + Pagination pg = new Pagination(); + pg.setPageSize(pageSize); + pg.setTotalCount(childData.size()); + pg.setPageIndex(pageIndex); + if (pg.getPageSize() == 0)//要求0时返回所有 + { + pageIndex = 1; + pageCount = childData.size(); + } + int realPageCount = (int) Math.ceil((float) childData.size()/pageSize); + if(pageIndex>realPageCount) { + pageIndex=realPageCount; + pg.setPageIndex(pageIndex+1); + } + int startIndex = (pageIndex - 1) * pageSize; + if(startIndex<0) + startIndex=0; + List childDataNews = new ArrayList(childData).subList(startIndex, pageCount); + + return new RetrieveChildResult() { + { + setResult(new ArrayList<>(childDataNews)); + setPagination(pg); + } + }; + } + pagination.setTotalCount(childData.size()); + return new RetrieveChildResult() { + { + setResult(new ArrayList<>(childData)); + setPagination(pagination); + } + }; + } +} -- Gitee From be705f14985108309cfa4c014f21cb896b985f5c Mon Sep 17 00:00:00 2001 From: qinxinyuan Date: Sat, 29 Oct 2022 11:26:29 +0800 Subject: [PATCH 67/81] =?UTF-8?q?=E6=A3=80=E7=B4=A2=E7=B1=BB=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RetrieveDefaultAction.java | 142 ++++++++++++++++++ .../RetrieveDefaultBatchAction.java | 105 +++++++++++++ 2 files changed, 247 insertions(+) create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultAction.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultBatchAction.java diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultAction.java new file mode 100644 index 0000000..5ee3331 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultAction.java @@ -0,0 +1,142 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.retrievedefault; + +import com.inspur.edp.bff.api.dataprocessor.IDefaultValueConvertor; +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.assembler.IAssemblerManager; +import com.inspur.edp.bff.api.manager.context.DataMapperContext; +import com.inspur.edp.bff.api.manager.context.RetrieveDefaultContext; +import com.inspur.edp.bff.core.manager.FSManager; +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.bff.spi.builtin.BffEntityResInfoImpl; +import com.inspur.edp.bff.spi.builtin.BffModelResInfoImpl; +import com.inspur.edp.bff.spi.builtin.BffPropertyInfo; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import com.inspur.edp.cef.spi.entity.info.propertyinfo.DataTypePropertyInfo; +import com.inspur.edp.cef.spi.entity.resourceInfo.ModelResInfo; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefModelResInfoImpl; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +public class RetrieveDefaultAction extends AbstractFSAction { + + + private VoDefaultValue defaultValue; + private String dataId; + + public RetrieveDefaultAction() + { + } + + public RetrieveDefaultAction(VoDefaultValue defaultValue) + { + this.defaultValue = defaultValue; + } + + public RetrieveDefaultAction(String dataId) + { + this.dataId = dataId; + } + @Override + protected void execute() + { + IAssemblerManager assemblerManager = getContext().getAssemblerManager(); + if (assemblerManager == null) + { + doDefaultRetrieveDefault(); + return; + } + RetrieveDefaultContext createContext = new RetrieveDefaultContext(); + createContext.setVoDefaultValue(defaultValue); + createContext.setDataId(dataId); + //① BeforeRetrieve + assemblerManager.getRetrieveDefaultAssembler().doBeforeRetrieveDefault(getContext(), createContext); + + //② DoRetrieve + assemblerManager.getRetrieveDefaultAssembler().doRetrieveDefault(getContext(), createContext); + //③ DataMapping + DataMapperContext mapperContext = new DataMapperContext(); + mapperContext.setSourceData(createContext.getRetrieveDefaultData()); + mapperContext.setIsNew (true); + mapperContext.setVoDefaultValue(defaultValue); + ArrayList vmDatas = assemblerManager.getDataMapperAssembler(). + doDataMapping2Vo(getContext(), mapperContext); + + //处理虚拟字段默认值 + if(getModelInfo() instanceof BffModelResInfoImpl) { + dealVirtualDefaultValue(vmDatas.get(0), getContext()); + } + createContext.setRetrieveDefaultResult(vmDatas.get(0)); + //④ AfterRetrieve + assemblerManager.getRetrieveDefaultAssembler().doAfterRetrieveDefault(getContext(), createContext); + + setResult(vmDatas.get(0)); + } + private ModelResInfo getModelInfo(){ + return this.getContext().getModelResourceInfo(); + } + private void dealVirtualDefaultValue(IEntityData data, IFSManagerContext context) { + ModelResInfo modelResInfo=context.getModelResourceInfo(); + if(modelResInfo!=null &&modelResInfo instanceof CefModelResInfoImpl){ + BffEntityResInfoImpl resInfo = (BffEntityResInfoImpl)modelResInfo.getCustomResource(modelResInfo.getRootNodeCode()); + Map propertyInfos= resInfo.getEntityTypeInfo().getPropertyInfos(); + if(propertyInfos==null || propertyInfos.size()==0) + return; + dealDefalutValue(propertyInfos,data); + } + } + private void dealDefalutValue(Map propertyInfos,IEntityData data){ + for (Map.Entry propInfo:propertyInfos.entrySet()){ + String beLabelId=((BffPropertyInfo)(propInfo.getValue())).getBeLabelId(); + if(beLabelId!=null && !"".equals(beLabelId)) + continue; + if ((propInfo.getValue()).getDefaultValue() != null) { + data.setValue((propInfo.getValue()).getPropertyName(), (propInfo.getValue()).getDefaultValue().getRealValue()); + } + + } + } + private void doDefaultRetrieveDefault() + { + IEntityData beData; + + IDefaultValueConvertor convertor = getContext().getDefaultValueConvertor(); + if (defaultValue != null && convertor !=null) + { + + HashMap beDefault = convertor.convertFromVo(defaultValue); + beData = getLcp().retrieveDefault(beDefault); + } + else if (!(dataId==null||dataId.isEmpty())) + { + beData = getLcp().retrieveDefault(dataId); + } + else + { + beData = getLcp().retrieveDefault(); + } + + IEntityData vmData = getContext().createData(); + getContext().getDataConvertor().convertFromBEData(beData, vmData); + setResult(vmData); + } + +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultBatchAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultBatchAction.java new file mode 100644 index 0000000..69fe6fa --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultBatchAction.java @@ -0,0 +1,105 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.retrievedefault; + +import com.inspur.edp.bff.api.dataprocessor.IDefaultValueConvertor; +import com.inspur.edp.bff.api.manager.assembler.IAssemblerManager; +import com.inspur.edp.bff.api.manager.context.DataMapperContext; +import com.inspur.edp.bff.api.manager.context.RetrieveDefaultContext; +import com.inspur.edp.bff.entity.RetrieveDefaultParam; +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.ArrayList; +import java.util.HashMap; + +/** + * 批量新增主表数据 + */ +public class RetrieveDefaultBatchAction extends AbstractFSAction> { + + private RetrieveDefaultParam param; + public RetrieveDefaultBatchAction(RetrieveDefaultParam param) { + this.param=param; + } + + @Override + protected void execute() + { + ArrayList datas = new ArrayList<>(); + if(param.getVoDefaultValues() == null || param.getVoDefaultValues().size() ==0) + throw new RuntimeException("批量新增主表数据,默认值参数为空"); + IAssemblerManager assemblerManager = getContext().getAssemblerManager(); + if (assemblerManager == null) + { + doDefaultRetrieveDefault(); + return; + } + for(VoDefaultValue defaultValue: param.getVoDefaultValues()){ + RetrieveDefaultContext createContext = new RetrieveDefaultContext(); + createContext.setVoDefaultValue(defaultValue); + //todo wangmj +// createContext.setDataId(dataId); + //① BeforeRetrieve + assemblerManager.getRetrieveDefaultAssembler().doBeforeRetrieveDefault(getContext(), createContext); + + //② DoRetrieve + assemblerManager.getRetrieveDefaultAssembler().doRetrieveDefault(getContext(), createContext); + //③ DataMapping + DataMapperContext mapperContext = new DataMapperContext(); + mapperContext.setSourceData(createContext.getRetrieveDefaultData()); + mapperContext.setIsNew (true); + mapperContext.setVoDefaultValue(defaultValue); + ArrayList vmDatas = assemblerManager.getDataMapperAssembler(). + doDataMapping2Vo(getContext(), mapperContext); + createContext.setRetrieveDefaultResult(vmDatas.get(0)); + //④ AfterRetrieve + assemblerManager.getRetrieveDefaultAssembler().doAfterRetrieveDefault(getContext(), createContext); + datas.add(vmDatas.get(0)); + } + + + setResult(datas); + } + + private void doDefaultRetrieveDefault() + { + ArrayList datas = new ArrayList<>(); + for(VoDefaultValue defaultValue: param.getVoDefaultValues()){ + IEntityData beData; + IDefaultValueConvertor convertor = getContext().getDefaultValueConvertor(); + if (defaultValue != null && convertor !=null) + { + + HashMap beDefault = convertor.convertFromVo(defaultValue); + beData = getLcp().retrieveDefault(beDefault); + } + else + { + beData = getLcp().retrieveDefault(); + } + + IEntityData vmData = getContext().createData(); + getContext().getDataConvertor().convertFromBEData(beData, vmData); + datas.add(vmData); + } + + setResult(datas); + } + +} -- Gitee From e4b97d87313489130ff345c7368009497b165ae0 Mon Sep 17 00:00:00 2001 From: qinxinyuan Date: Sat, 29 Oct 2022 13:57:29 +0800 Subject: [PATCH 68/81] =?UTF-8?q?=E6=A3=80=E7=B4=A2=E7=B1=BB=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RetrieveDefaultChildAction.java | 283 ++++++++++++++++++ .../RetrieveDefaultChildeWithIdsAction.java | 170 +++++++++++ 2 files changed, 453 insertions(+) create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultChildAction.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultChildeWithIdsAction.java diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultChildAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultChildAction.java new file mode 100644 index 0000000..1d98fe6 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultChildAction.java @@ -0,0 +1,283 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.retrievedefault; + +import com.inspur.edp.bef.api.lcp.IStandardLcp; +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.api.extend.IBffEntityExtend; +import com.inspur.edp.bff.api.extend.IBffManagerExtend; +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.spi.AbstractDataConvertor; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.bff.spi.builtin.BffEntityResInfoImpl; +import com.inspur.edp.bff.spi.builtin.BffModelResInfoImpl; +import com.inspur.edp.bff.spi.builtin.BffPropertyInfo; +import com.inspur.edp.bff.spi.defaultvalue.DefaultValueUtil; +import com.inspur.edp.cef.api.changeListener.EntityDataChangeListener; +import com.inspur.edp.cef.api.dataType.entity.ICefEntity; +import com.inspur.edp.cef.entity.accessor.entity.IEntityAccessor; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import com.inspur.edp.cef.entity.changeset.ModifyChangeDetail; +import com.inspur.edp.cef.entity.entity.ICefData; +import com.inspur.edp.cef.entity.entity.IEntityData; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.DataTypePropertyInfo; +import com.inspur.edp.cef.spi.entity.resourceInfo.ModelResInfo; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefEntityResInfoImpl; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefModelResInfoImpl; +import java.util.List; +import java.util.Map; +import lombok.var; + +import java.util.ArrayList; +import java.util.HashMap; + +public class RetrieveDefaultChildAction extends AbstractFSAction { + + private ArrayList nodeCodes; + private ArrayList lierachyIds; + + public RetrieveDefaultChildAction(ArrayList nodeCodes, ArrayList lierachyIds) { + this.nodeCodes = nodeCodes; + this.lierachyIds = lierachyIds; + } + + @Override + protected void execute() { + IEntityData beData; + ModelResInfo modelResInfo=this.getModelInfo(); + if(modelResInfo instanceof BffModelResInfoImpl){ + Map defaultValues=new HashMap<>(); + initDefaultValue(getContext().getBffManager(),getLcp(),defaultValues,nodeCodes); + beData = getLcp().retrieveDefaultChild(nodeCodes, lierachyIds,defaultValues); + }else { + beData = getLcp().retrieveDefaultChild(nodeCodes, lierachyIds); + } + AbstractDataConvertor dataConvertor = getDataConvertor(nodeCodes); + Object tempVar = getContext().getBffManager().createChildData(nodeCodes.get(nodeCodes.size() - 1), ""); + + IEntityAccessor vmAccessor = (IEntityAccessor) ((tempVar instanceof IEntityAccessor) ? tempVar : null); + + IEntityData voData = (IEntityData) ((vmAccessor.getInnerData() instanceof IEntityData) ? vmAccessor.getInnerData() : null); + + if (dataConvertor != null) + dataConvertor.convertFromBEData(beData, voData); + + //region extend + dealExtendMapping(voData, beData); + + + vmAccessor.setInnerData(voData); + if(!(modelResInfo instanceof BffModelResInfoImpl)) { + dealDefaultValue(vmAccessor); + } + IEntityData result = (IEntityData) ((vmAccessor.getInnerData() instanceof IEntityData) ? vmAccessor.getInnerData() : null); + //默认值 + if(modelResInfo instanceof BffModelResInfoImpl){ + dealVirtualDefaultValue(result,getContext()); + } + setResult(result); + } + private ModelResInfo getModelInfo(){ + return this.getContext().getModelResourceInfo(); + } + private void dealVirtualDefaultValue(IEntityData data, IFSManagerContext context) { + ModelResInfo modelResInfo=context.getModelResourceInfo(); + if(modelResInfo!=null &&modelResInfo instanceof CefModelResInfoImpl && ((CefModelResInfoImpl) modelResInfo).getEntityResInfos().containsKey(nodeCodes.get(nodeCodes.size()-1).toLowerCase())){ + BffEntityResInfoImpl resInfo = (BffEntityResInfoImpl)modelResInfo.getCustomResource(nodeCodes.get(nodeCodes.size()-1)); + Map propertyInfos= resInfo.getEntityTypeInfo().getPropertyInfos(); + if(propertyInfos==null || propertyInfos.size()==0) + return; + for (Map.Entry propInfo:propertyInfos.entrySet()){ + String beLabelId=((BffPropertyInfo)(propInfo.getValue())).getBeLabelId(); + if(beLabelId!=null && !"".equals(beLabelId)) + continue; + if ((propInfo.getValue()).getDefaultValue() != null) { + data.setValue((propInfo.getValue()).getPropertyName(), (propInfo.getValue()).getDefaultValue().getRealValue()); + } + + } + } + } + + public void mergeDefaultValue(Map outerValue,Map innerDefaultValue){ + if (outerValue==null || outerValue.size()==0) + return; + for (Map.Entry defaultValue:outerValue.entrySet()){ + innerDefaultValue.put(defaultValue.getKey(),defaultValue.getValue()); + } + } + private void initDefaultValue(IFSManager manager, IStandardLcp lcp,Map values,ArrayList nodeCodes) { + List extendList=manager.getBffContext().getExtList(); + ModelResInfo modelResInfo=getContext().getBffManager().getModelInfo(); + if(modelResInfo instanceof CefModelResInfoImpl && ((CefModelResInfoImpl)modelResInfo).getEntityResInfos().containsKey(nodeCodes.get(nodeCodes.size()-1).toLowerCase())){ + initBasicDefaultValue(manager,lcp,values,nodeCodes); + if(extendList==null ||extendList.size()==0) + return; + initChangedDefaultValue(manager,lcp,values,extendList,nodeCodes); + mapExtendDefaultValue(manager,extendList,values,nodeCodes); + return; + } + mapExtendDefaultValue(manager,extendList,values,nodeCodes); + } + + private void mapExtendDefaultValue(IFSManager manager,List extendList,Map values,ArrayList nodeCodes) { + Map extendDefaultValues=new HashMap<>(); + Map beDefaultValues=new HashMap<>(); + for (IBffManagerExtend bffManagerExtend:extendList){ + IBffEntityExtend bffEntityExtend=getChildEntityExtend(bffManagerExtend); + if(bffEntityExtend!=null){ + //VO扩展默认值 + initExtendDefaultValue(manager,bffEntityExtend,extendDefaultValues,nodeCodes); + //转换扩展默认值 + bffEntityExtend.mapDefaultValuesFromVo(extendDefaultValues,beDefaultValues); + //合并默认值 + } + } + mergeDefaultValue(beDefaultValues,values); + } + + private void initExtendDefaultValue(IFSManager manager, IBffEntityExtend extend, Map values,ArrayList nodeCodes) { + CefEntityResInfoImpl entityResInfo=extend.getEntityResInfo(); + if(entityResInfo==null || entityResInfo.getEntityTypeInfo()==null|| entityResInfo.getEntityTypeInfo().getPropertyInfos()==null) + return; + for (Map.Entry propInfo:entityResInfo.getEntityTypeInfo().getPropertyInfos().entrySet() ){ + DataTypePropertyInfo propertyInfo=propInfo.getValue(); + if(propertyInfo.getDefaultValue()==null ||("".equals(propertyInfo.getDefaultValue().getRealValue()) ||propertyInfo.getDefaultValue().getRealValue()==null)) + continue; + DefaultValueUtil.dealExtendValue(manager,propertyInfo,nodeCodes,values); + } + } + private void initBasicDefaultValue(IFSManager manager,IStandardLcp lcp, Map values,ArrayList nodeCodes){ + CefEntityResInfoImpl resInfo= (CefEntityResInfoImpl) manager.getModelInfo().getCustomResource(nodeCodes.get(nodeCodes.size()-1)); + if(resInfo.getEntityTypeInfo()==null ||resInfo.getEntityTypeInfo().getPropertyInfos()==null|| resInfo.getEntityTypeInfo().getPropertyInfos().size()==0) + return ; + dealPropDefaultValue(manager,lcp,resInfo.getEntityTypeInfo().getPropertyInfos(),values,nodeCodes); + } + private void initChangedDefaultValue(IFSManager manager, IStandardLcp lcp,Map values,List extendList,ArrayList nodeCodes){ + for (IBffManagerExtend bffManagerExtend:extendList){ + IBffEntityExtend entityExtend = getChildEntityExtend(bffManagerExtend); + dealChangePropertyValue(manager,lcp,entityExtend,values,nodeCodes); + } + } + + private void dealChangePropertyValue(IFSManager manager,IStandardLcp lcp,IBffEntityExtend bffEntityDataExtend,Map values,ArrayList nodeCodes) { + bffEntityDataExtend.mapChangedDefaultValuesFromVo(manager,lcp,nodeCodes,values); + } + + private void dealPropDefaultValue(IFSManager manager, IStandardLcp lcp,Map prpertyInfos,Map values,ArrayList nodeCodes){ + for (Map.Entry propertyInfo:prpertyInfos.entrySet()){ + DataTypePropertyInfo propertyInfoTemp=propertyInfo.getValue(); + String beLabelId=((BffPropertyInfo)propertyInfoTemp).getBeLabelId(); + if(defaultValueIsNull(propertyInfoTemp)) + continue; + if(beLabelId==null || "".equals(beLabelId)) + continue; + DefaultValueUtil.dealDefaultValue(manager,lcp,propertyInfoTemp,nodeCodes,values); + } + } + private boolean defaultValueIsNull(DataTypePropertyInfo propertyInfo) { + if(propertyInfo.getDefaultValue()==null) + return true; + Object value=propertyInfo.getDefaultValue().getRealValue(); + if(value==null ||"".equals(value)) + return true; + return false; + } + private void dealExtendMapping(IEntityData voData,IEntityData beData){ + var extList = getContext().getExtList(); + if(extList == null || extList.size() < 1) + return ; + for (var ext : extList){ + IBffEntityExtend entityExtend = getChildEntityExtend(ext); + if(entityExtend != null) + entityExtend.mapData2Vo(voData, beData); + } + } + + private IBffEntityExtend getChildEntityExtend(IBffManagerExtend mgrExtend){ + + IBffEntityExtend entityExtend = mgrExtend.getDataTypeExtend(); + for (String nodeCode : + nodeCodes) { + entityExtend = entityExtend.getChildEntity(nodeCode); + if(entityExtend == null) + break; + } + return entityExtend; + } + + + private void dealDefaultValue(IEntityAccessor vmAccessor) { + + IEntityData voData = (IEntityData) ((vmAccessor.getInnerData() instanceof IEntityData) ? vmAccessor.getInnerData() : null); + + EntityDataChangeListener listener = EntityDataChangeListener.createInstance(); + listener.registListener((ICefData) ((vmAccessor instanceof ICefData) ? vmAccessor : null)); + ICefEntity entinty = getEntity(voData.getID()); + entinty.assignDefaultValue(vmAccessor); + + + IChangeDetail defalutChange = listener.getChange(); + if (defalutChange != null) { + ModifyChangeDetail beChange = getChangeDetail((ModifyChangeDetail) ((defalutChange instanceof ModifyChangeDetail) ? defalutChange : null)); + getContext().getBffManager().modify(beChange); + } + } + + private ModifyChangeDetail getChangeDetail(ModifyChangeDetail defaultChange) { + IChangeDetail tempVar = defaultChange.clone(); + + ModifyChangeDetail currentChange = (ModifyChangeDetail) ((tempVar instanceof ModifyChangeDetail) ? tempVar : null); + for (int i = lierachyIds.size() - 1; i >= 0; i--) { + + String nodeCode = nodeCodes.get(i); + ModifyChangeDetail change = new ModifyChangeDetail(lierachyIds.get(i)); + HashMap childChange = new HashMap(); + childChange.put(currentChange.getDataID(), currentChange); + change.getChildChanges().put(nodeCode, childChange); + IChangeDetail tempVar2 = change.clone(); + currentChange = (ModifyChangeDetail) ((tempVar2 instanceof ModifyChangeDetail) ? tempVar2 : null); + } + + return currentChange; + } + + private ICefEntity getEntity(String childId) { + ICefEntity currentEntity = getContext().getBffManager().createEntity(lierachyIds.get(0)); + for (int i = 0; i < nodeCodes.size(); i++) { + currentEntity = currentEntity.getChildEntity(nodeCodes.get(i), i == nodeCodes.size() - 1 ? childId : lierachyIds.get(i + 1)); + } + + return currentEntity; + } + + private AbstractDataConvertor getDataConvertor(ArrayList nodesCodes) { + IDataConvertor tempVar = getContext().getDataConvertor(); + AbstractDataConvertor rootConvertor = (AbstractDataConvertor) ((tempVar instanceof AbstractDataConvertor) ? tempVar : null); + if (nodeCodes.isEmpty()) { + return rootConvertor; + } + AbstractDataConvertor currentConvertor = rootConvertor; + for (int i = 0; i < nodeCodes.size(); i++) { + currentConvertor = (AbstractDataConvertor) currentConvertor.getChildConvertor(nodeCodes.get(i)); + if (currentConvertor == null) + break; + } + return currentConvertor; + } +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultChildeWithIdsAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultChildeWithIdsAction.java new file mode 100644 index 0000000..f51c441 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultChildeWithIdsAction.java @@ -0,0 +1,170 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.retrievedefault; + + +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.api.dataprocessor.IDefaultValueConvertor; +import com.inspur.edp.bff.api.extend.IBffEntityExtend; +import com.inspur.edp.bff.api.extend.IBffManagerExtend; +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; +import com.inspur.edp.bff.spi.AbstractDataConvertor; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.changeListener.EntityDataChangeListener; +import com.inspur.edp.cef.api.dataType.entity.ICefEntity; +import com.inspur.edp.cef.entity.accessor.entity.IEntityAccessor; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import com.inspur.edp.cef.entity.changeset.ModifyChangeDetail; +import com.inspur.edp.cef.entity.entity.ICefData; +import com.inspur.edp.cef.entity.entity.IEntityData; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import lombok.var; + +public class RetrieveDefaultChildeWithIdsAction extends AbstractFSAction> { + + private ArrayList nodeCodes; + private ArrayList lierachyIds; + private ArrayList ids; + + public RetrieveDefaultChildeWithIdsAction(ArrayList nodeCodes, ArrayList lierachyIds, ArrayList ids) { + + this.nodeCodes = nodeCodes; + this.lierachyIds = lierachyIds; + this.ids = ids; + + } + + + @Override + protected void execute() { + if(ids==null ||ids.size()==0) + throw new RuntimeException("批量新增时,id列表不能为空!"); + + ArrayList dataList=new ArrayList<>(ids.size()); + + Map beDatas=getLcp().retrieveDefaultChild(nodeCodes,lierachyIds,ids); + for(Map.Entry dataEntry:beDatas.entrySet()){ + IEntityData beData=dataEntry.getValue(); + Object tempVar = getContext().getBffManager().createChildData(nodeCodes.get(nodeCodes.size() - 1), ""); + IEntityAccessor vmAccessor = (IEntityAccessor) ((tempVar instanceof IEntityAccessor) ? tempVar : null); + IEntityData voData = (IEntityData) ((vmAccessor.getInnerData() instanceof IEntityData) ? vmAccessor.getInnerData() : null); + + transBeDataToVoData(beData,voData); + //region extend + dealExtendMapping(voData, beData); + + + vmAccessor.setInnerData(voData); + + dealDefaultValue(vmAccessor); + IEntityData result = (IEntityData) ((vmAccessor.getInnerData() instanceof IEntityData) ? vmAccessor.getInnerData() : null); + dataList.add(result); + } + setResult(dataList); + } + + private IEntityData transBeDataToVoData(IEntityData beData,IEntityData voData){ + + IDataConvertor dataConvertor=getDataConvertor(nodeCodes); + if(dataConvertor!=null) + + dataConvertor.convertFromBEData(beData, voData); + + return voData; + } + + private void dealDefaultValue(IEntityAccessor vmAccessor) { + + IEntityData voData = (IEntityData) ((vmAccessor.getInnerData() instanceof IEntityData) ? vmAccessor.getInnerData() : null); + + EntityDataChangeListener listener = EntityDataChangeListener.createInstance(); + listener.registListener((ICefData) ((vmAccessor instanceof ICefData) ? vmAccessor : null)); + ICefEntity entinty = getEntity(voData.getID()); + entinty.assignDefaultValue(vmAccessor); + + + IChangeDetail defalutChange = listener.getChange(); + if (defalutChange != null) { + ModifyChangeDetail beChange = getChangeDetail((ModifyChangeDetail) ((defalutChange instanceof ModifyChangeDetail) ? defalutChange : null)); + getContext().getBffManager().modify(beChange); + } + } + + private void dealExtendMapping(IEntityData voData, IEntityData beData) { + var extList = getContext().getExtList(); + if(extList == null || extList.size() < 1) + return ; + for (var ext : extList){ + IBffEntityExtend entityExtend = getChildEntityExtend(ext); + if(entityExtend != null) + entityExtend.mapData2Vo(voData, beData); + } + } + + private IBffEntityExtend getChildEntityExtend(IBffManagerExtend mgrExtend) { + IBffEntityExtend entityExtend = mgrExtend.getDataTypeExtend(); + for (String nodeCode : nodeCodes) { + entityExtend = entityExtend.getChildEntity(nodeCode); + if(entityExtend == null) + break; + } + return entityExtend; + } + + private ModifyChangeDetail getChangeDetail(ModifyChangeDetail defaultChange) { + IChangeDetail tempVar = defaultChange.clone(); + + ModifyChangeDetail currentChange = (ModifyChangeDetail) ((tempVar instanceof ModifyChangeDetail) ? tempVar : null); + for (int i = lierachyIds.size() - 1; i >= 0; i--) { + + String nodeCode = nodeCodes.get(i); + ModifyChangeDetail change = new ModifyChangeDetail(lierachyIds.get(i)); + HashMap childChange = new HashMap(); + childChange.put(currentChange.getDataID(), currentChange); + change.getChildChanges().put(nodeCode, childChange); + IChangeDetail tempVar2 = change.clone(); + currentChange = (ModifyChangeDetail) ((tempVar2 instanceof ModifyChangeDetail) ? tempVar2 : null); + } + + return currentChange; + } + private ICefEntity getEntity(String childId) { + ICefEntity currentEntity = getContext().getBffManager().createEntity(lierachyIds.get(0)); + for (int i = 0; i < nodeCodes.size(); i++) { + currentEntity = currentEntity.getChildEntity(nodeCodes.get(i), i == nodeCodes.size() - 1 ? childId : lierachyIds.get(i + 1)); + } + + return currentEntity; + } + private IDataConvertor getDataConvertor(ArrayList nodeCodes) { + IDataConvertor tempVar = getContext().getDataConvertor(); + AbstractDataConvertor rootConvertor = (AbstractDataConvertor) ((tempVar instanceof AbstractDataConvertor) ? tempVar : null); + if (nodeCodes.isEmpty()) { + return rootConvertor; + } + AbstractDataConvertor currentConvertor = rootConvertor; + for (int i = 0; i < nodeCodes.size(); i++) { + currentConvertor = (AbstractDataConvertor) currentConvertor.getChildConvertor(nodeCodes.get(i)); + if (currentConvertor == null) + break; + } + return currentConvertor; + } + +} -- Gitee From fd54ef48dc07f27100833bb8bc42de6a55af30ff Mon Sep 17 00:00:00 2001 From: qinxinyuan Date: Sat, 29 Oct 2022 14:25:36 +0800 Subject: [PATCH 69/81] =?UTF-8?q?=E6=A3=80=E7=B4=A2=E7=B1=BB=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ieveDefaultChildWithDefaultValueAtion.java | 167 ++++++++++++++++++ ...efaultChildWithDefaultValueBatchAtion.java | 47 +++++ 2 files changed, 214 insertions(+) create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultChildWithDefaultValueAtion.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultChildWithDefaultValueBatchAtion.java diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultChildWithDefaultValueAtion.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultChildWithDefaultValueAtion.java new file mode 100644 index 0000000..63193ed --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultChildWithDefaultValueAtion.java @@ -0,0 +1,167 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.retrievedefault; + +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.api.dataprocessor.IDefaultValueConvertor; +import com.inspur.edp.bff.api.extend.IBffEntityExtend; +import com.inspur.edp.bff.api.extend.IBffManagerExtend; +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; +import com.inspur.edp.bff.spi.AbstractDataConvertor; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.changeListener.EntityDataChangeListener; +import com.inspur.edp.cef.api.dataType.entity.ICefEntity; +import com.inspur.edp.cef.entity.accessor.entity.IEntityAccessor; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import com.inspur.edp.cef.entity.changeset.ModifyChangeDetail; +import com.inspur.edp.cef.entity.entity.ICefData; +import com.inspur.edp.cef.entity.entity.IEntityData; +import java.util.ArrayList; +import java.util.HashMap; +import lombok.var; + +public class RetrieveDefaultChildWithDefaultValueAtion extends AbstractFSAction { + + private ArrayList nodeCodes; + private ArrayList lierachyIds; + private VoDefaultValue defaultValue; + public RetrieveDefaultChildWithDefaultValueAtion(ArrayList nodeCodes, ArrayList lierachyIds, VoDefaultValue defaultValue) { + this.nodeCodes=nodeCodes; + this.lierachyIds=lierachyIds; + this.defaultValue=defaultValue; + + } + + + @Override + protected void execute() { + + IDefaultValueConvertor valueConvertor=getDefaultValueConvertor(); + + IEntityData beData=getLcp().retrieveDefaultChild(nodeCodes,lierachyIds,valueConvertor.convertFromVo(defaultValue)); + + Object tempVar = getContext().getBffManager().createChildData(nodeCodes.get(nodeCodes.size() - 1), ""); + IEntityAccessor vmAccessor = (IEntityAccessor) ((tempVar instanceof IEntityAccessor) ? tempVar : null); + IEntityData voData = (IEntityData) ((vmAccessor.getInnerData() instanceof IEntityData) ? vmAccessor.getInnerData() : null); + + transBeDataToVoData(beData,voData); + //region extend + dealExtendMapping(voData, beData); + + + vmAccessor.setInnerData(voData); + + dealDefaultValue(vmAccessor); + IEntityData result = (IEntityData) ((vmAccessor.getInnerData() instanceof IEntityData) ? vmAccessor.getInnerData() : null); + + setResult(result); + } + + private IDefaultValueConvertor getDefaultValueConvertor() { + + return getContext().getDefaultValueConvertor(); + } + + private IEntityData transBeDataToVoData(IEntityData beData,IEntityData voData){ + + IDataConvertor dataConvertor=getDataConvertor(nodeCodes); + if(dataConvertor!=null) + + dataConvertor.convertFromBEData(beData, voData); + + return voData; + } + + private void dealDefaultValue(IEntityAccessor vmAccessor) { + + IEntityData voData = (IEntityData) ((vmAccessor.getInnerData() instanceof IEntityData) ? vmAccessor.getInnerData() : null); + + EntityDataChangeListener listener = EntityDataChangeListener.createInstance(); + listener.registListener((ICefData) ((vmAccessor instanceof ICefData) ? vmAccessor : null)); + ICefEntity entinty = getEntity(voData.getID()); + entinty.assignDefaultValue(vmAccessor); + + + IChangeDetail defalutChange = listener.getChange(); + if (defalutChange != null) { + ModifyChangeDetail beChange = getChangeDetail((ModifyChangeDetail) ((defalutChange instanceof ModifyChangeDetail) ? defalutChange : null)); + getContext().getBffManager().modify(beChange); + } + } + + private void dealExtendMapping(IEntityData voData, IEntityData beData) { + var extList = getContext().getExtList(); + if(extList == null || extList.size() < 1) + return ; + for (var ext : extList){ + IBffEntityExtend entityExtend = getChildEntityExtend(ext); + if(entityExtend != null) + entityExtend.mapData2Vo(voData, beData); + } + } + + private IBffEntityExtend getChildEntityExtend(IBffManagerExtend mgrExtend) { + IBffEntityExtend entityExtend = mgrExtend.getDataTypeExtend(); + for (String nodeCode : nodeCodes) { + entityExtend = entityExtend.getChildEntity(nodeCode); + if(entityExtend == null) + break; + } + return entityExtend; + } + + private ModifyChangeDetail getChangeDetail(ModifyChangeDetail defaultChange) { + IChangeDetail tempVar = defaultChange.clone(); + + ModifyChangeDetail currentChange = (ModifyChangeDetail) ((tempVar instanceof ModifyChangeDetail) ? tempVar : null); + for (int i = lierachyIds.size() - 1; i >= 0; i--) { + + String nodeCode = nodeCodes.get(i); + ModifyChangeDetail change = new ModifyChangeDetail(lierachyIds.get(i)); + HashMap childChange = new HashMap(); + childChange.put(currentChange.getDataID(), currentChange); + change.getChildChanges().put(nodeCode, childChange); + IChangeDetail tempVar2 = change.clone(); + currentChange = (ModifyChangeDetail) ((tempVar2 instanceof ModifyChangeDetail) ? tempVar2 : null); + } + + return currentChange; + } + private ICefEntity getEntity(String childId) { + ICefEntity currentEntity = getContext().getBffManager().createEntity(lierachyIds.get(0)); + for (int i = 0; i < nodeCodes.size(); i++) { + currentEntity = currentEntity.getChildEntity(nodeCodes.get(i), i == nodeCodes.size() - 1 ? childId : lierachyIds.get(i + 1)); + } + + return currentEntity; + } + private IDataConvertor getDataConvertor(ArrayList nodeCodes) { + IDataConvertor tempVar = getContext().getDataConvertor(); + AbstractDataConvertor rootConvertor = (AbstractDataConvertor) ((tempVar instanceof AbstractDataConvertor) ? tempVar : null); + if (nodeCodes.isEmpty()) { + return rootConvertor; + } + AbstractDataConvertor currentConvertor = rootConvertor; + for (int i = 0; i < nodeCodes.size(); i++) { + currentConvertor = (AbstractDataConvertor) currentConvertor.getChildConvertor(nodeCodes.get(i)); + if (currentConvertor == null) + break; + } + return currentConvertor; + } + +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultChildWithDefaultValueBatchAtion.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultChildWithDefaultValueBatchAtion.java new file mode 100644 index 0000000..6212d95 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultChildWithDefaultValueBatchAtion.java @@ -0,0 +1,47 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.retrievedefault; + +import com.inspur.edp.bff.entity.RetrieveDefaultParam; +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.entity.entity.IEntityData; +import java.util.ArrayList; +import javassist.CodeConverter.DefaultArrayAccessReplacementMethodNames; + +public class RetrieveDefaultChildWithDefaultValueBatchAtion extends AbstractFSAction> { + + private ArrayList nodeCodes; + private ArrayList lierachyIds; + private RetrieveDefaultParam param; + public RetrieveDefaultChildWithDefaultValueBatchAtion(ArrayList nodeCodes, + ArrayList lierachyIds, RetrieveDefaultParam param) { + this.nodeCodes=nodeCodes; + this.lierachyIds=lierachyIds; + this.param=param; + } + + @Override + protected void execute() { + ArrayList data=new ArrayList<>(); + if(param.getVoDefaultValues().size()>0 ){ + data=getContext().getBffManager().retrieveDefaultChilds(nodeCodes,lierachyIds,param.getVoDefaultValues()); + } + setResult(data); + + } +} -- Gitee From f13e0944a908b5edfbbe755bf4f8f14a5bd54066 Mon Sep 17 00:00:00 2001 From: qinxinyuan Date: Sat, 29 Oct 2022 14:42:06 +0800 Subject: [PATCH 70/81] =?UTF-8?q?=E6=A3=80=E7=B4=A2=E7=B1=BB=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RetrieveWithChildPaginationAction.java | 124 +++++++++++++++++ .../RetrieveDefaultWithChildAction.java | 129 ++++++++++++++++++ 2 files changed, 253 insertions(+) create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveWithChildPaginationAction.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultWithChildAction.java diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveWithChildPaginationAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveWithChildPaginationAction.java new file mode 100644 index 0000000..48615ca --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveWithChildPaginationAction.java @@ -0,0 +1,124 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.retrieve; + +import com.inspur.edp.bff.api.param.retrieve.RetrieveParam; +import com.inspur.edp.bff.api.param.retrieve.RetrieveResult; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.entity.dependenceTemp.Pagination; +import com.inspur.edp.cef.entity.entity.EntityDataCollection; +import com.inspur.edp.cef.entity.entity.IEntityData; +import com.inspur.edp.cef.entity.entity.IEntityDataCollection; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class RetrieveWithChildPaginationAction extends AbstractFSAction { + private String dataId; + private RetrieveParam param; + + public RetrieveWithChildPaginationAction(String dataId, RetrieveParam param) { + this.dataId = dataId; + this.param = param; + } + + @Override + protected void execute() { + if (param == null) + throw new RuntimeException("传入参数params不能为空。"); + if (dataId == null || "".equals(dataId)) + throw new RuntimeException("传入的dataId不能为空"); + IEntityData entityData = getContext().getBffManager().retrieve(dataId); + if (entityData == null) + return; + HashMap pageResult = new HashMap<>(); + BuildChildData(entityData, param, dataId, pageResult); + setResult(getRetrieveResult(entityData, pageResult)); + } + + private void BuildChildData(IEntityData baseData, RetrieveParam params, String id, HashMap pageResult) { + HashMap entityDatas = baseData.getChilds(); + IEntityDataCollection childData = null; + + for (String frontKey : params.getFilters().keySet()) { + String voKey = getContext().getVoCode(frontKey); + childData = entityDatas.get(voKey); + if (childData == null || childData.size() <= 0) { + continue; + } + Pagination pagination = params.getFilters().get(frontKey).getPagination(); + if (pagination.getPageSize() == 0)//分页个数=0时要求返回所有 + { + continue; + } + if (pagination.getPageIndex() <= 0) { + throw new RuntimeException("每页索引不允许小于1,请检查!"); + } + int pageIndex = pagination.getPageIndex(); + int pageSize = pagination.getPageSize(); + Pagination pagination1 = new Pagination(); + pagination1.setPageIndex(pageIndex); + pagination1.setPageSize(pageSize); + pagination1.setTotalCount(childData.size()); + int realPageCount = (int) Math.ceil((float) childData.size()/pageSize); + if(pageIndex>realPageCount) { + pageIndex=realPageCount; + } + int otherCount = childData.size() - (pageIndex - 1) * pageSize; + int pageCount = pageIndex * pageSize; + if (otherCount < pageSize) { + pageCount = childData.size(); + } + List childDataNews = new ArrayList(childData).subList((pageIndex - 1) * pageSize, pageCount); + childData.clear(); + baseData.mergeChildData(voKey, new ArrayList<>(childDataNews)); +// for(int i =0;i entityDataCollectionEntry:data.getChilds().entrySet()) { +// entityDataCollectionEntry.getValue().clear(); +// } +// } + pageResult.put(frontKey + "_" + id, pagination1); + + } + for (IEntityDataCollection datas : entityDatas.values()) { + for (IEntityData data : datas) { + BuildChildData(data, params, data.getID(), pageResult); + } + } + } + + private RetrieveResult getRetrieveResult(IEntityData baseData, HashMap pageResult) { + RetrieveResult retrieveResult = new RetrieveResult(); + retrieveResult.setResult(baseData); + retrieveResult.setPagination(pageResult); + return retrieveResult; + } +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultWithChildAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultWithChildAction.java new file mode 100644 index 0000000..505e46f --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrievedefault/RetrieveDefaultWithChildAction.java @@ -0,0 +1,129 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.retrievedefault; + +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.api.dataprocessor.IDefaultValueConvertor; +import com.inspur.edp.bff.api.extend.IBffEntityExtend; +import com.inspur.edp.bff.api.extend.IBffManagerExtend; +import com.inspur.edp.bff.api.manager.assembler.IAssemblerManager; +import com.inspur.edp.bff.api.manager.context.DataMapperContext; +import com.inspur.edp.bff.api.manager.context.RetrieveDefaultContext; +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; +import com.inspur.edp.bff.spi.AbstractDataConvertor; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.changeListener.EntityDataChangeListener; +import com.inspur.edp.cef.api.dataType.entity.ICefEntity; +import com.inspur.edp.cef.entity.accessor.entity.IEntityAccessor; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import com.inspur.edp.cef.entity.changeset.ModifyChangeDetail; +import com.inspur.edp.cef.entity.entity.ICefData; +import com.inspur.edp.cef.entity.entity.IEntityData; +import lombok.var; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +public class RetrieveDefaultWithChildAction extends AbstractFSAction { + + + private VoDefaultValue defaultValue; + private String dataId; + private LinkedHashMap childCount; + + public RetrieveDefaultWithChildAction(VoDefaultValue defaultValue, LinkedHashMap childCount) + { + this.defaultValue = defaultValue; + this.childCount = childCount; + } + + @Override + protected void execute() + { + IAssemblerManager assemblerManager = getContext().getAssemblerManager(); + if (assemblerManager == null) + { + doDefaultRetrieveDefault(); + return; + } + RetrieveDefaultContext createContext = new RetrieveDefaultContext(); + createContext.setVoDefaultValue(defaultValue); + createContext.setDataId(dataId); + //① BeforeRetrieve + assemblerManager.getRetrieveDefaultAssembler().doBeforeRetrieveDefault(getContext(), createContext); + + //② DoRetrieve + assemblerManager.getRetrieveDefaultAssembler().doRetrieveDefault(getContext(), createContext); + //③ DataMapping + DataMapperContext mapperContext = new DataMapperContext(); + mapperContext.setSourceData(createContext.getRetrieveDefaultData()); + mapperContext.setIsNew (true); + mapperContext.setVoDefaultValue(defaultValue); + ArrayList vmDatas = assemblerManager.getDataMapperAssembler(). + doDataMapping2Vo(getContext(), mapperContext); + createContext.setRetrieveDefaultResult(vmDatas.get(0)); + //④ AfterRetrieve + assemblerManager.getRetrieveDefaultAssembler().doAfterRetrieveDefault(getContext(), createContext); + retrieveChild(vmDatas.get(0)); + setResult(vmDatas.get(0)); + } + + private void retrieveChild(IEntityData vmData){ + for(Map.Entry entry: childCount.entrySet()){ + ArrayList nodeCodes = new ArrayList<>(); + ArrayList lierachyIds = new ArrayList<>(); + nodeCodes.add(entry.getKey().toString()); + lierachyIds.add(vmData.getID()); + RetrieveDefaultChildAction childAction = new RetrieveDefaultChildAction(nodeCodes, lierachyIds); + int count = Integer.parseInt(entry.getValue().toString()); + for(int i=0; i beDefault = convertor.convertFromVo(defaultValue); + beData = getLcp().retrieveDefault(beDefault); + } + else if (!(dataId==null||dataId.isEmpty())) + { + beData = getLcp().retrieveDefault(dataId); + } + else + { + beData = getLcp().retrieveDefault(); + } + + IEntityData vmData = getContext().createData(); + getContext().getDataConvertor().convertFromBEData(beData, vmData); + setResult(vmData); + } + + +} -- Gitee From da9bba6051a6bd5d8e4571b68942c9fca47001e6 Mon Sep 17 00:00:00 2001 From: qinxinyuan Date: Sat, 29 Oct 2022 14:46:36 +0800 Subject: [PATCH 71/81] =?UTF-8?q?vo=E5=AE=9E=E4=BD=93=E7=B1=BB=E4=B8=8E?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=8A=A8=E4=BD=9C=E7=B1=BB=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../edp/bff/core/action/save/SaveAction.java | 65 ++++++++++++ .../edp/bff/core/entity/ViewObjectEntity.java | 98 +++++++++++++++++++ .../core/session/SessionItemRecoverImpl.java | 68 +++++++++++++ 3 files changed, 231 insertions(+) create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/save/SaveAction.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/entity/ViewObjectEntity.java create mode 100644 bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/SessionItemRecoverImpl.java diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/save/SaveAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/save/SaveAction.java new file mode 100644 index 0000000..5ea1360 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/save/SaveAction.java @@ -0,0 +1,65 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.action.save; + +import com.inspur.edp.bef.api.action.VoidActionResult; +import com.inspur.edp.bef.api.lcp.IStandardLcp; +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.bff.api.manager.assembler.IAssemblerManager; +import com.inspur.edp.bff.api.manager.context.SaveContext; +import com.inspur.edp.bff.api.manager.context.TimeStampContext; +import com.inspur.edp.bff.spi.AbstractFSAction; + +public class SaveAction extends AbstractFSAction { + + + public SaveAction() + { + } + + @Override + protected void execute() + { + IAssemblerManager assemblerManager = getContext().getAssemblerManager(); + if (assemblerManager == null) + { + executeSave(); + return; + } + + SaveContext saveContext = new SaveContext(); + + //① BeforeSave + assemblerManager.getSaveAssembler().doBeforeSave(getContext(), saveContext); + + executeSave(); + //② AfterSave + assemblerManager.getSaveAssembler().doAfterSave(getContext(), saveContext); + } + + private void executeSave() + { + //获取外部服务传过来的上下文信息 + TimeStampContext context=getContext().getBffManager().getTimeStampContext(); + + for (IStandardLcp lcp : getContext().getLcps().values()) + { + lcp.getBefContext().setEnableTimeStampLastModifiedBy(context.isEnableTimeStampLastModifiedBy()); + lcp.save(); + } + } +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/entity/ViewObjectEntity.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/entity/ViewObjectEntity.java new file mode 100644 index 0000000..69d2a1a --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/entity/ViewObjectEntity.java @@ -0,0 +1,98 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.entity; + +import com.inspur.edp.cef.api.dataType.entity.ICefEntity; +import com.inspur.edp.cef.api.dataType.entity.ICefRootEntity; +import com.inspur.edp.cef.core.datatype.CefEntity; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import com.inspur.edp.cef.entity.entity.IEntityData; +import lombok.var; +import sun.reflect.generics.reflectiveObjects.NotImplementedException; + +import java.util.Objects; + +public class ViewObjectEntity extends CefEntity implements ICefRootEntity { + + + public ViewObjectEntity(String dataId) + { + this.id = dataId; + } + @Override + public void modify(IChangeDetail change) + { + throw new NotImplementedException(); + } + + @Override + public ICefEntity getChildEntity(String code, String id) + { + Objects.requireNonNull(code); + + if (extList != null) { + for(var ext : extList) { + var addedChild = ext.getAddedChilds(); + if(addedChild == null || addedChild.isEmpty()){ + continue; + } + var child = addedChild.stream().filter(item -> code.equals(item.getNodeCode())).findFirst(); + if(child.isPresent()){ + return child.get().createEntity(id); + } + } + } + + var child = (ViewObjectEntity)innerGetChildEntity(code, id); + //TODO: 增加从从表暂不支持 +// if (extList != null) { +// child.setExtend( +// extList.stream().map(item -> item.getChildEntity(code)) +// .filter(item -> item != null) +// .collect(Collectors.toList())); +// } + return child; + } + + protected ICefEntity innerGetChildEntity(String code, String id){ + throw new RuntimeException("此方法应在子类中重写"); + } + + private String id; + @Override + public String getID() + { + return id; + } +// public final IEntityData retrieve() +// { +// +// } + + @Override + public IEntityData retrieveData() { + throw new NotImplementedException(); + } + +// //region [运行时定制]扩展 +// private List extList; +// +// public final void setExtend(List extList) { +// this.extList = extList; +// } + +} diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/SessionItemRecoverImpl.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/SessionItemRecoverImpl.java new file mode 100644 index 0000000..6666194 --- /dev/null +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/session/SessionItemRecoverImpl.java @@ -0,0 +1,68 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.core.session; + + +import com.inspur.edp.bff.api.manager.IFSManagerFactory; +import com.inspur.edp.bff.core.manager.FSManager; +import com.inspur.edp.cef.api.session.ICefSession; +import com.inspur.edp.cef.entity.accessor.base.IAccessor; +import com.inspur.edp.commonmodel.core.session.SessionItemRecover; +import com.inspur.edp.commonmodel.core.session.distributed.dac.FuncSessionItemIncrement; +import com.inspur.edp.commonmodel.core.variable.VarBufferManager; +import io.iec.edp.caf.commons.utils.SpringBeanUtils; +import org.springframework.util.StringUtils; + +public class SessionItemRecoverImpl implements SessionItemRecover { + + private static IFSManagerFactory factory; + + static { + factory = SpringBeanUtils.getBean(IFSManagerFactory.class); + } + + @Override + public BffSessionItem buildSessionItem(ICefSession session, String configId) { + FSManager lcp = (FSManager) factory.getFSManagerByVOId(configId); + return lcp.buildSessionItem(); + } + + @Override + public void incrementBeforeReset(BffSessionItem item, FuncSessionItemIncrement increment) { + increment4Variable(item, increment); +// increment4WeakVariables(item, increment); + } + + @Override + public void incrementAfterReset(BffSessionItem item, FuncSessionItemIncrement increment) { + incrementBeforeReset(item, increment); + } + + @Override + public void reset(BffSessionItem bffSessionItem) { + } + + private void increment4Variable(BffSessionItem item, FuncSessionItemIncrement increment) { + if (StringUtils.isEmpty(increment.getVarChangeString())) { + return; + } + VarBufferManager manager = item.getVarBufferManager(); + //TODO: 调试看看只读data变不变 + ((IAccessor) manager.getCurrentData()) + .acceptChange(manager.getVarManager().deserializeChange(increment.getVarChangeString())); + } +} -- Gitee From 336ab9ad889ee399da45c7499b1059025dbf0aa0 Mon Sep 17 00:00:00 2001 From: Jakeem Date: Sun, 30 Oct 2022 07:19:56 +0800 Subject: [PATCH 72/81] =?UTF-8?q?1.=20=E6=B7=BB=E5=8A=A0=E4=BA=86retrieve?= =?UTF-8?q?=E5=92=8C=E9=BB=98=E8=AE=A4retrieve=E7=9A=84Listener=E5=92=8CBr?= =?UTF-8?q?oker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../retrieve/BffRetrieveEventBroker.java | 150 +++++++++++++++++ .../retrieve/IBffRetrieveEventListener.java | 73 ++++++++ .../BffRetrieveDefaultEventBroker.java | 156 ++++++++++++++++++ .../IBffRetrieveDefaultEventListener.java | 77 +++++++++ 4 files changed, 456 insertions(+) create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/retrieve/BffRetrieveEventBroker.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/retrieve/IBffRetrieveEventListener.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/retrievedefault/BffRetrieveDefaultEventBroker.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/retrievedefault/IBffRetrieveDefaultEventListener.java diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/retrieve/BffRetrieveEventBroker.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/retrieve/BffRetrieveEventBroker.java new file mode 100644 index 0000000..3e211c7 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/retrieve/BffRetrieveEventBroker.java @@ -0,0 +1,150 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.event.retrieve; + +import com.inspur.edp.bef.api.lcp.AuthInfo; +import com.inspur.edp.bef.api.parameter.retrieve.RetrieveParam; +import com.inspur.edp.bff.api.manager.IFSAction; +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.context.QueryContext; +import com.inspur.edp.bff.api.manager.context.RetrieveContext; +import com.inspur.edp.cef.entity.condition.EntityFilter; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class BffRetrieveEventBroker { + private static List eventLs = new ArrayList() {{ + //add(getBffRetrieveEventListener("com.inspur.edp.bff.debugtool.listener.impl.retrieve.BffRetrieveEventListener")); + }}; + private static IBffRetrieveEventListener getBffRetrieveEventListener(String className){ + try { + Class cls=Class.forName(className); + IBffRetrieveEventListener listener= (IBffRetrieveEventListener) cls.newInstance(); + return listener; + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { + throw new RuntimeException("listener实例初始化失败",e); + } + + } + public static final void fireBeforeRetrieve(IFSManager manager, List dataIds, RetrieveParam retrieveParam) { + for (IBffRetrieveEventListener el : eventLs) { +// el.beforeRetrieve(manager, dataIds, retrieveParam); + } + } + + public static final void fireAfterRetrieve(IFSManager manager,List data) { + for (IBffRetrieveEventListener el : eventLs) { +// el.afterRetrieve(manager, data); + } + } + + + public static final void fireBeforeTotalJSQAssembler(RetrieveContext retrievecontext) { + for (IBffRetrieveEventListener el : eventLs) { +// el.beforeTotalJSQAssembler(retrievecontext); + } + } + + public static final void fireBeforeJSQAssembler(IFSAction beforeaction, RetrieveContext retrievecontext, IFSManagerContext bffcontext) { + for (IBffRetrieveEventListener el : eventLs) { +// el.beforeJSQAssembler(beforeaction,retrievecontext,bffcontext); + } + } + + public static final void fireAfterJSQAssembler(IFSManagerContext bffcontext, RetrieveContext retrievecontext) { + for (IBffRetrieveEventListener el : eventLs) { +// el.afterJSQAssembler(bffcontext,retrievecontext); + } + } + + public static final void fireAfterTotalJSQAssembler(IFSManagerContext bffcontext, RetrieveContext retrievecontext, int TotalCount) { + for (IBffRetrieveEventListener el : eventLs) { +// el.afterTotalJSQAssembler(bffcontext,retrievecontext, TotalCount); + } + } + + public static final void fireBeforeTotalCoreRetrieve(RetrieveContext retrieveContext) { + for (IBffRetrieveEventListener el : eventLs) { +// el.beforeTotalCoreRetrieve(retrieveContext); + } + } + + + public static final void fireBeforeCoreRetrieve(IFSAction queryaction,RetrieveContext retrieveContext, IFSManagerContext context) { + for (IBffRetrieveEventListener el : eventLs) { +// el.beforeCoreRetrieve(queryaction,retrieveContext,context); + } + } + + + + public static final void fireAfterCoreRetrieve(IFSManagerContext context, RetrieveContext retrieveContext) { + for (IBffRetrieveEventListener el : eventLs) { +// el.afterCoreRetrieve(context,retrieveContext); + } + } + + + public static final void fireAfterTotalCoreRetrieve(IFSManagerContext context, RetrieveContext retrieveContext, int TotalCount) { + for (IBffRetrieveEventListener el : eventLs) { +// el.afterTotalCoreRetrieve(context,retrieveContext, TotalCount); + } + } + + public static final void fireBeforeTotalJSHAssembler(RetrieveContext retrievecontext, IFSManagerContext bffcontext) { + for (IBffRetrieveEventListener el : eventLs) { +// el.beforeTotalJSHAssembler(retrievecontext,bffcontext); + } + } + + + public static final void fireBeforeJSHAssembler(IFSAction jshassm, RetrieveContext retrievecontext, IFSManagerContext bffcontext) { + for (IBffRetrieveEventListener el : eventLs) { +// el.beforeJSHAssembler(jshassm,retrievecontext,bffcontext); + } + } + + public static final void fireAfteJSHAssembler(RetrieveContext retrievecontext, IFSManagerContext bffcontext) { + for (IBffRetrieveEventListener el : eventLs) { +// el.afterJSHAssembler(retrievecontext, bffcontext); + } + } + + public static final void fireAfterTotalJSHAssembler(RetrieveContext retrievecontext, IFSManagerContext bffcontext, int TotalCount) { + for (IBffRetrieveEventListener el : eventLs) { +// el.afterTotalJSHAssembler(retrievecontext, bffcontext, TotalCount); + } + } + + public static final void fireAfterQuery(IFSManagerContext context, EntityFilter filter, List result) { + for (IBffRetrieveEventListener el : eventLs) { + el.afterQuery(context, filter, result); + } + } + public static final void fireQueryUnnormalStop(Exception e) { + for (IBffRetrieveEventListener el : eventLs) { + el.queryUnnormalStop(e); + } + } + + + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/retrieve/IBffRetrieveEventListener.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/retrieve/IBffRetrieveEventListener.java new file mode 100644 index 0000000..5dc4a5c --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/retrieve/IBffRetrieveEventListener.java @@ -0,0 +1,73 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.event.retrieve; + +import com.inspur.edp.bef.api.lcp.AuthInfo; +import com.inspur.edp.bef.api.parameter.retrieve.RetrieveParam; +import com.inspur.edp.bff.api.manager.IFSAction; +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.bff.api.manager.context.QueryContext; +import com.inspur.edp.cef.entity.condition.EntityFilter; +import com.inspur.edp.cef.entity.entity.IEntityData; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public interface IBffRetrieveEventListener { + public void beforeRetrieve(IFSManagerContext bffcontext, ArrayList dataIds, RetrieveParam retrieveParam); + + //检索前扩展动作 + public void beforeTotalCXQAssembler(QueryContext querycontext); + + public void beforeCXQAssembler(IFSAction beforeaction, QueryContext querycontext, IFSManagerContext bffcontext); + + public void afterCXQAssembler(IFSManagerContext bffcontext, QueryContext queryContext); + + public void afterTotalCXQAssembler(IFSManagerContext bffcontext, QueryContext queryContext, int TotalCount); + + //查询 + public void beforeWKZTotalCoreQuery(EntityFilter filter); + + public void afterWKZTotalCoreQuery(IFSManagerContext bffcontext, List queryResult, List vmdatas); + + public void beforeTotalCoreQuery(QueryContext querycontext); + + public void beforeCoreQuery(IFSAction queryaction, QueryContext querycontext, IFSManagerContext bffcontext); + + public void processGetAuth(AuthInfo auth, String auvoid, String auconfigid); + + public void afterCoreQuery(IFSManagerContext context, HashMap> queryResult, QueryContext queryContext); + + public void afterTotalCoreQuery(IFSManagerContext context, HashMap> queryResult, QueryContext queryContext, int TotalCount); + + + + //查询后扩展动作 + public void beforeTotalCXHAssembler(QueryContext queryContext, IFSManagerContext bffcontext); + + public void beforeCXHAssembler(IFSAction cxhassembler, QueryContext queryContext, IFSManagerContext bffcontext); + + public void afterCXHAssembler(QueryContext queryContext, IFSManagerContext bffcontext); + + public void afterTotalCXHAssembler(QueryContext queryContext, IFSManagerContext bffcontext, int TotalCount); + + public void afterQuery(IFSManagerContext context, EntityFilter filter, List result); + + public void queryUnnormalStop(Exception e); + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/retrievedefault/BffRetrieveDefaultEventBroker.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/retrievedefault/BffRetrieveDefaultEventBroker.java new file mode 100644 index 0000000..db6d664 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/retrievedefault/BffRetrieveDefaultEventBroker.java @@ -0,0 +1,156 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.event.retrievedefault; + +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.bff.api.manager.context.RetrieveDefaultContext; +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.bff.spi.action.retrievedefault.AbstractRetrieveDefaultAction; +import com.inspur.edp.bff.spi.action.retrievedefault.AfterRetrieveDefaultAction; +import com.inspur.edp.bff.spi.action.retrievedefault.BeforeRetrieveDefaultAction; +import com.inspur.edp.cef.entity.entity.IEntityData; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.DataTypePropertyInfo; +import java.util.ArrayList; +import java.util.List; + +public class BffRetrieveDefaultEventBroker { + private static List eventLs = new ArrayList() {{ + //add(getBffEventListener("com.inspur.edp.bff.debugtool.listener.impl.retrievedefault.BffRetrieveDefaultEventListener")); + }}; + private static IBffRetrieveDefaultEventListener getBffEventListener(String className){ + try { + Class cls=Class.forName(className); + IBffRetrieveDefaultEventListener listener= (IBffRetrieveDefaultEventListener) cls.newInstance(); + return listener; + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { + throw new RuntimeException("listener实例初始化失败",e); + } + + } + + public static final void fireBeforeRetrieveDefault(IFSManager manager, VoDefaultValue defaultValue,String dataId) { + for (IBffRetrieveDefaultEventListener el : eventLs) { + el.beforeRetrieveDefault(manager,defaultValue,dataId); + } + } + public static final void fireAfterRetrieveDefault(IFSManager manager,IEntityData data) { + for (IBffRetrieveDefaultEventListener el : eventLs) { + el.afterRetrieveDefault(manager,data); + } + } + + public static final void fireExceptionStop(Exception e){ + for (IBffRetrieveDefaultEventListener el : eventLs) { + el.exceptionStop(e); + } + } + + public static final void fireB4BeforeRetrieveDefaultAction(IFSManager manager,AbstractFSAction action,RetrieveDefaultContext retrieveDefaultContext){ + for (IBffRetrieveDefaultEventListener el : eventLs) { + el. beforeRetrieveDefaultAction( manager,action,retrieveDefaultContext); + } + } + public static final void fireAfterBeforeRetrieveDefaultAction(IFSManager manager,RetrieveDefaultContext retrieveDefaultContext){ + for (IBffRetrieveDefaultEventListener el : eventLs) { + el. afterRetrieveDefaultAction( manager,retrieveDefaultContext); + } + } + public static final void fireB4ExecuteRetrieveDefaultActions(IFSManager manager,ArrayList actions){ + for (IBffRetrieveDefaultEventListener el : eventLs) { + el. beforeExecuteRetrieveDefaultActions( manager,actions); + } + } + public static final void fireAfterExecuteRetrieveDefaultActions(IFSManager manager,ArrayList actions){ + for (IBffRetrieveDefaultEventListener el : eventLs) { + el. afterExecuteRetrieveDefaultActions( manager,actions); + } + } + public static final void fireB4AfterRetrieveDefaultAction(IFSManager manager,AbstractFSAction action,RetrieveDefaultContext retrieveDefaultContext){ + for (IBffRetrieveDefaultEventListener el : eventLs) { + el. beforeAfterRetrieveDefaultAction( manager,action,retrieveDefaultContext); + } + } + public static final void fireAfterAfterRetrieveDefaultAction(IFSManager manager,RetrieveDefaultContext retrieveDefaultContext){ + for (IBffRetrieveDefaultEventListener el : eventLs) { + el. afterAfterRetrieveDefaultAction( manager,retrieveDefaultContext); + } + } + public static final void fireB4ExecuteAfterRetrieveDefaultActions(IFSManager manager,ArrayList actions){ + for (IBffRetrieveDefaultEventListener el : eventLs) { + el. beforeExecuteAfterRetrieveDefaultActions( manager,actions); + } + } + public static final void fireAfterExecuteAfterRetrieveDefaultActions(IFSManager manager,ArrayList actions){ + for (IBffRetrieveDefaultEventListener el : eventLs) { + el. afterExecuteAfterRetrieveDefaultActions( manager,actions); + } + } + public static final void fireB4AbstractRetrieveDefaultAction(IFSManager manager,AbstractFSAction action,RetrieveDefaultContext retrieveDefaultContext){ + for (IBffRetrieveDefaultEventListener el : eventLs) { + el. beforeAbstractRetrieveDefaultAction( manager,action,retrieveDefaultContext); + } + } + public static final void fireAfterAbstractRetrieveDefaultAction(IFSManager manager,RetrieveDefaultContext retrieveDefaultContext){ + for (IBffRetrieveDefaultEventListener el : eventLs) { + el. afterAbstractRetrieveDefaultAction( manager,retrieveDefaultContext); + } + } + public static final void fireB4ExecuteAbstractRetrieveDefaultActions(IFSManager manager,ArrayList actions){ + for (IBffRetrieveDefaultEventListener el : eventLs) { + el. beforeExecuteAbstractRetrieveDefaultActions( manager,actions); + } + } + public static final void fireAfterExecuteAbstractRetrieveDefaultActions(IFSManager manager,ArrayList actions){ + for (IBffRetrieveDefaultEventListener el : eventLs) { + el. afterAbstractRetrieveDefaultActions( manager,actions); + } + } + public static final void fireBeforeRetrieveDefaultChild(IFSManager manager,ArrayList nodeCodes, ArrayList lierachyIds,ArrayList ids, + ArrayList defaultValues){ + for (IBffRetrieveDefaultEventListener el : eventLs) { + el. beforeRetrieveDefaultChild( manager,nodeCodes,lierachyIds,ids,defaultValues); + } + } + public static final void fireAfterRetrieveDefaultChild(IFSManager manager,ArrayList childData,ArrayList nodeCodes){ + for (IBffRetrieveDefaultEventListener el : eventLs) { + el. afterRetrieveDfaultChild( manager,childData,nodeCodes); + } + } + + public static final void fireBeforeDefaultValue(IFSManager manager,VoDefaultValue defaultValue){ + for (IBffRetrieveDefaultEventListener el : eventLs) { + el. beforeDefaultValue( manager,defaultValue); + } + } + public static final void fireAfterDefaultValue(IFSManager manager,ArrayList data){ + for (IBffRetrieveDefaultEventListener el : eventLs) { + el. afterDefaultValue( manager,data); + } + } + public static final void fireBeforeMetaDefaultValue(IFSManager manager, DataTypePropertyInfo propertyInfo){ + for (IBffRetrieveDefaultEventListener el : eventLs) { + el. beforeMetaDefaultValue( manager,propertyInfo); + } + } + public static final void firAfterMetaDefaultValue(IFSManager manager, ArrayList data){ + for (IBffRetrieveDefaultEventListener el : eventLs) { + el. afterMetaDefaultValue( manager,data); + } + } + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/retrievedefault/IBffRetrieveDefaultEventListener.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/retrievedefault/IBffRetrieveDefaultEventListener.java new file mode 100644 index 0000000..8d3b6c1 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/event/retrievedefault/IBffRetrieveDefaultEventListener.java @@ -0,0 +1,77 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.event.retrievedefault; + + +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.bff.api.manager.context.RetrieveDefaultContext; +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.bff.spi.action.retrievedefault.AbstractRetrieveDefaultAction; +import com.inspur.edp.bff.spi.action.retrievedefault.AfterRetrieveDefaultAction; +import com.inspur.edp.bff.spi.action.retrievedefault.BeforeRetrieveDefaultAction; +import com.inspur.edp.cef.entity.entity.IEntityData; +import com.inspur.edp.cef.spi.entity.info.propertyinfo.DataTypePropertyInfo; +import java.util.ArrayList; + +public interface IBffRetrieveDefaultEventListener { + void beforeRetrieveDefault(IFSManager manager, VoDefaultValue defaultValue, String dataId); + + void afterRetrieveDefault(IFSManager manager, IEntityData data); + + void beforeExecuteRetrieveDefaultActions(IFSManager manager,ArrayList actions); + + void beforeRetrieveDefaultAction(IFSManager manager, AbstractFSAction action, + RetrieveDefaultContext retrieveDefaultContext); + + void afterRetrieveDefaultAction(IFSManager manager, RetrieveDefaultContext retrieveDefaultContext); + + void afterExecuteRetrieveDefaultActions(IFSManager manager,ArrayList actions); + + void beforeExecuteAfterRetrieveDefaultActions(IFSManager manager,ArrayList actions); + + void beforeAfterRetrieveDefaultAction(IFSManager manager, AbstractFSAction action, + RetrieveDefaultContext retrieveDefaultContext); + + void afterAfterRetrieveDefaultAction(IFSManager manager, RetrieveDefaultContext retrieveDefaultContext); + + void afterExecuteAfterRetrieveDefaultActions(IFSManager manager,ArrayList actions); + + void beforeExecuteAbstractRetrieveDefaultActions(IFSManager manager,ArrayList actions); + + void beforeAbstractRetrieveDefaultAction(IFSManager manager, AbstractFSAction action, + RetrieveDefaultContext retrieveDefaultContext); + + void afterAbstractRetrieveDefaultAction(IFSManager manager, RetrieveDefaultContext retrieveDefaultContext); + + void afterAbstractRetrieveDefaultActions(IFSManager manager,ArrayList actions); + + void beforeRetrieveDefaultChild(IFSManager manager,ArrayList nodeCodes, ArrayList lierachyIds,ArrayList ids, + ArrayList defaultValues); + + void afterRetrieveDfaultChild(IFSManager manager,ArrayList data,ArrayList nodeCodes); + + void beforeDefaultValue(IFSManager manager,VoDefaultValue defaultValue); + + void afterDefaultValue(IFSManager manager,ArrayList data); + + void beforeMetaDefaultValue(IFSManager manager, DataTypePropertyInfo propertyInfo); + + void afterMetaDefaultValue(IFSManager manager,ArrayList data); + + void exceptionStop(Exception e); +} -- Gitee From 800e0a7b5028d62f0c293031b6db897432383107 Mon Sep 17 00:00:00 2001 From: Jakeem Date: Sun, 30 Oct 2022 08:37:16 +0800 Subject: [PATCH 73/81] =?UTF-8?q?1.=20=E5=AE=9E=E4=BD=93=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E5=92=8C=E5=AD=90=E5=AE=9E=E4=BD=93=E6=89=A9=E5=B1=95=E7=AD=89?= =?UTF-8?q?=E5=AE=9E=E4=BD=93=E7=B1=BB=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractBffAddedChildDataExtend.java | 23 ++++++++++++ .../AbstractBffAddedChildEntityExtend.java | 23 ++++++++++++ .../extend/AbstractBffEntityDataExtend.java | 26 ++++++++++++++ .../spi/extend/AbstractBffEntityExtend.java | 25 +++++++++++++ .../spi/extend/AbstractBffManagerExtend.java | 24 +++++++++++++ .../edp/bff/spi/extend/AddHelpExtend.java | 36 +++++++++++++++++++ 6 files changed, 157 insertions(+) create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffAddedChildDataExtend.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffAddedChildEntityExtend.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffEntityDataExtend.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffEntityExtend.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffManagerExtend.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AddHelpExtend.java diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffAddedChildDataExtend.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffAddedChildDataExtend.java new file mode 100644 index 0000000..30bfae7 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffAddedChildDataExtend.java @@ -0,0 +1,23 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.extend; + +import com.inspur.edp.commonmodel.spi.extendimpl.AbstractCMAddedChildDataExtend; + +public abstract class AbstractBffAddedChildDataExtend extends AbstractCMAddedChildDataExtend { + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffAddedChildEntityExtend.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffAddedChildEntityExtend.java new file mode 100644 index 0000000..4bf1b8f --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffAddedChildEntityExtend.java @@ -0,0 +1,23 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.extend; + +import com.inspur.edp.commonmodel.spi.extendimpl.AbstractCMAddedChildEntityExtend; + +public abstract class AbstractBffAddedChildEntityExtend extends AbstractCMAddedChildEntityExtend { + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffEntityDataExtend.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffEntityDataExtend.java new file mode 100644 index 0000000..0e82b73 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffEntityDataExtend.java @@ -0,0 +1,26 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.extend; + +import com.inspur.edp.bff.api.extend.IBffEntityDataExtend; +import com.inspur.edp.commonmodel.spi.extendimpl.AbstractCMEntityDataExtend; + +public abstract class AbstractBffEntityDataExtend + extends AbstractCMEntityDataExtend + implements IBffEntityDataExtend { + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffEntityExtend.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffEntityExtend.java new file mode 100644 index 0000000..1e62e1b --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffEntityExtend.java @@ -0,0 +1,25 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.extend; + +import com.inspur.edp.bff.api.extend.IBffEntityExtend; +import com.inspur.edp.commonmodel.spi.extendimpl.AbstractCMEntityExtend; + +public abstract class AbstractBffEntityExtend extends AbstractCMEntityExtend implements + IBffEntityExtend { + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffManagerExtend.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffManagerExtend.java new file mode 100644 index 0000000..99ae36c --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AbstractBffManagerExtend.java @@ -0,0 +1,24 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.extend; + +import com.inspur.edp.bff.api.extend.IBffManagerExtend; +import com.inspur.edp.commonmodel.spi.extendimpl.AbstractCMEntityManagerExtend; + +public abstract class AbstractBffManagerExtend extends AbstractCMEntityManagerExtend implements + IBffManagerExtend { +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AddHelpExtend.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AddHelpExtend.java new file mode 100644 index 0000000..59c4696 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/extend/AddHelpExtend.java @@ -0,0 +1,36 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.extend; + +import com.inspur.edp.bff.api.extend.IVMHelpExtendInfo; +import com.inspur.edp.bff.spi.VMHelpConfig; + +public class AddHelpExtend implements IVMHelpExtendInfo { + + private VMHelpConfig config; + + public AddHelpExtend(VMHelpConfig config){ + this.config = config; + } + + public VMHelpConfig getAddedHelpConfig(){ + return config; + } + public void setAddedHelpConfig(VMHelpConfig value){ + this.config = value; + } +} -- Gitee From cd3285653c257e67cedc646db878a6693a419d20 Mon Sep 17 00:00:00 2001 From: Jakeem Date: Sun, 30 Oct 2022 08:50:05 +0800 Subject: [PATCH 74/81] =?UTF-8?q?1.=20=E6=B7=BB=E5=8A=A0=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bff/spi/gencommon/FsConfigManager.java | 73 +++++++++++++++++++ .../edp/bff/spi/i18n/ViewModelMgrInfo.java | 22 ++++++ .../inspur/edp/bff/spi/i18n/VoEntityInfo.java | 22 ++++++ .../inspur/edp/bff/spi/i18n/VoPropInfo.java | 22 ++++++ .../edp/bff/spi/i18n/VoRefPropInfo.java | 22 ++++++ 5 files changed, 161 insertions(+) create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/gencommon/FsConfigManager.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/i18n/ViewModelMgrInfo.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/i18n/VoEntityInfo.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/i18n/VoPropInfo.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/i18n/VoRefPropInfo.java diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/gencommon/FsConfigManager.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/gencommon/FsConfigManager.java new file mode 100644 index 0000000..d2bea6c --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/gencommon/FsConfigManager.java @@ -0,0 +1,73 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.gencommon; + +import com.inspur.edp.cef.entity.config.CefConfig; +import com.inspur.edp.cef.gencommon.config.CefConfigManager; +import com.inspur.edp.formserver.viewmodel.extendinfo.api.GspVoExtendInfoService; +import com.inspur.edp.formserver.viewmodel.extendinfo.entity.GspVoExtendInfo; +import com.inspur.edp.lcm.metadata.api.entity.ProcessMode; +import io.iec.edp.caf.commons.utils.SpringBeanUtils; + +import javax.persistence.NonUniqueResultException; + + +public class FsConfigManager extends CefConfigManager { + + private static FsConfigManager instance; + + public static FsConfigManager getInstance() { + if (instance == null) + instance = new FsConfigManager(); + return instance; + } + +// @Override + protected String getConfigFilePath() { + return "fs_runtime.json"; + } + +// @Override + protected String getConfigType() { + return "BFF"; + } + + @Override + protected CefConfig getCefConfigByDb(String configId) { + GspVoExtendInfoService gspVoExtendInfoService = SpringBeanUtils.getBean(GspVoExtendInfoService.class); + // 通过id获取 + GspVoExtendInfo voExisting = gspVoExtendInfoService.getVoExtendInfoByConfigId(configId); + if (voExisting == null) { + voExisting = gspVoExtendInfoService.getVoExtendInfo(configId); + } + if(voExisting == null){ + int shortIndex = configId.lastIndexOf("."); + if(shortIndex >0){ + String temConfigId = configId.substring(shortIndex+1); + voExisting = gspVoExtendInfoService.getVoExtendInfoByConfigId(temConfigId); + } + } + if (voExisting == null) { + return null; + } + if (voExisting.getVoConfigCollectionInfo() != null && voExisting.getVoConfigCollectionInfo().getConfig().getID() != null && !voExisting.getVoConfigCollectionInfo().getConfig().getID().isEmpty() && ProcessMode.generation == voExisting.getVoConfigCollectionInfo().getProjectType()) { + return voExisting.getVoConfigCollectionInfo().getConfig(); + } else { + return null; + } + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/i18n/ViewModelMgrInfo.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/i18n/ViewModelMgrInfo.java new file mode 100644 index 0000000..077b47d --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/i18n/ViewModelMgrInfo.java @@ -0,0 +1,22 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.i18n; + +import com.inspur.edp.cef.spi.entity.info.AbstractMgrInfo; + +public abstract class ViewModelMgrInfo extends AbstractMgrInfo { +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/i18n/VoEntityInfo.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/i18n/VoEntityInfo.java new file mode 100644 index 0000000..6ccd857 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/i18n/VoEntityInfo.java @@ -0,0 +1,22 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.i18n; + +import com.inspur.edp.cef.spi.entity.info.EntityInfo; + +public abstract class VoEntityInfo extends EntityInfo { +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/i18n/VoPropInfo.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/i18n/VoPropInfo.java new file mode 100644 index 0000000..ce3e0ae --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/i18n/VoPropInfo.java @@ -0,0 +1,22 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.i18n; + +import com.inspur.edp.cef.spi.entity.AbstractPropertyInfo; + +public abstract class VoPropInfo extends AbstractPropertyInfo { +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/i18n/VoRefPropInfo.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/i18n/VoRefPropInfo.java new file mode 100644 index 0000000..4590434 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/i18n/VoRefPropInfo.java @@ -0,0 +1,22 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.i18n; + +import com.inspur.edp.cef.spi.entity.info.AbstractRefPropInfo; + +public abstract class VoRefPropInfo extends AbstractRefPropInfo { +} -- Gitee From 1a8a8162e98c10930d25d026b0ef62b0859c8b11 Mon Sep 17 00:00:00 2001 From: Jakeem Date: Sun, 30 Oct 2022 08:56:36 +0800 Subject: [PATCH 75/81] =?UTF-8?q?1.=20=E6=B7=BB=E5=8A=A0=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inspur/edp/bff/spi/utils/AuthUtils.java | 50 ++++++ .../edp/bff/spi/utils/BffActionNames.java | 21 +++ .../edp/bff/spi/utils/EnumConvertor.java | 34 ++++ .../edp/bff/spi/utils/ParameterInfo.java | 32 ++++ .../inspur/edp/bff/spi/utils/ReflectInfo.java | 57 ++++++ .../edp/bff/spi/utils/VoJsonDeserializer.java | 167 ++++++++++++++++++ .../edp/bff/spi/utils/VoJsonSerializer.java | 131 ++++++++++++++ .../bff/spi/utils/VoMapIgnoreKeysUtil.java | 59 +++++++ 8 files changed, 551 insertions(+) create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/AuthUtils.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/BffActionNames.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/EnumConvertor.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/ParameterInfo.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/ReflectInfo.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/VoJsonDeserializer.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/VoJsonSerializer.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/VoMapIgnoreKeysUtil.java diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/AuthUtils.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/AuthUtils.java new file mode 100644 index 0000000..76e7b1a --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/AuthUtils.java @@ -0,0 +1,50 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.utils; + +import com.inspur.edp.bef.api.lcp.AuthInfo; + +public class AuthUtils { + public static void buildAuthInfo( + AuthInfo info, + String extendType, + String extend1, + String extend2, + String extend3, + String extend4, + String extend5){ + info.setExtType(extendType); + info.setExtend1(extend1); + info.setExtend2(extend2); + info.setExtend3(extend3); + info.setExtend4(extend4); + info.setExtend5(extend5); + } + + public static void buildAuthInfo( + AuthInfo info, + String extendType, + String extend1, + String extend2, + String extend3, + String extend4, + String extend5, + String sourceType){ + buildAuthInfo(info, extendType, extend1, extend2, extend3, extend4, extend5); + info.setSourceType(sourceType); + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/BffActionNames.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/BffActionNames.java new file mode 100644 index 0000000..47a50f1 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/BffActionNames.java @@ -0,0 +1,21 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.utils; + +public class BffActionNames { + public static final String DefaultName = "Default"; +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/EnumConvertor.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/EnumConvertor.java new file mode 100644 index 0000000..c729e05 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/EnumConvertor.java @@ -0,0 +1,34 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.utils; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import java.io.IOException; + +public class EnumConvertor extends JsonSerializer { + + @Override + public void serialize(Enum anEnum, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) + throws IOException, JsonProcessingException { + jsonGenerator.writeString(String.valueOf(anEnum)); + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/ParameterInfo.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/ParameterInfo.java new file mode 100644 index 0000000..7ee8010 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/ParameterInfo.java @@ -0,0 +1,32 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.utils; + +import lombok.Getter; + +public class ParameterInfo { + @Getter + private String parameterName; + @Getter + private String parameterValue; + + public ParameterInfo(String parameterName, String parameterValue) + { + this.parameterName = parameterName; + this.parameterValue = parameterValue; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/ReflectInfo.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/ReflectInfo.java new file mode 100644 index 0000000..f93a5db --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/ReflectInfo.java @@ -0,0 +1,57 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.utils; + +import lombok.Getter; + +import java.util.ArrayList; +import java.util.List; + +public class ReflectInfo { + + @Getter + private String assemblyName; + @Getter + private String className; + @Getter + private Object[] parameters; + @Getter + private List parameterInfoList; + @Getter + private String componentID; + + + public ReflectInfo(String assemblyName, String className) + { + this.assemblyName = assemblyName; + this.className = className; + } + + public ReflectInfo(String assemblyName, String className, List parameterInfoList) + { + this.assemblyName = assemblyName; + this.className = className; + this.parameterInfoList = parameterInfoList; + } + public ReflectInfo(String assemblyName, String className, List parameterInfoList, String componentID) + { + this.assemblyName = assemblyName; + this.className = className; + this.parameterInfoList = parameterInfoList; + this.componentID = componentID; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/VoJsonDeserializer.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/VoJsonDeserializer.java new file mode 100644 index 0000000..0d16fb8 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/VoJsonDeserializer.java @@ -0,0 +1,167 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.utils; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.JsonDeserializer; +import io.iec.edp.caf.common.JSONSerializer; + +import java.io.IOException; +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +public abstract class VoJsonDeserializer extends JsonDeserializer { + + + /** + * 读取字符数据 + * + * @param p 值 + * @return 得到的字符串值 + */ + protected final String readString(JsonParser p){ + try { + return p.getValueAsString(); + } catch (IOException e) { + throw new RuntimeException("字符串数据Json反序列化失败"); + } + } + + /** + * 读取整型数据 + * + * @param p 值 + * @return 得到的整数值 + */ + protected final int readInt(JsonParser p){ + try { + return p.getValueAsInt(); + } catch (IOException e) { + throw new RuntimeException("整形数据Json反序列化失败"); + } + } + + /** + * 读取小数数据 + * + * @param p 值 + * @return 得到的小数值 + */ + protected final BigDecimal readDecimal(JsonParser p){ + try { + return p.getDecimalValue(); +// p.getValueAsDouble(); + } catch (IOException e) { + throw new RuntimeException("浮点型数据Json反序列化失败"); + } + } + + /** + * 读取布尔数据 + * + * @param p 值 + * @return 得到的布尔值 + */ + protected final boolean readBool(JsonParser p){ + try { + return p.getValueAsBoolean(); + } catch (IOException e) { + throw new RuntimeException("布尔型数据Json反序列化失败"); + } + } + /** + * 读取日期数据 + * + * @param p 值 + * @return 得到的日期值 + */ + protected final Date readDateTime(JsonParser p) { + String strValue = null; + try { + strValue = p.getValueAsString(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return dateFormat.parse(strValue); +// + } catch (IOException | ParseException e) { + try{ + return strValue != null && !("".equals(strValue))? java.sql.Date.valueOf(strValue) : null; + }catch (Exception e1){ + throw new RuntimeException("日期类型数据Json反序列化失败:"+strValue, e1); + } + + } + + } + + protected final Date readDate(JsonParser p){ + String strValue = null; + try{ + strValue = p.getValueAsString(); + return strValue != null && !("".equals(strValue))? java.sql.Date.valueOf(strValue) : null; + }catch (Exception e){ + throw new RuntimeException("日期类型数据Json反序列化失败:"+strValue, e); + } + } + + /** + * 读取二进制数据 + * + * @param p 值 + * @return 得到的二进制数据值 + */ + protected final byte[] readBytes(JsonParser p){ + try { + return p.getBinaryValue(); + } catch (IOException e) { + throw new RuntimeException("二进制类型数据Json反序列化失败"); + } + + } + + /** + * 读取枚举数据 + * + * @param p 值 + * @param enumType 枚舉類类型 + * @return 得到的枚举值 + */ + protected final > T readEnum(JsonParser p, Class enumType){ + try { + return T.valueOf(enumType,p.getValueAsString()); + } catch (IOException e) { + throw new RuntimeException("枚举类型数据Json反序列化失败"); + } + } + /** + * 读取关联数据 + * + * @param value 值 + * @return 得到的关联值 + */ + protected final T readAssociation(JsonParser value, Class assoType) + { + try { + return JSONSerializer.getObjectMapper().readValue(value,assoType); + } catch (IOException e) { + throw new RuntimeException("关联"+assoType.getName()+"反序列化失败", e); + } + } + + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/VoJsonSerializer.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/VoJsonSerializer.java new file mode 100644 index 0000000..a18c61a --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/VoJsonSerializer.java @@ -0,0 +1,131 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.utils; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.inspur.edp.cef.spi.jsonser.base.StringUtils; + +import java.io.IOException; + + +public abstract class VoJsonSerializer extends JsonSerializer { + + + /** + * 将枚举类型数据写入到Json中 + * + * @param writer Json写入器 + * @param value 要写入的值 + * @param propertyName 要写入的属性名称 + * @param serializerProvider Json序列化类 + */ + protected final void writeEnum(JsonGenerator writer, Object value, String propertyName, SerializerProvider serializerProvider) + throws IOException{ + writer.writeFieldName(StringUtils.toCamelCase(propertyName)); + writer.writeString(String.valueOf(value)); + } + + /** + * 将字符类型数据写入到Json中 + * + * @param writer Json写入器 + * @param value 要写入的值 + * @param propertyName 要写入的属性名称 + * @param serializerProvider Json序列化类 + */ + protected final void writeString(JsonGenerator writer, Object value, String propertyName, SerializerProvider serializerProvider) throws IOException { + writeBaseType(writer, value, propertyName, serializerProvider); + } + + /** + * 将整数类型数据写入到Json中 + * + * @param writer Json写入器 + * @param value 要写入的值 + * @param propertyName 要写入的属性名称 + * @param serializerProvider Json序列化类 + */ + protected final void writeInt(JsonGenerator writer, Object value, String propertyName, SerializerProvider serializerProvider) throws IOException { + writeBaseType(writer, value, propertyName, serializerProvider); + } + /** + * 将小数类型数据写入到Json中 + * + * @param writer Json写入器 + * @param value 要写入的值 + * @param propertyName 要写入的属性名称 + * @param serializerProvider Json序列化类 + */ + protected final void writeDecimal(JsonGenerator writer, Object value, String propertyName, SerializerProvider serializerProvider) throws IOException { + writeBaseType(writer, value, propertyName, serializerProvider); + } + /** + * 将布尔类型数据写入到Json中 + * + * @param writer Json写入器 + * @param value 要写入的值 + * @param propertyName 要写入的属性名称 + * @param serializerProvider Json序列化类 + */ + protected final void writeBool(JsonGenerator writer, Object value, String propertyName, SerializerProvider serializerProvider) throws IOException { + writeBaseType(writer, value, propertyName, serializerProvider); + } + /** + * 将日期类型数据写入到Json中 + * + * @param writer Json写入器 + * @param value 要写入的值 + * @param propertyName 要写入的属性名称 + * @param serializerProvider Json序列化类 + */ + protected final void writeDateTime(JsonGenerator writer, Object value, String propertyName, SerializerProvider serializerProvider) throws IOException { + writeBaseType(writer, value, propertyName, serializerProvider); + } + /** + * 将二进制数组类型数据写入到Json中 + * + * @param writer Json写入器 + * @param value 要写入的值 + * @param propertyName 要写入的属性名称 + * @param serializerProvider Json序列化类 + */ + protected final void writeBytes(JsonGenerator writer, Object value, String propertyName, SerializerProvider serializerProvider) + throws IOException { +// String transValue =Base64Utils Convert.ToBase64String((byte[])((value instanceof byte[]) ? value : null)); +// writeBaseType(writer, transValue, propertyName, serializerProvider); + } + /** + * 将关联类型数据写入到Json中 + * + * @param writer Json写入器 + * @param value 要写入的值 + * @param propertyName 要写入的属性名称 + * @param serializerProvider Json序列化类 + */ + protected final void writeAssociation(JsonGenerator writer, Object value, String propertyName, SerializerProvider serializerProvider) throws IOException { + writeBaseType(writer, value, propertyName, serializerProvider); + } + private void writeBaseType(JsonGenerator writer, Object value, String propertyName, SerializerProvider serializerProvider) + throws IOException { + writer.writeFieldName(StringUtils.toCamelCase(propertyName)); + serializerProvider.defaultSerializeValue(value, writer); + } + + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/VoMapIgnoreKeysUtil.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/VoMapIgnoreKeysUtil.java new file mode 100644 index 0000000..52ae673 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/utils/VoMapIgnoreKeysUtil.java @@ -0,0 +1,59 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.utils; + +import java.util.Map; +import java.util.Set; + +public class VoMapIgnoreKeysUtil { + + public static boolean containsIgnoreKey(Set keys, String propertyName) { + if (keys == null || propertyName == null) { + return false; + } + for (String key : keys) { + if (propertyName.equalsIgnoreCase(key)) { + return true; + } + } + return false; + } + + public static T getValueByIgnoreKey(Map keys, String propertyName) { + if (keys == null || propertyName == null) { + return null; + } + for (Map.Entry entry : keys.entrySet()) { + if (propertyName.equalsIgnoreCase(entry.getKey())) { + return entry.getValue(); + } + } + return null; + } + + public static String getRelKey(Set keys, String propertyName) { + if (keys == null || propertyName == null) { + return ""; + } + for (String key : keys) { + if (propertyName.equalsIgnoreCase(key)) { + return key; + } + } + return ""; + } +} -- Gitee From af6bf2b57a48c3c0b04ee2ba1c5079ec26e8c9c4 Mon Sep 17 00:00:00 2001 From: Jakeem Date: Sun, 30 Oct 2022 09:35:52 +0800 Subject: [PATCH 76/81] =?UTF-8?q?1.=20=E6=B7=BB=E5=8A=A0=E5=BA=8F=E5=88=97?= =?UTF-8?q?=E5=8C=96=E5=8F=8D=E5=BA=8F=E5=88=97=E5=8C=96convertor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spi/AbstractBffEntityDeserConvertor.java | 62 ++++ .../spi/AbstractBffEntitySerConvertor.java | 34 ++ .../edp/bff/spi/AbstractChangeConvertor.java | 320 ++++++++++++++++++ .../edp/bff/spi/AbstractDataConvertor.java | 209 ++++++++++++ .../spi/AbstractDefaultValueConvertor.java | 52 +++ .../bff/spi/AbstractEntityPropertyMapper.java | 137 ++++++++ .../inspur/edp/bff/spi/AbstractFSAction.java | 92 +++++ .../inspur/edp/bff/spi/AbstractFSManager.java | 73 ++++ .../edp/bff/spi/AbstractHelpAction.java | 34 ++ .../edp/bff/spi/BffChangeDeserConvertor.java | 73 ++++ .../edp/bff/spi/BffChangeSerConvertor.java | 55 +++ .../edp/bff/spi/BffEntityDeserConvertor.java | 50 +++ .../edp/bff/spi/BffEntitySerConvertor.java | 46 +++ .../edp/bff/spi/BffEntitySerializer.java | 39 +++ .../inspur/edp/bff/spi/BffSourceConfig.java | 29 ++ .../com/inspur/edp/bff/spi/IHelpExtend.java | 24 ++ .../com/inspur/edp/bff/spi/IHelpMapping.java | 28 ++ .../com/inspur/edp/bff/spi/VMHelpConfig.java | 88 +++++ 18 files changed, 1445 insertions(+) create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractBffEntityDeserConvertor.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractBffEntitySerConvertor.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractChangeConvertor.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractDataConvertor.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractDefaultValueConvertor.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractEntityPropertyMapper.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractFSAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractFSManager.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractHelpAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffChangeDeserConvertor.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffChangeSerConvertor.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffEntityDeserConvertor.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffEntitySerConvertor.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffEntitySerializer.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffSourceConfig.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/IHelpExtend.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/IHelpMapping.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/VMHelpConfig.java diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractBffEntityDeserConvertor.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractBffEntityDeserConvertor.java new file mode 100644 index 0000000..f2afd33 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractBffEntityDeserConvertor.java @@ -0,0 +1,62 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi; + +import com.inspur.edp.bff.api.manager.IFSManagerFactory; +import com.inspur.edp.cef.spi.jsonser.entity.AbstractEntitySerializerItem; +import com.inspur.edp.commonmodel.api.ICMManager; +import com.inspur.edp.commonmodel.spi.AbstractEntityDataDeSerializer; +import io.iec.edp.caf.runtime.config.CefBeanUtil; + +import java.util.List; + + +public abstract class AbstractBffEntityDeserConvertor extends AbstractEntityDataDeSerializer { + private String configId; + private ICMManager manager; + + protected AbstractBffEntityDeserConvertor(String objectCode, boolean isRoot, String configId, List serializers) { + super(objectCode, isRoot, serializers); + this.configId = configId; + } + + private IFSManagerFactory fsMgrFactory; + private IFSManagerFactory getFsMgrFactory(){ + if(fsMgrFactory == null){ + fsMgrFactory = CefBeanUtil.getAppCtx().getBean(IFSManagerFactory.class); + } + return fsMgrFactory; + } + @Override + protected ICMManager getCMManager() { + if(manager == null) + manager = getFsMgrFactory().getFSManager(configId); + return manager; + } + + public void setManager(ICMManager manager){ + this.manager = manager; + super.setManager(manager); + } + + @Override + protected AbstractEntityDataDeSerializer buildChildConvertor(String childCode) { + AbstractEntityDataDeSerializer childConvertor = this.getChildConvertor(childCode); + childConvertor.setManager(this.getCMManager()); + return childConvertor; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractBffEntitySerConvertor.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractBffEntitySerConvertor.java new file mode 100644 index 0000000..0d6cbee --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractBffEntitySerConvertor.java @@ -0,0 +1,34 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi; + +import com.inspur.edp.cef.spi.jsonser.entity.AbstractEntitySerializerItem; +import com.inspur.edp.commonmodel.spi.AbstractEntityDataSerializer; +import java.util.ArrayList; +import java.util.List; + +public abstract class AbstractBffEntitySerConvertor extends AbstractEntityDataSerializer { + + + private String configId; + protected AbstractBffEntitySerConvertor(String objectCode, boolean isRoot,String configId, List serializers) { + super(objectCode, isRoot, serializers); + this.configId = configId; + } + +} + diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractChangeConvertor.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractChangeConvertor.java new file mode 100644 index 0000000..5b0be11 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractChangeConvertor.java @@ -0,0 +1,320 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi; + +import com.inspur.edp.bff.api.dataprocessor.IChangeConvertor; +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import com.inspur.edp.cef.entity.accessor.entity.IEntityAccessor; +import com.inspur.edp.cef.entity.changeset.AddChangeDetail; +import com.inspur.edp.cef.entity.changeset.DeleteChangeDetail; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import com.inspur.edp.cef.entity.changeset.ModifyChangeDetail; +import com.inspur.edp.cef.entity.entity.IEntityData; +import com.inspur.edp.cef.entity.entity.IEntityDataCollection; +import com.inspur.edp.cef.entity.i18n.MultiLanguageInfo; +import com.inspur.edp.cef.spi.jsonser.base.StringUtils; + +import javax.ws.rs.NotSupportedException; +import java.util.HashMap; +import java.util.Map; + +public abstract class AbstractChangeConvertor implements IChangeConvertor { + + private IFSManagerContext mgrContext; + /**转换器基类构造函数。 + * + * @param mgrContext FormServer管理类上下文接口{@link IFSManagerContext} + */ + + + public AbstractChangeConvertor(IFSManagerContext mgrContext) + { + this.mgrContext = mgrContext; + } + + private String nodeCode; + public final String getNodeCode() + { + return nodeCode; + } + public final void setNodeCode(String value) + { + nodeCode = value; + } + /** + * FormServer管理类上下文接口{@link IFSManagerContext} + * + * @see IFSManagerContext + */ + protected IFSManagerContext getMgrContext(){return mgrContext;} + + /** + * 将BE变更集数据转换成VM变更集数据 + * + * @param beChanges BM变更集数据 + * @return 转换之后的VM变更集数据 + * + * @see IChangeDetail + */ + public final IChangeDetail convertFromBEChange(IChangeDetail beChanges) + { + if (beChanges == null) + { + return null; + } + switch (beChanges.getChangeType()) + { + case Added: + //TODO 待完善 +// throw new NotImplementedException("目前不支持新增的变更转换。"); + throw new UnsupportedOperationException("目前不支持新增的变更转换"); +// break; + case Modify: + ModifyChangeDetail modifyChange = new ModifyChangeDetail(beChanges.getDataID()); + convertModifyPropertiesFormBE((ModifyChangeDetail)((beChanges instanceof ModifyChangeDetail) ? beChanges : null), modifyChange); + convertModifyChildChangesFromBE((ModifyChangeDetail)((beChanges instanceof ModifyChangeDetail) ? beChanges : null), modifyChange); + return modifyChange; + case Deleted: + //TODO + return new DeleteChangeDetail(beChanges.getDataID()); + default: + throw new NotSupportedException(); + } + } + + private void convertModifyChildChangesFromBE(ModifyChangeDetail beChange, ModifyChangeDetail vmChange) + { + if (beChange.getChildChanges() == null || beChange.getChildChanges().size() == 0) + { + return; + } + for (Map.Entry> item : beChange.getChildChanges().entrySet()) + { + convertChildChangesFromBE(item.getKey(), item.getValue(), vmChange); + } + } + + private void convertChildChangesFromBE(String childCode, Map beChildChanges, ModifyChangeDetail vmParentChange) + { + if (beChildChanges == null || beChildChanges.isEmpty()) + { + return; + } + + String vmChildCode = getMgrContext().getVMCodeFromBE(childCode); + if (StringUtils.isNullOrEmpty(vmChildCode)) + { + return; + } + Map vmChildChanges = null; + if (vmParentChange.getChildChanges().containsKey(vmChildCode)) + { + vmChildChanges = vmParentChange.getChildChanges().get(vmChildCode); + } + else + { + vmChildChanges = new HashMap(beChildChanges.size()); + vmParentChange.getChildChanges().put(vmChildCode, vmChildChanges); + } + + AbstractChangeConvertor childChangeConvertor = getChildChangeConvertor(vmChildCode); + childChangeConvertor.setNodeCode(vmChildCode); + for (IChangeDetail item : beChildChanges.values()) + { + IChangeDetail targetChildChange = childChangeConvertor.convertFromBEChange(item); + vmChildChanges.put(targetChildChange.getDataID(), targetChildChange); + } + } + + /** + * 获取子节点变更集转换器。 + * + * @param childCode 子节点编号 + * @return 得到的子节点的属性变更转换器 + * + * @see AbstractChangeConvertor + */ + protected abstract AbstractChangeConvertor getChildChangeConvertor(String childCode); + + private void convertModifyPropertiesFormBE(ModifyChangeDetail beChange, ModifyChangeDetail vmChange) + { + if (beChange.getPropertyChanges() == null || beChange.getPropertyChanges().size() == 0) + { + return; + } + + for (Map.Entry item : beChange.getPropertyChanges().entrySet()) { + convertModifyPropFromBE(item.getKey(), item.getValue(), vmChange); + } + for (Map.Entry item : beChange.getMultiLanguageInfos() + .entrySet()) { + String propName = item.getKey().split(MultiLanguageInfo.MULTILANGUAGETOKEN)[0]; + convertMultiLanguageModifyPropFromBE(propName, item.getValue(), vmChange); + } + } + + /** + * 将BE变更属性转换成VM变更数据属性 + * + * @param beElementCode BE节点编号 + * @param beValue BE节点的值 + * @param vmChange VM变更定义 + */ + protected abstract void convertModifyPropFromBE(String beElementCode, Object beValue, ModifyChangeDetail vmChange); + + protected void convertMultiLanguageModifyPropFromBE(String beElementCode, Object beValue, + ModifyChangeDetail vmChange) { + + } + + /** + * 将VM变更集数据转换成BE变更集数据 + * + * @param vmChanges VM变更集数据 + * @return 转换之后的BE变更集数据 + * + */ + public final IChangeDetail convertFromVMChange(IChangeDetail vmChanges) + { + if (vmChanges == null) + { + return null; + } + switch (vmChanges.getChangeType()) + { + case Added: + AddChangeDetail addChange = (AddChangeDetail)((vmChanges instanceof AddChangeDetail) ? vmChanges : null); + String beCode = getMgrContext().getBECodeFromVM(getNodeCode()); + + IEntityAccessor beAcsr = (IEntityAccessor)getMgrContext().getLcp().createChildData(beCode,""); + + IEntityData beData = getMgrContext().getLcp().createUnlistenableChildData(beCode,""); + + IDataConvertor convertor = getMgrContext().getDataConvertor().getChildConvertor(getNodeCode()); + convertor.convertFromVMData(addChange.getEntityData(), beData); + beAcsr.setInnerData(beData); + beData.getChilds().forEach((key, value) -> { + if (value == null || value.isEmpty()) { + return; + } + IEntityDataCollection childCollection = beAcsr.createAndSetChildCollection(key); + value.forEach(item -> { + IEntityAccessor childAcsr = (IEntityAccessor)getMgrContext().getLcp().createChildData(key,""); + childAcsr.setInnerData(item); + childCollection.add(childAcsr); + }); + }); + return new AddChangeDetail((IEntityData)beAcsr); + case Modify: + ModifyChangeDetail beChange = new ModifyChangeDetail(vmChanges.getDataID()); + convertModifyPropertiesFormVM(beChange, (ModifyChangeDetail)((vmChanges instanceof ModifyChangeDetail) ? vmChanges : null)); + convertModifyChildChangesFromVM(beChange, (ModifyChangeDetail)((vmChanges instanceof ModifyChangeDetail) ? vmChanges : null)); + return beChange; + case Deleted: + return new DeleteChangeDetail(vmChanges.getDataID()); + default: + throw new NotSupportedException(); + } + } + + private void convertModifyChildChangesFromVM(ModifyChangeDetail beChange, ModifyChangeDetail vmChange) + { + if (vmChange.getChildChanges() == null || vmChange.getChildChanges().size() == 0) + { + return; + } + + for (Map.Entry> item : vmChange.getChildChanges().entrySet()) + { + convertChildChangesFromVM(item.getKey(), item.getValue(), beChange); + } + } + private void convertChildChangesFromVM(String childCode, Map vmChildChanges, ModifyChangeDetail beParent) + { + if (vmChildChanges == null || vmChildChanges.isEmpty()) + { + return; + } + + + String beChildCode = getMgrContext().getBECodeFromVM(childCode); + if(beChildCode == null || "".equals(beChildCode)) + return; + Map beChildChanges = null; + if (beParent.getChildChanges().containsKey(beChildCode)) { + beChildChanges = beParent.getChildChanges().get(beChildCode); + } + else { + beChildChanges = new HashMap(vmChildChanges.size()); + beParent.getChildChanges().put(beChildCode, beChildChanges); + } + AbstractChangeConvertor childChangeConvertor = getChildChangeConvertor(childCode); + if(childChangeConvertor == null) + return; + childChangeConvertor.setNodeCode(childCode); + + for (IChangeDetail item : vmChildChanges.values()) { + IChangeDetail targetChildChange = childChangeConvertor.convertFromVMChange(item); + beChildChanges.put(targetChildChange.getDataID(), targetChildChange); + } + } + + private void convertModifyPropertiesFormVM(ModifyChangeDetail beChange, + ModifyChangeDetail vmChange) { + if ((vmChange.getPropertyChanges() == null || vmChange.getPropertyChanges().size() == 0) + && vmChange.getMultiLanguageInfos().isEmpty()) { + return; + } + for (Map.Entry item : vmChange.getPropertyChanges().entrySet()) { + convertModifyPropFromVM(item.getKey(), item.getValue(), beChange); + } + for (Map.Entry item : vmChange.getMultiLanguageInfos() + .entrySet()) { + String propName = item.getKey().split(MultiLanguageInfo.MULTILANGUAGETOKEN)[0]; + convertMultiLanguageModifyPropFromVo(propName, item.getValue(), beChange); + } + } + + /** + * 变更集多语属性赋值,生成代码中调用 + */ + protected void setChangeDetailMultiLanguageInfo(ModifyChangeDetail changeDetail, + String voLabelId, + Object value) { + MultiLanguageInfo targetValue = ((MultiLanguageInfo) value).clone(); + targetValue.setPropName(voLabelId + MultiLanguageInfo.MULTILANGUAGETOKEN); + changeDetail.getMultiLanguageInfos() + .put(voLabelId + MultiLanguageInfo.MULTILANGUAGETOKEN, targetValue); + } + + /** + * 将VM变更数据属性转换成BE变更数据属性 + * + * @param vmElementCode VM字段编号 + * @param vmValue VM变更属性值 + * @param beChange BE变更 + * + * @see ModifyChangeDetail + */ + protected abstract void convertModifyPropFromVM(String vmElementCode, Object vmValue, ModifyChangeDetail beChange); + + protected void convertMultiLanguageModifyPropFromVo(String vmElementCode, Object vmValue, + ModifyChangeDetail beChange) { + + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractDataConvertor.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractDataConvertor.java new file mode 100644 index 0000000..86f44cb --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractDataConvertor.java @@ -0,0 +1,209 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi; + +import com.inspur.edp.bff.api.dataprocessor.IDataConvertor; +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.cef.entity.accessor.base.IAccessor; +import com.inspur.edp.cef.entity.entity.*; + +import java.util.HashMap; +import java.util.Map; + +public abstract class AbstractDataConvertor implements IDataConvertor { + + private IFSManager fsManager; + + /** + * 构造函数 + */ + + public AbstractDataConvertor() { + + } + + public final IFSManager getFSManager() { + return fsManager; + } + + public final void setFSManager(IFSManager value) { + fsManager = value; + } + + /** + * 将BE数据转换成VM数据 + * + * @param beData BE数据 + * @param vmData VM数据 + * + * @see IEntityData + */ + public final void convertFromBEData(IEntityData beData, IEntityData vmData) { + mappingEntityDataProperties(beData, vmData); + + if (beData instanceof IMultiLanguageData && vmData instanceof IMultiLanguageData) { + mappingEntityDataMultiLanguageProps(beData, vmData); + } + + HashMap childs = beData.getChilds(); + if (childs == null || childs.size() == 0) { + return; + } + + for (Map.Entry item : childs.entrySet()) { + convertChild(item.getKey(), item.getValue(), vmData); + } + } + + private void convertChild(String childCode, IEntityDataCollection datas, IEntityData vmData) { + if (datas == null || datas.size() == 0 || !checkChildCode(childCode)) { + return; + } + AbstractDataConvertor childConvertor = getChildDataConvertor(childCode); + + if (childConvertor == null) { + return; + } + + for (IEntityData item : datas) { + Object tempVar = (getFSManager() == null ? vmData.createChild(childCode) : ((IAccessor) getFSManager().createChildData(childCode, "")).getInnerData()); + IEntityData vmChild = (IEntityData) (getFSManager() == null ? vmData.createChild(childCode) : ((IAccessor) getFSManager().createChildData(childCode, "")).getInnerData()); + if (vmChild == null) + //TODO 异常封装 + { + throw new RuntimeException(); + } + childConvertor.convertFromBEData(item, vmChild); + + HashMap childDatas = vmData.getChilds(); + if (childDatas.containsKey(childCode)) { + childDatas.get(childCode).add(vmChild); + } else { + EntityDataCollection collection = new EntityDataCollection(); + collection.add(vmChild); + childDatas.put(childCode, collection); + } + } + } + + protected boolean checkChildCode(String childCode) { + return true; + } + + + /** + * 将BE数据属性映射到VM数据实体上 + * + * @param beData BE数据 + * @param vmData VM数据 + * @see IEntityData + */ + protected abstract void mappingEntityDataProperties(IEntityData beData, IEntityData vmData); + + protected void mappingEntityDataMultiLanguageProps(IEntityData beData, IEntityData vmData) { + + } + + protected void mappingEntityDataPropertiesFromVo(IEntityData beData, IEntityData vmData) { + throw new RuntimeException("暂未实现Vo数据转换为Be数据,请尝试重新编译Vo所在元数据工程"); + } + + protected void mappingEntityDataMultiLanguagePropsFromVo(IEntityData beData, + IEntityData vmData) { + + } + + /** + * 获取子节点的数据转换器 + * + * @param childCode 子节点编号 + * @return 得到的子节点的数据转换器 + * + * @see AbstractDataConvertor + */ + public abstract AbstractDataConvertor getChildDataConvertor(String childCode); + + public final IDataConvertor getChildConvertor(String childCode) { + if (checkChildCode(childCode)) + return getChildDataConvertor(childCode); + return null; + } + //TODO:暂时未实现。 + + /** + * 将VM数据转换成BE数据 + * + * @param vmData VM数据 + * @param beData BE数据 + * + * @see IEntityData + */ + public final void convertFromVMData(IEntityData vmData, IEntityData beData) { + mappingEntityDataPropertiesFromVo(beData, vmData); + if (beData instanceof IMultiLanguageData && vmData instanceof IMultiLanguageData) { + mappingEntityDataMultiLanguagePropsFromVo(beData, vmData); + } + HashMap childs = vmData.getChilds(); + if (childs == null || childs.size() == 0) { + return; + } + + for (Map.Entry item : childs.entrySet()) { + convertChildFromVo(item.getKey(), item.getValue(), beData); + } + } + + private void convertChildFromVo(String childCode, IEntityDataCollection datas, IEntityData beData) { + if (datas == null || datas.size() == 0 || !checkChildCode(childCode)) { + return; + } + AbstractDataConvertor childConvertor = getChildDataConvertor(childCode); + + if (childConvertor == null) { + return; + } + + for (IEntityData item : datas) { + ICefData tempVar = beData.createChild(childCode); + IEntityData beChild = (IEntityData) ((tempVar instanceof IEntityData) ? tempVar : null); + if (beChild == null) + //TODO 异常封装 + { + throw new RuntimeException(); + } + childConvertor.convertFromVMData(item, beChild); + + HashMap childDatas = beData.getChilds(); + if (childDatas.containsKey(childCode)) { + childDatas.get(childCode).add(beChild); + } else { + EntityDataCollection collection = new EntityDataCollection(); + collection.add(beChild); + childDatas.put(childCode, collection); + + } + } + } + + public final void convertFromSourceData(ICefData sourceData, IEntityData vmData) { + throw new UnsupportedOperationException(); + } + + public final void convert2SourceData(IEntityData vmData, ICefData sourceData) { + throw new UnsupportedOperationException(); + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractDefaultValueConvertor.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractDefaultValueConvertor.java new file mode 100644 index 0000000..b64fb09 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractDefaultValueConvertor.java @@ -0,0 +1,52 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi; + +import com.inspur.edp.bff.api.dataprocessor.IDefaultValueConvertor; +import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue; + +import java.util.HashMap; +import java.util.Map; + +public abstract class AbstractDefaultValueConvertor implements IDefaultValueConvertor { + + public final HashMap convertFromVo(VoDefaultValue voDefaultValue) + { + HashMap beDefaultValue = new HashMap(); + if (voDefaultValue != null) + { + convertDefaultFormVo(beDefaultValue, voDefaultValue.getDefaultValue()); + } + return beDefaultValue; + } + + private void convertDefaultFormVo(HashMap beDefaultValue, HashMap voDefaultValue) + { + if (voDefaultValue == null || voDefaultValue.isEmpty()) + { + return; + } + + for (Map.Entry item : voDefaultValue.entrySet()) + { + convertDefaultFormVo(item.getKey(), item.getValue(), beDefaultValue); + } + } + + protected abstract void convertDefaultFormVo(String voElementCode, Object voValue, HashMap beDefaultValue); + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractEntityPropertyMapper.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractEntityPropertyMapper.java new file mode 100644 index 0000000..d02f5cc --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractEntityPropertyMapper.java @@ -0,0 +1,137 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi; + +import com.inspur.edp.bff.api.dataprocessor.IEntityPropertyMapper; +import com.inspur.edp.bff.api.dataprocessor.MapperBEEntityInfo; +import com.inspur.edp.bff.api.dataprocessor.MapperBEPropertyInfo; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +public abstract class AbstractEntityPropertyMapper implements IEntityPropertyMapper { + + + private MapperBEEntityInfo beEntityInfo; + @Override + public MapperBEEntityInfo getBEInfo() { + if(beEntityInfo== null){ + beEntityInfo = buildBEInfo(); + } + return beEntityInfo; + } + + protected abstract MapperBEEntityInfo buildBEInfo(); + + + + + + + private Map bePropFromVO; + @Override + public MapperBEPropertyInfo getBEPropertyInfoFromVO(String prop) { + if(bePropFromVO == null){ + buildPropertyMappings(); + } + return bePropFromVO.get(prop); + } + + protected final void addBEPropertyNameFromVO(String voProp, MapperBEPropertyInfo bePropInfo ){ + Objects.requireNonNull(bePropInfo, "bePropInfo"); + Objects.requireNonNull(voProp, "voProp"); + + bePropFromVO.put(voProp, bePropInfo); + } + + protected abstract void buildBEPropertyInfoFromVO(); + + private void buildPropertyMappings(){ + bePropFromVO = new HashMap<>(); + buildBEPropertyInfoFromVO(); + voPropFromBE = new HashMap<>(bePropFromVO.size()); + for(Map.Entry mapping : bePropFromVO.entrySet()){ + voPropFromBE.put(buildKeyByBEInfo(mapping.getValue().getBEType(), mapping.getValue().getBEEntityCode()), mapping.getKey()); + } + } + + + + private Map voPropFromBE; + @Override + public String getVOPropertyNameFromBE(String beType, String prop) { + if(voPropFromBE == null){ + buildPropertyMappings(); + } + return voPropFromBE.get(buildKeyByBEInfo(beType, prop)); + } + + protected final void addVOPropertyNameFromBE(String beType, String prop, String voProp){ + Objects.requireNonNull(beType, "beType"); + Objects.requireNonNull(prop, "prop"); + Objects.requireNonNull(voProp, "voProp"); + + voPropFromBE.put(buildKeyByBEInfo(beType, prop), voProp); + } + + private static final String buildKeyByBEInfo(String beType, String prop){ + return beType.concat(":").concat(prop); + } + + + + private Map mapperByBECode; + @Override + public IEntityPropertyMapper getMapperByBECode(String beType, String code) { + if(mapperByBECode== null){ + buildChildMappers(); + } + + return mapperByBECode.get(buildKeyByBEInfo(beType, code)); + } + + + + private Map mapperByVOCode; + @Override + public IEntityPropertyMapper getMapperByVOCode(String voCode) { + if(mapperByVOCode== null){ + buildChildMappers(); + } + return mapperByVOCode.get(voCode); + } + + protected final void addMapper(String voCode, IEntityPropertyMapper mapper){ + Objects.requireNonNull(voCode, "voCode"); + Objects.requireNonNull(mapper, "mapper"); + + mapperByVOCode.put(voCode, mapper); + } + + protected abstract void buildMapperByVOCode(); + + private void buildChildMappers(){ + mapperByVOCode = new HashMap<>(); + buildMapperByVOCode(); + mapperByVOCode.put(getVOCode(), this); + mapperByBECode = new HashMap<>(mapperByVOCode.size()); + for(IEntityPropertyMapper mapper : mapperByVOCode.values()){ + mapperByBECode.put(buildKeyByBEInfo(mapper.getBEInfo().getBEType(), mapper.getBEInfo().getBEEntityCode()), mapper); + } + } + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractFSAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractFSAction.java new file mode 100644 index 0000000..73c2e6d --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractFSAction.java @@ -0,0 +1,92 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi; + +import com.inspur.edp.bef.api.action.VoidActionResult; +import com.inspur.edp.bef.api.lcp.IStandardLcp; +import com.inspur.edp.bff.api.manager.IFSAction; +import com.inspur.edp.bff.api.manager.IFSManagerContext; +import lombok.Getter; + +/** + * FormServer操作基类,所有FormServer操作继承自该类。 + * 实现接口{@link IFSAction + * 如果操作没有返回值,则指定返回值类型为 {@link VoidActionResult }} + */ +public abstract class AbstractFSAction implements IFSAction { + + /** + * FormServer管理器上下文。 + + */ + @Getter + private IFSManagerContext context; + private TResult result; + private boolean hasSetValue = false; + + protected boolean getIsAutoSave(){ + return false; + } + + protected AbstractFSAction() + { + } + + + + /** + * 获取BELcp + * @return 得到的BELcp + * + * @see IStandardLcp + */ + protected final IStandardLcp getLcp() + { + return getContext().getLcp(); + } + + + + + public final TResult deal(IFSManagerContext context) + { + this.context = context; + execute(); + //if(IsAutoSave) + // GetLcp().Save(); + return getResult(); + } + + /** + * 获取或设置自定义动作的返回值,返回值类型为TResult + */ + protected final TResult getResult() + { + return result; + } + protected final void setResult(TResult value) + { + result = value; + + hasSetValue = true; + } + + /** + * 自定义动作的核心逻辑抽象方法,该方法需要开发人员在实现类中复写并添加实现逻辑 + */ + protected abstract void execute(); +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractFSManager.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractFSManager.java new file mode 100644 index 0000000..383f197 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractFSManager.java @@ -0,0 +1,73 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi; + +import com.inspur.edp.bff.api.manager.IFSAction; +import com.inspur.edp.bff.api.manager.IFSManagerContext; + +import java.util.Map; + +public class AbstractFSManager { + + private IFSManagerContext context; + + /** + * 管理器上下文{@link IFSManagerContext} + */ + protected IFSManagerContext getContext() { + return context; + } + + public final void setContext(IFSManagerContext context) { + this.context = context; + } + + /** + * 执行操作 + *{@link TResult}要执行的操作的返回值类型 + * + * @param action 要执行的操作 + * @return 操作的执行结果 + */ + protected final TResult executeAction(IFSAction action) { + return context.executeAction(action); + } + + protected final TResult executeAction(IFSAction action ,String actionId, String actionCode + , Map parameters) + { + return context.executeAction(action,actionId,actionCode,parameters,false); + } + + protected final TResult executeAction(IFSAction action ,String actionId, String actionCode + , Map parameters,boolean autoSave) + {return context.executeAction(action,actionId,actionCode,parameters,autoSave);} + + protected final void ProcessResponse() { + context.processResponse(); + } + + @Deprecated + /** use save instea*/ + protected final void Save() { + save(); + } + + protected final void save() { + getContext().getLcp().save(); + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractHelpAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractHelpAction.java new file mode 100644 index 0000000..d9bb5fd --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/AbstractHelpAction.java @@ -0,0 +1,34 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi; + +import com.inspur.edp.bef.api.action.VoidActionResult; +import com.inspur.edp.web.help.api.LookupQueryParam; + +public abstract class AbstractHelpAction extends AbstractFSAction implements IHelpExtend{ + + + protected AbstractHelpAction() + { + } + public abstract void beforeHelp(LookupQueryParam lookupQueryParam); + + @Override + protected final void execute() + { + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffChangeDeserConvertor.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffChangeDeserConvertor.java new file mode 100644 index 0000000..61dc0a7 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffChangeDeserConvertor.java @@ -0,0 +1,73 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi; + +import com.inspur.edp.bff.spi.changeset.AbstractBffChangeJsonDeserializer; +import com.inspur.edp.bff.spi.utils.VoMapIgnoreKeysUtil; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefEntityResInfoImpl; +import com.inspur.edp.cef.spi.jsonser.abstractcefchange.AbstractCefDataDeSerializer; +import com.inspur.edp.cef.spi.jsonser.entity.AbstractEntitySerializerItem; +import java.util.ArrayList; + +/** + * 变更集序列化 + */ +public class BffChangeDeserConvertor extends AbstractBffChangeJsonDeserializer { + private final String code; + private final boolean isRoot; + private final String type; + private final CefEntityResInfoImpl info; + + public BffChangeDeserConvertor(String objectCode, boolean isRoot, String voType, CefEntityResInfoImpl resourceInfo) { + super(objectCode, isRoot, voType, getTypes(resourceInfo)); + this.code = objectCode; + this.isRoot = isRoot; + this.type = voType; + this.info = resourceInfo; + } + + private static ArrayList getTypes(CefEntityResInfoImpl resourceInfo) { + ArrayList list = new ArrayList<>(); + list.add(new com.inspur.edp.cef.spi.jsonser.builtinimpls.CefEntityDataSerializerItem(resourceInfo)); + return list; + } + + @Override + protected AbstractBffChangeJsonDeserializer getChildEntityConvertor( + String nodeCode) { + if (info.getChildEntityResInfos() != null && VoMapIgnoreKeysUtil.containsIgnoreKey(info.getChildEntityResInfos().keySet(), nodeCode)) { + return new BffChangeDeserConvertor(VoMapIgnoreKeysUtil.getRelKey(info.getChildEntityResInfos().keySet(), nodeCode), false, type, (CefEntityResInfoImpl) VoMapIgnoreKeysUtil.getValueByIgnoreKey(info.getChildEntityResInfos(), nodeCode)); + } + // todo 详细注释 + throw new RuntimeException("无法找到" + nodeCode + "节点"); + } + + @Override + protected boolean isChildObjectCode(String propertyName) { + // todo 判断是否存在true + String name = propertyName; + if ("s".equalsIgnoreCase(propertyName.substring(propertyName.length() - 1))) { + name = propertyName.substring(0, propertyName.length() - 1); + } + return info.getChildEntityResInfos() != null && VoMapIgnoreKeysUtil.containsIgnoreKey(info.getChildEntityResInfos().keySet(), name); + } + + @Override + protected AbstractCefDataDeSerializer getCefDataDeSerializer() { + return new BffEntityDeserConvertor(code, isRoot, type, info); + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffChangeSerConvertor.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffChangeSerConvertor.java new file mode 100644 index 0000000..06c4a23 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffChangeSerConvertor.java @@ -0,0 +1,55 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi; + +import com.inspur.edp.bff.spi.changeset.AbstractBffChangeJsonSerializer; +import com.inspur.edp.bff.spi.utils.VoMapIgnoreKeysUtil; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefEntityResInfoImpl; +import com.inspur.edp.cef.spi.jsonser.abstractcefchange.AbstractCefDataSerializer; +import com.inspur.edp.cef.spi.jsonser.entity.AbstractEntitySerializerItem; +import java.util.ArrayList; + +public class BffChangeSerConvertor extends AbstractBffChangeJsonSerializer { + private final String code; + private final boolean isRoot; + private final String type; + private final CefEntityResInfoImpl info; + + public BffChangeSerConvertor(String objectCode, boolean isRoot, String voType, CefEntityResInfoImpl resourceInfo){ + super(objectCode, isRoot, voType, getTypes(resourceInfo)); + this.code = objectCode; + this.isRoot = isRoot; + this.type = voType; + this.info = resourceInfo; + } + private static ArrayList getTypes(CefEntityResInfoImpl resourceInfo){ + ArrayList list=new ArrayList<>(); + list.add(new com.inspur.edp.cef.spi.jsonser.builtinimpls.CefEntityDataSerializerItem(resourceInfo)); + return list; + } + @Override + protected AbstractBffChangeJsonSerializer getChildEntityConvertor( String nodeCode){ + if (info.getChildEntityResInfos() != null && VoMapIgnoreKeysUtil.containsIgnoreKey(info.getChildEntityResInfos().keySet(), nodeCode)) { + return new BffChangeSerConvertor(VoMapIgnoreKeysUtil.getRelKey(info.getChildEntityResInfos().keySet(), nodeCode), false, type,(CefEntityResInfoImpl) VoMapIgnoreKeysUtil.getValueByIgnoreKey(info.getChildEntityResInfos(), nodeCode)); + } + return null; + } + @Override + protected AbstractCefDataSerializer getCefDataConvertor(){ + return new BffEntitySerConvertor(code, isRoot, type, info); + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffEntityDeserConvertor.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffEntityDeserConvertor.java new file mode 100644 index 0000000..07ec325 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffEntityDeserConvertor.java @@ -0,0 +1,50 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi; + +import com.inspur.edp.bff.spi.utils.VoMapIgnoreKeysUtil; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefEntityResInfoImpl; +import com.inspur.edp.cef.spi.jsonser.entity.AbstractEntitySerializerItem; +import java.util.ArrayList; + +/** + * BE序列化类 + */ +public class BffEntityDeserConvertor extends AbstractBffEntityDeserConvertor { + private final String type; + private final CefEntityResInfoImpl info; + + public BffEntityDeserConvertor(String objectCode, boolean isRoot, String voType, CefEntityResInfoImpl resourceInfo) { + super(objectCode, isRoot, voType, getTypes(resourceInfo)); + type = voType; + this.info = resourceInfo; + } + + @Override + protected AbstractBffEntityDeserConvertor getChildConvertor(String childCode) { + if (info.getChildEntityResInfos() != null && VoMapIgnoreKeysUtil.containsIgnoreKey(info.getChildEntityResInfos().keySet(), childCode)) { + return new BffEntityDeserConvertor(VoMapIgnoreKeysUtil.getRelKey(info.getChildEntityResInfos().keySet(), childCode), false, type, (CefEntityResInfoImpl) VoMapIgnoreKeysUtil.getValueByIgnoreKey(info.getChildEntityResInfos(), childCode)); + } + throw new RuntimeException("无法找到"+ childCode +"节点"); + } + + private static ArrayList getTypes(CefEntityResInfoImpl resourceInfo) { + ArrayList list = new ArrayList<>(); + list.add(new com.inspur.edp.cef.spi.jsonser.builtinimpls.CefEntityDataSerializerItem(resourceInfo)); + return list; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffEntitySerConvertor.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffEntitySerConvertor.java new file mode 100644 index 0000000..5a405f2 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffEntitySerConvertor.java @@ -0,0 +1,46 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi; + +import com.inspur.edp.bff.spi.utils.VoMapIgnoreKeysUtil; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefEntityResInfoImpl; +import com.inspur.edp.cef.spi.jsonser.entity.AbstractEntitySerializerItem; +import com.inspur.edp.commonmodel.spi.AbstractEntityDataSerializer; +import java.util.ArrayList; + +public class BffEntitySerConvertor extends AbstractBffEntitySerConvertor { + private final String type; + private final CefEntityResInfoImpl info; + + public BffEntitySerConvertor(String objectCode, boolean isRoot, String voType, CefEntityResInfoImpl resourceInfo) { + super(objectCode, isRoot, voType, getTypes(resourceInfo)); + this.type = voType; + this.info = resourceInfo; + } + + private static java.util.ArrayList getTypes(CefEntityResInfoImpl resourceInfo){ + java.util.ArrayList list=new ArrayList<>(); + list.add(new com.inspur.edp.cef.spi.jsonser.builtinimpls.CefEntityDataSerializerItem(resourceInfo)); + return list; + } + @Override protected AbstractEntityDataSerializer getChildConvertor( String childCode){ + if (info.getChildEntityResInfos() != null && VoMapIgnoreKeysUtil.containsIgnoreKey(info.getChildEntityResInfos().keySet(), childCode)){ + return new BffEntitySerConvertor(VoMapIgnoreKeysUtil.getRelKey(info.getChildEntityResInfos().keySet(), childCode), false, type, (CefEntityResInfoImpl) VoMapIgnoreKeysUtil.getValueByIgnoreKey(info.getChildEntityResInfos(), childCode)); + } + return null; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffEntitySerializer.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffEntitySerializer.java new file mode 100644 index 0000000..d72f061 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffEntitySerializer.java @@ -0,0 +1,39 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.inspur.edp.cef.entity.entity.ICefData; +import java.io.IOException; + +/** + * Vo上默认注解序列化 + */ +public class BffEntitySerializer extends JsonSerializer { + @Override + public void serialize(ICefData value, JsonGenerator gen, SerializerProvider serializers) throws IOException { + getResourceInfo(value).serialize(value, gen, serializers); + } + + protected JsonSerializer getResourceInfo(ICefData value) { + throw new RuntimeException("获取序列化器失败 ClassName:" + value.getClass()); + } +} + + diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffSourceConfig.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffSourceConfig.java new file mode 100644 index 0000000..6f51495 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/BffSourceConfig.java @@ -0,0 +1,29 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi; + +import com.inspur.edp.bff.api.attribute.AbstractSourceConfig; +import com.inspur.edp.bff.api.manager.SourceConfig; + +public class BffSourceConfig extends AbstractSourceConfig { + + public void addConfig(SourceConfig config){ + sourceConfigs.add(config); + } +} + + diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/IHelpExtend.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/IHelpExtend.java new file mode 100644 index 0000000..882fda5 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/IHelpExtend.java @@ -0,0 +1,24 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi; + +import com.inspur.edp.web.help.api.LookupQueryParam; + +public interface IHelpExtend { + void beforeHelp(LookupQueryParam lookupQueryParam); + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/IHelpMapping.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/IHelpMapping.java new file mode 100644 index 0000000..1c4407e --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/IHelpMapping.java @@ -0,0 +1,28 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi; + +import java.util.HashMap; + +public interface IHelpMapping { + + /** + * 存储设计时映射信息,key:codeName+labelId组合,Value:帮助配置信息类 + */ + HashMap getHelpConfig(); + +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/VMHelpConfig.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/VMHelpConfig.java new file mode 100644 index 0000000..83ec67b --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/VMHelpConfig.java @@ -0,0 +1,88 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi; + +import com.inspur.edp.bff.spi.utils.ReflectInfo; + +import java.util.ArrayList; + +public class VMHelpConfig { + /** + * 帮助元数据ID + */ + private String helpId; + public final String getHelpId() + { + return helpId; + } + public final void setHelpId(String value) + { + helpId = value; + } + + /** + * 事件集合 + */ + private ArrayList actionRecord; + public final ArrayList getActionRecord() + { + return actionRecord; + } + public final void setActionRecord(ArrayList value) + { + actionRecord = value; + } + private boolean useCustomAuthInfo = false; + public boolean getUseCustomAuthInfo(){return useCustomAuthInfo;} + public void setUseCustomAuthInfo(boolean value){useCustomAuthInfo=value;} + + private String voID=""; + + public String getVoID() { + return voID; + } + + public void setVoID(String voID) { + this.voID = voID; + } + + private String helpElementID=""; + + public String getHelpElementID() { + return helpElementID; + } + + public void setHelpElementID(String helpElementID) { + this.helpElementID = helpElementID; + } + + private String filterCondition; + public String getFilterCondition() { + return filterCondition; + } + public void setFilterCondition(String filterCondition) { + this.filterCondition = filterCondition; + } + + private String orderbyCondition; + public String getOrderbyCondition() { + return orderbyCondition; + } + public void setOrderbyCondition(String orderbyCondition) { + this.orderbyCondition = orderbyCondition; + } +} -- Gitee From 4a075b5c1464776b6786e36d5aabe728f13db9ff Mon Sep 17 00:00:00 2001 From: Jakeem Date: Sun, 30 Oct 2022 10:56:21 +0800 Subject: [PATCH 77/81] =?UTF-8?q?1.=20=E6=B7=BB=E5=8A=A0request=E5=92=8Cre?= =?UTF-8?q?sponse=20Convertor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bff/spi/action/save/AfterSaveAction.java | 35 +++ .../bff/spi/action/save/BeforeSaveAction.java | 35 +++ .../edp/bff/spi/request/RequestConvertor.java | 119 +++++++++ .../bff/spi/response/ResponseConvertor.java | 230 ++++++++++++++++++ 4 files changed, 419 insertions(+) create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/save/AfterSaveAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/save/BeforeSaveAction.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/request/RequestConvertor.java create mode 100644 bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/response/ResponseConvertor.java diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/save/AfterSaveAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/save/AfterSaveAction.java new file mode 100644 index 0000000..d78cc12 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/save/AfterSaveAction.java @@ -0,0 +1,35 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.save; + +import com.inspur.edp.bff.api.manager.context.SaveContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class AfterSaveAction extends AbstractFSAction { + + private SaveContext saveContext; + protected final SaveContext getSaveContext() + { + return saveContext; + } + + protected AfterSaveAction(SaveContext context) + { + saveContext = context; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/save/BeforeSaveAction.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/save/BeforeSaveAction.java new file mode 100644 index 0000000..ac52cbf --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/action/save/BeforeSaveAction.java @@ -0,0 +1,35 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.action.save; + +import com.inspur.edp.bff.api.manager.context.SaveContext; +import com.inspur.edp.bff.spi.AbstractFSAction; +import com.inspur.edp.cef.api.VoidReturnType; + +public abstract class BeforeSaveAction extends AbstractFSAction { + + private SaveContext saveContext; + protected final SaveContext getSaveContext() + { + return saveContext; + } + + protected BeforeSaveAction(SaveContext context) + { + saveContext = context; + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/request/RequestConvertor.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/request/RequestConvertor.java new file mode 100644 index 0000000..6d7e0f0 --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/request/RequestConvertor.java @@ -0,0 +1,119 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.request; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.node.JsonNodeType; +import com.inspur.edp.bff.api.extend.IBffEntityExtend; +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.bff.spi.changeset.AbstractBffChangeJsonDeserializer; +import com.inspur.edp.bff.spi.utils.VoJsonDeserializer; +import com.inspur.edp.cef.api.manager.serialize.CefSerializeContext; +import com.inspur.edp.cef.api.request.RequestInfo; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefEntityResInfoImpl; +import com.inspur.edp.cef.variable.api.manager.IVariableManager; +import lombok.var; + +import java.io.IOException; +import java.util.List; + +public abstract class RequestConvertor extends VoJsonDeserializer { + + private static final String TitleDataChange = "dataChange"; + private static final String TitleVarChange = "variableChange"; + protected abstract RequestInfo createRequsetInfo(); + protected abstract AbstractBffChangeJsonDeserializer getJsonConverter(); + protected abstract IFSManager createFsManager(); + private CefSerializeContext context; + + @Override + public RequestInfo deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) + throws IOException, JsonProcessingException { + RequestInfo request = createRequsetInfo(); + ObjectMapper mapper = new ObjectMapper(); + JsonNode node = mapper.readValue(jsonParser, JsonNode.class); + JsonNode changeToken = node.get(TitleDataChange); + if (changeToken != null && changeToken.getNodeType() == JsonNodeType.ARRAY) + { + readDataChange(changeToken, request); + } + + JsonNode varChangeToken = node.get(TitleVarChange); + + IVariableManager varManager = createFsManager().createVariableManager(); + if (varChangeToken != null && varManager != null) + { + IChangeDetail varChange = varManager.deserializeChange(varChangeToken.toString()); + request.setVariableChange(varChange); + } + + return request; + } + + private void readDataChange(JsonNode changeToken, RequestInfo request) throws IOException { + + + for (JsonNode changeDetailToken : changeToken) { + { + //Object tempVar = JsonConvert.DeserializeObject(changeDetailToken, IChangeDetail.class, getJsonConverter().getChangeConvertor()); + + IChangeDetail change = getChangeJsonMapper().readValue(changeDetailToken.toString(), IChangeDetail.class); +// IChangeDetail change = (IChangeDetail) ((tempVar instanceof IChangeDetail) ? tempVar : null); + request.getDataChange().add(change); + } + } + } + + private ObjectMapper getChangeJsonMapper() + { + ObjectMapper mapper = new ObjectMapper(); + SimpleModule module = new SimpleModule(); + var convertor = getJsonConverter(); + if(extList != null){ + extList.forEach(item -> convertor.addExtend(item)); + } + convertor.setCefSerializeContext(context); + module.addDeserializer(IChangeDetail.class, convertor); + mapper.registerModule(module); + return mapper; + } + + private List extList; + public void setExtList(List extList) { + this.extList = extList; + } + + public void setContext(CefSerializeContext context) { + this.context = context; + } + + /** + * 表单运行时调用 + * + * @param nodeCode 节点编号 + * @return CefResourceInfo + */ + protected CefEntityResInfoImpl cefEntityResInfo(String nodeCode) { + return (CefEntityResInfoImpl) createFsManager().getModelInfo().getCustomResource(nodeCode); + } +} diff --git a/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/response/ResponseConvertor.java b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/response/ResponseConvertor.java new file mode 100644 index 0000000..93e079e --- /dev/null +++ b/bff-framework-spi/src/main/java/com/inspur/edp/bff/spi/response/ResponseConvertor.java @@ -0,0 +1,230 @@ +/* + * Copyright © OpenAtom Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.bff.spi.response; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.inspur.edp.bff.api.extend.IBffEntityExtend; +import com.inspur.edp.bff.api.manager.IFSManager; +import com.inspur.edp.bff.spi.AbstractBffEntitySerConvertor; +import com.inspur.edp.bff.spi.changeset.AbstractBffChangeJsonSerializer; +import com.inspur.edp.bff.spi.utils.VoJsonSerializer; +import com.inspur.edp.cef.api.manager.serialize.CefSerializeContext; +import com.inspur.edp.cef.api.manager.serialize.JsonFormatType; +import com.inspur.edp.cef.api.message.IBizMessage; +import com.inspur.edp.cef.api.response.ResponseInfo; +import com.inspur.edp.cef.entity.changeset.IChangeDetail; +import com.inspur.edp.cef.entity.entity.IEntityData; +import com.inspur.edp.cef.entity.entity.IEntityDataCollection; +import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefEntityResInfoImpl; +import com.inspur.edp.cef.variable.api.manager.IVariableManager; +import com.inspur.edp.commonmodel.spi.AbstractEntityDataSerializer; + +import java.io.IOException; +import java.util.HashMap; +import java.util.List; + +public abstract class ResponseConvertor extends VoJsonSerializer { + + + private static final String TitleResult = "returnValue"; + private static final String TitleInnerChange = "innerDataChange"; + private static final String TitleMessage = "message"; + private static final String TitleVarChange = "innerVariableChange"; + protected abstract IFSManager createFsManager(); + protected abstract AbstractBffChangeJsonSerializer getJsonConverter(); + private CefSerializeContext context; + private IFSManager fsManager; + private List extList; + @Override + public void serialize(ResponseInfo response, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) + throws IOException, JsonProcessingException { + + if (response == null) + { + return; + } + + fsManager = createFsManager(); + jsonGenerator.writeStartObject();//writer.WriteStartObject(); + //①ReturnValue + jsonGenerator.writeFieldName(TitleResult); //writer.WritePropertyName(TitleResult); + writeResult(jsonGenerator, response.getReturnValue(), serializerProvider); +// serializer.Serialize(writer, response.getReturnValue()); + //②InnerChange + //writer.WritePropertyName(TitleInnerChange); + jsonGenerator.writeFieldName(TitleInnerChange); + writeInnerChanges(jsonGenerator, response.getInnerDataChange(), serializerProvider); + //③Message + jsonGenerator.writeFieldName(TitleMessage);// writer.WritePropertyName(TitleMessage); + writeMessage(jsonGenerator, response.getMessage(), serializerProvider); + + //④InnerVariableChange + jsonGenerator.writeFieldName(TitleVarChange); + writeInnerVarChange(jsonGenerator, response.getInnerVariableChange(), serializerProvider); + + jsonGenerator.writeEndObject();// writer.WriteEndObject(); + } + + private void writeResult(JsonGenerator writer, Object result, SerializerProvider serializer) throws IOException { + + AbstractBffEntitySerConvertor dataConverter = getDataJsonConverter(); + + if(dataConverter == null|| context == null || context.getJsonFormatType() != JsonFormatType.Tiled){ + writer.writeObject(result); + return; + } + IEntityData data = fsManager.createData(); + Class dataClass = data.getClass().getInterfaces()[0]; + ObjectMapper mapper = getDefaultJsonMapper(); + SimpleModule module = new SimpleModule(); + if(extList != null){ + extList.forEach(item -> dataConverter.addExtend(item)); + } + dataConverter.setCefSerializeContext(context); + module.addSerializer(dataClass, dataConverter); + IBffEntityExtend rootEntityExtend=getRootEtityExtend(extList); + addChildConverter(data, module, dataConverter,rootEntityExtend); + mapper.configure(MapperFeature.USE_ANNOTATIONS, false); + mapper.registerModule(module); + String value = mapper.writeValueAsString(result); + writer.writeRawValue(value); + } + + private void addChildConverter(IEntityData currentData, SimpleModule module, AbstractEntityDataSerializer dataConverter,IBffEntityExtend parentEntityExtend){ + HashMap childs = currentData.getChilds(); + if(childs == null || childs.size() < 1) + return; + for(String nodeCode : childs.keySet()){ + IEntityData childData = (IEntityData)currentData.createChild(nodeCode); + Class dataClass = childData.getClass().getInterfaces()[0]; + AbstractEntityDataSerializer childConvertor = dataConverter.getChildDataConvertor(nodeCode); + IBffEntityExtend childEtityExtend=getChildEtityExtend(parentEntityExtend,nodeCode); + if(childEtityExtend != null){ + childConvertor.addExtend(childEtityExtend); + } + childConvertor.setCefSerializeContext(context); + module.addSerializer(dataClass, childConvertor); + addChildConverter(childData, module, childConvertor,childEtityExtend); + } + } + + private IBffEntityExtend getRootEtityExtend(List extendList){ + if(extendList==null) + return null; + IBffEntityExtend extend=null; + for (IBffEntityExtend rootEntityExtend :extendList){ + extend=rootEntityExtend; + } + return extend; + } + + private IBffEntityExtend getChildEtityExtend(IBffEntityExtend extend,String nodeCode){ + if(extend==null) + return null; + return extend.getChildEntity(nodeCode); + } + private void writeInnerVarChange(JsonGenerator writer, IChangeDetail innerVariableChange, SerializerProvider serializer) + { + + if (innerVariableChange != null) + { + IVariableManager varManager = fsManager.createVariableManager(); + try { + writer.writeRawValue(varManager.serializeChange(innerVariableChange)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + else + { + try { + writer.writeNull(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + + private void writeInnerChanges(JsonGenerator writer, java.util.HashMap innerChange, SerializerProvider serializer) throws IOException { + writer.writeStartArray(); + if (innerChange == null || innerChange.size() < 1) + { + writer.writeEndArray(); + return; + } + + for (IChangeDetail changeDetail : innerChange.values()) + { + writeInnerChanges(writer, changeDetail, serializer); + } + + writer.writeEndArray(); + } + + private void writeInnerChanges(JsonGenerator writer, IChangeDetail innerChange, SerializerProvider serializer) throws IOException { + AbstractBffChangeJsonSerializer converter = getJsonConverter(); + converter.setCefSerializeContext(context); + converter.writeJson(innerChange,writer, serializer); + } + + private void writeMessage(JsonGenerator writer, java.util.List message, SerializerProvider serializer) throws IOException { + if (message == null || message.size() < 1) + { + writer.writeStartArray(); + writer.writeEndArray(); + return; + } + + String messageStr = getDefaultJsonMapper().writeValueAsString(message); + writer.writeRawValue(messageStr); //WriteRawValue(messageStr); + } + + private ObjectMapper getDefaultJsonMapper() + { + ObjectMapper mapper = new ObjectMapper(); + SimpleModule module = new SimpleModule(); + mapper.registerModule(module); + return mapper; + } + + public void setExtList(List extList) { + this.extList = extList; + } + + public void setContext(CefSerializeContext context) { + this.context = context; + } + + protected AbstractBffEntitySerConvertor getDataJsonConverter(){ + return null; + } + + /** + * 表单运行时调用 + * + * @param nodeCode 节点编号 + * @return CefResourceInfo + */ + protected CefEntityResInfoImpl cefEntityResInfo(String nodeCode) { + return (CefEntityResInfoImpl) createFsManager().getModelInfo().getCustomResource(nodeCode); + } +} -- Gitee From 67823de58a64211bc9fbe8841434d3e95cda175c Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Wed, 2 Nov 2022 18:26:15 +0800 Subject: [PATCH 78/81] =?UTF-8?q?style(vo-runtime-api)=EF=BC=9A=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=A0=BC=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调整代码格式,代码风格 --- .../manager/context/DataMapperContext.java | 48 ++++++++----------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/DataMapperContext.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/DataMapperContext.java index 62c298c..8342ec9 100644 --- a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/DataMapperContext.java +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/DataMapperContext.java @@ -31,82 +31,76 @@ import java.util.HashMap; public class DataMapperContext { private HashMap> sourceData = new HashMap>(); + /** * 数据源(Be,Qo等)数据集合 * Key是数据源编号,内部默认Key值使用Default,开发时请注意不要使用该Key值,以免出现未知问题。 * Value是数据源数据 */ - public final HashMap> getSourceData() - { + public final HashMap> getSourceData() { return sourceData; } - public final void setSourceData(HashMap> value) - { + + public final void setSourceData(HashMap> value) { sourceData = value; } + private HashMap> mappedData = new HashMap>(); - - private HashMap> mappedData= new HashMap>(); /** * 映射结果集合 * Key是数据源编号,内部默认Key值使用Default,开发时请注意不要使用该Key值,以免出现未知问题。 * Value是数据源数据 * */ - public final HashMap> getMappedData() - { + public final HashMap> getMappedData() { return mappedData; } - public final void setMappedData(HashMap> value) - { + + public final void setMappedData(HashMap> value) { mappedData = value; } - private ArrayList targetResult = new ArrayList(); + /** * Vo数据集,这里的数据指的是:经过数据映射之后,将{@link #getSourceData()}方法中获取的源数据转换为vo结构的数据集 - * */ - public final ArrayList getTargetResult() - { + public final ArrayList getTargetResult() { return targetResult; } - public final void setTargetResult(ArrayList value) - { + + public final void setTargetResult(ArrayList value) { targetResult = value; } - - private boolean privateIsNew= false; + private boolean privateIsNew = false; /** * 判断数据是否是新增状态 + * * @return */ - public final boolean getIsNew() - { + public final boolean getIsNew() { return privateIsNew; } - public final void setIsNew(boolean value) - { + + public final void setIsNew(boolean value) { privateIsNew = value; } - private VoDefaultValue voDefaultValue; /** * 获取外部以及实体上设置的默认值 + * * @return */ - public final VoDefaultValue getVoDefaultValue() - { + public final VoDefaultValue getVoDefaultValue() { return voDefaultValue; } - public final void setVoDefaultValue(VoDefaultValue value) - { + + public final void setVoDefaultValue(VoDefaultValue value) { voDefaultValue = value; } } -- Gitee From 3b012190a6000d2648d3c930fcb73701a17e0eaa Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Wed, 2 Nov 2022 18:30:31 +0800 Subject: [PATCH 79/81] =?UTF-8?q?style(vo-runtime-api)=EF=BC=9A=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=A0=BC=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调整代码格式,代码风格 --- .../edp/bff/api/manager/context/ModifyContext.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/ModifyContext.java b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/ModifyContext.java index e7234f5..385edd8 100644 --- a/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/ModifyContext.java +++ b/bff-framework-api/src/main/java/com/inspur/edp/bff/api/manager/context/ModifyContext.java @@ -37,12 +37,11 @@ public class ModifyContext { { return sourceChange; } + public final void setSourceChange(ArrayList value) { sourceChange = value; } - - private HashMap> mappedChange = new HashMap>(); @@ -55,13 +54,12 @@ public class ModifyContext { { return mappedChange; } + public final void setMappedChange(HashMap> value) { mappedChange = value; } - - private HashMap> innerChange= new HashMap>(); /** * 内部变更集合,执行完变更操作后,将内部变更集写入 @@ -72,13 +70,12 @@ public class ModifyContext { { return innerChange; } + public final void setInnerChange(HashMap> value) { innerChange = value; } - - private ArrayList targetChange = new ArrayList(); /** @@ -88,6 +85,7 @@ public class ModifyContext { { return targetChange; } + public final void setTargetChange(ArrayList value) { targetChange = value; -- Gitee From 2912b2bd1d146d6b5434638ddf47cd11be584dd8 Mon Sep 17 00:00:00 2001 From: zhangjintr <1234qwer> Date: Fri, 4 Nov 2022 17:23:03 +0800 Subject: [PATCH 80/81] =?UTF-8?q?style(bff-framework-core):CancelAction?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E4=BB=A3=E7=A0=81=E7=BC=A9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bff/core/action/cancel/CancelAction.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/cancel/CancelAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/cancel/CancelAction.java index 7135388..986fd2e 100644 --- a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/cancel/CancelAction.java +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/cancel/CancelAction.java @@ -22,17 +22,14 @@ import com.inspur.edp.bff.spi.AbstractFSAction; public class CancelAction extends AbstractFSAction { - public CancelAction() - { - } + public CancelAction() { + } - @Override - protected void execute() - { - for (IStandardLcp lcp : getContext().getLcps().values()) - { - lcp.cancel(); - } + @Override + protected void execute() { + for (IStandardLcp lcp : getContext().getLcps().values()) { + lcp.cancel(); } + } } -- Gitee From 6b7d1781d4b60f4dc4eed9e9dfc0d77eb94c7412 Mon Sep 17 00:00:00 2001 From: qinxinyuan Date: Wed, 9 Nov 2022 15:31:08 +0800 Subject: [PATCH 81/81] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=96=B9=E6=B3=95=E7=9A=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../edp/bff/core/action/query/QueryAction.java | 14 ++++++++++++++ .../RetrieveWithChildPaginationAction.java | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryAction.java index c327c7b..2880e4a 100644 --- a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryAction.java +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/query/QueryAction.java @@ -69,6 +69,11 @@ public class QueryAction extends AbstractFSAction> { } } + /** + * 过滤条件转换 + * @param filterConditions 过滤条件 + * @param convertor + */ private void transFilter(ArrayList filterConditions, IFilterFieldConvertor convertor) { for (FilterCondition filterCondition : filterConditions) { if("".equals(filterCondition.getFilterField()) ||filterCondition.getFilterField()==null){ @@ -82,6 +87,11 @@ public class QueryAction extends AbstractFSAction> { } } + /** + * 排序条件转换 + * @param sortConditions 排序条件 + * @param convertor + */ private void transSort(ArrayList sortConditions, IFilterFieldConvertor convertor) { for (SortCondition sortCondition : sortConditions) { if("".equals(sortCondition.getSortField()) ||sortCondition.getSortField()==null){ @@ -177,6 +187,10 @@ public class QueryAction extends AbstractFSAction> { } + /** + * 删除扩展Mapping映射 + * @param voDatas + */ private void dealExtendMapping(ArrayList voDatas){ var extList = ((FSManagerContext)getContext()).getExtList(); if( extList == null || extList.size() <1) diff --git a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveWithChildPaginationAction.java b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveWithChildPaginationAction.java index 48615ca..1cc938f 100644 --- a/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveWithChildPaginationAction.java +++ b/bff-framework-core/src/main/java/com/inspur/edp/bff/core/action/retrieve/RetrieveWithChildPaginationAction.java @@ -52,6 +52,13 @@ public class RetrieveWithChildPaginationAction extends AbstractFSAction pageResult) { HashMap entityDatas = baseData.getChilds(); IEntityDataCollection childData = null; -- Gitee