From b2c0d3bd1c25bcf61d78fbc8fd18db39723533ac Mon Sep 17 00:00:00 2001 From: Lukas Fey <107985579+LukasFey-GIP@users.noreply.github.com> Date: Wed, 23 Oct 2024 07:47:06 +0200 Subject: [PATCH] [yang] workflow defined mask in factory manager 1112 (#1189) --- .../yang/XMOM/xdev/yang/YangAppGeneration.xml | 47 +++ .../yang/YangAppGenerationInputParameter.xml | 6 +- .../xmcp/yang/LoadYangAssignmentsData.xml | 42 +++ .../xmcp/yang/UseCaseAssignmentTableData.xml | 38 ++ .../yang/XMOM/xmcp/yang/UseCaseTableData.xml | 47 +++ .../XMOM/xmcp/yang/YangImportTableData.xml | 37 ++ .../yang/XMOM/xmcp/yang/fman/AddUseCase.xml | 67 ++++ .../xmcp/yang/fman/DefineAddUsecaseDialog.xml | 260 +++++++++++++ .../DefineImportModuleCollectionDialog.xml | 220 +++++++++++ .../fman/DefineImportYangDeviceDialog.xml | 220 +++++++++++ .../yang/fman/ImportYangDeviceApplication.xml | 81 ++++ .../ImportYangModuleCollectionApplication.xml | 93 +++++ .../xmcp/yang/fman/SaveUseCaseAssignment.xml | 39 ++ .../yang/fman/UseCaseAssignmentTableInfo.xml | 357 ++++++++++++++++++ .../fman/UseCaseAssignmentsDefinition.xml | 191 ++++++++++ .../XMOM/xmcp/yang/fman/UseCaseDefinition.xml | 118 ++++++ .../fman/UseCaseRootAssignmentsDefinition.xml | 91 +++++ .../XMOM/xmcp/yang/fman/UseCaseTableInfo.xml | 353 +++++++++++++++++ .../xmcp/yang/fman/YangImportDefinition.xml | 210 +++++++++++ modules/xdev/yang/application.xml | 78 +++- modules/xdev/yang/build.xml | 4 +- .../mdmimpl/YangAppGenerationImpl/build.xml | 13 +- .../mdmimpl/YangAppGenerationImpl/pom.xml | 4 +- .../src/xdev/yang/impl/Constants.java | 45 +++ .../src/xdev/yang/impl/PluginManagement.java | 70 ++++ .../src/xdev/yang/impl/XmomDbInteraction.java | 70 ++++ ...angAppGenerationInstanceOperationImpl.java | 2 +- ...YangAppGenerationServiceOperationImpl.java | 95 ++++- .../yang/impl/YangApplicationGeneration.java | 46 ++- .../xdev/yang/impl/usecase/AddUsecase.java | 161 ++++++++ .../usecase/DetermineUseCaseAssignments.java | 162 ++++++++ .../yang/impl/usecase/LoadUsecasesTable.java | 158 ++++++++ .../usecase/SaveUsecaseAssignmentAction.java | 101 +++++ .../impl/usecase/UseCaseAssignmentUtils.java | 323 ++++++++++++++++ .../yang/impl/usecase/UseCaseMapping.java | 113 ++++++ .../xmldefinition/YangAppGeneration.xml | 47 +++ 36 files changed, 3956 insertions(+), 53 deletions(-) create mode 100644 modules/xdev/yang/XMOM/xmcp/yang/LoadYangAssignmentsData.xml create mode 100644 modules/xdev/yang/XMOM/xmcp/yang/UseCaseAssignmentTableData.xml create mode 100644 modules/xdev/yang/XMOM/xmcp/yang/UseCaseTableData.xml create mode 100644 modules/xdev/yang/XMOM/xmcp/yang/YangImportTableData.xml create mode 100644 modules/xdev/yang/XMOM/xmcp/yang/fman/AddUseCase.xml create mode 100644 modules/xdev/yang/XMOM/xmcp/yang/fman/DefineAddUsecaseDialog.xml create mode 100644 modules/xdev/yang/XMOM/xmcp/yang/fman/DefineImportModuleCollectionDialog.xml create mode 100644 modules/xdev/yang/XMOM/xmcp/yang/fman/DefineImportYangDeviceDialog.xml create mode 100644 modules/xdev/yang/XMOM/xmcp/yang/fman/ImportYangDeviceApplication.xml create mode 100644 modules/xdev/yang/XMOM/xmcp/yang/fman/ImportYangModuleCollectionApplication.xml create mode 100644 modules/xdev/yang/XMOM/xmcp/yang/fman/SaveUseCaseAssignment.xml create mode 100644 modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseAssignmentTableInfo.xml create mode 100644 modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseAssignmentsDefinition.xml create mode 100644 modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseDefinition.xml create mode 100644 modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseRootAssignmentsDefinition.xml create mode 100644 modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseTableInfo.xml create mode 100644 modules/xdev/yang/XMOM/xmcp/yang/fman/YangImportDefinition.xml create mode 100644 modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/Constants.java create mode 100644 modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/PluginManagement.java create mode 100644 modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/XmomDbInteraction.java create mode 100644 modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/AddUsecase.java create mode 100644 modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/DetermineUseCaseAssignments.java create mode 100644 modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/LoadUsecasesTable.java create mode 100644 modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/SaveUsecaseAssignmentAction.java create mode 100644 modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/UseCaseAssignmentUtils.java create mode 100644 modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/UseCaseMapping.java diff --git a/modules/xdev/yang/XMOM/xdev/yang/YangAppGeneration.xml b/modules/xdev/yang/XMOM/xdev/yang/YangAppGeneration.xml index 6122a727c..38370cb6a 100644 --- a/modules/xdev/yang/XMOM/xdev/yang/YangAppGeneration.xml +++ b/modules/xdev/yang/XMOM/xdev/yang/YangAppGeneration.xml @@ -22,6 +22,11 @@ YangAppGenerationImpl.jar yangkit + + + xmcp.forms.plugin.PluginManagement + + @@ -40,5 +45,47 @@ YangAppGenerationImpl.createYangDeviceApp(yangAppGenerationInputParameter2); + + + + + + + + + return xdev.yang.YangAppGenerationImpl.loadAssignments(loadYangAssignmentsData7); + + + + + + + + + return xdev.yang.YangAppGenerationImpl.loadUsecases(); + + + + + + + + + + + + + xdev.yang.YangAppGenerationImpl.addUsecase(correlatedXynaOrder, text2, text3, workspace5, text8, text9); + + + + + + + + + xdev.yang.YangAppGenerationImpl.saveAssignment(correlatedXynaOrder, useCaseAssignmentTableData10); + + diff --git a/modules/xdev/yang/XMOM/xdev/yang/YangAppGenerationInputParameter.xml b/modules/xdev/yang/XMOM/xdev/yang/YangAppGenerationInputParameter.xml index eb2aeea34..806a2a26a 100644 --- a/modules/xdev/yang/XMOM/xdev/yang/YangAppGenerationInputParameter.xml +++ b/modules/xdev/yang/XMOM/xdev/yang/YangAppGenerationInputParameter.xml @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + --> false @@ -34,7 +34,5 @@ String - - + - diff --git a/modules/xdev/yang/XMOM/xmcp/yang/LoadYangAssignmentsData.xml b/modules/xdev/yang/XMOM/xmcp/yang/LoadYangAssignmentsData.xml new file mode 100644 index 000000000..337f227cb --- /dev/null +++ b/modules/xdev/yang/XMOM/xmcp/yang/LoadYangAssignmentsData.xml @@ -0,0 +1,42 @@ + + + + false + + + + String + + + + + String + + + + + String + + + + + String + + + diff --git a/modules/xdev/yang/XMOM/xmcp/yang/UseCaseAssignmentTableData.xml b/modules/xdev/yang/XMOM/xmcp/yang/UseCaseAssignmentTableData.xml new file mode 100644 index 000000000..e2400b74c --- /dev/null +++ b/modules/xdev/yang/XMOM/xmcp/yang/UseCaseAssignmentTableData.xml @@ -0,0 +1,38 @@ + + + + false + + + + String + + + + + String + + + + + String + + + + diff --git a/modules/xdev/yang/XMOM/xmcp/yang/UseCaseTableData.xml b/modules/xdev/yang/XMOM/xmcp/yang/UseCaseTableData.xml new file mode 100644 index 000000000..fc6a542f0 --- /dev/null +++ b/modules/xdev/yang/XMOM/xmcp/yang/UseCaseTableData.xml @@ -0,0 +1,47 @@ + + + + false + + + + String + + + + + String + + + + + String + + + + + String + + + + + int + + + diff --git a/modules/xdev/yang/XMOM/xmcp/yang/YangImportTableData.xml b/modules/xdev/yang/XMOM/xmcp/yang/YangImportTableData.xml new file mode 100644 index 000000000..16abf0dab --- /dev/null +++ b/modules/xdev/yang/XMOM/xmcp/yang/YangImportTableData.xml @@ -0,0 +1,37 @@ + + + + false + + + + String + + + + + String + + + + + long + + + diff --git a/modules/xdev/yang/XMOM/xmcp/yang/fman/AddUseCase.xml b/modules/xdev/yang/XMOM/xmcp/yang/fman/AddUseCase.xml new file mode 100644 index 000000000..7cf6737c9 --- /dev/null +++ b/modules/xdev/yang/XMOM/xmcp/yang/fman/AddUseCase.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + UserConnected + + + + + UserConnected + + + + + + UserConnected + + + + + UserConnected + + + + + + + + diff --git a/modules/xdev/yang/XMOM/xmcp/yang/fman/DefineAddUsecaseDialog.xml b/modules/xdev/yang/XMOM/xmcp/yang/fman/DefineAddUsecaseDialog.xml new file mode 100644 index 000000000..976778a1f --- /dev/null +++ b/modules/xdev/yang/XMOM/xmcp/yang/fman/DefineAddUsecaseDialog.xml @@ -0,0 +1,260 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %1%.label="Usecase Group" + %1%.dataPath="%0%.text" + %2%.label="Usecase Name" + %2%.dataPath="%1%.text" + %3%.label="Workspace" + %3%.dataPath="%2%.name" + %4%.label="RPC" + %4%.dataPath="%3%.text" + %5%.label="Device Fqn" + %5%.dataPath="%4%.text" + %6%.dataPath="%0%, %1%, %2%, %3%, %4%" + %6%.label="Create Usecase" + %6%.serviceRTC=%0% + %6%.serviceFQN="xmcp.yang.fman.AddUseCase" + %6%.synchronously="true" + + + + + + + + + UserConnected + + + + + + + + + + UserConnected + + + + + + + + + + UserConnected + + + + + + + + + + UserConnected + + + + + + + + + + UserConnected + + + + + + + + + + + + + + + + %6%.label="Add Usecase" + %6%.children["0"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%0% + %6%.children["1"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%1% + %6%.children["2"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%2% + %6%.children["3"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%3% + %6%.children["4"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%4% + %6%.children["5"]#cast("xmcp.forms.datatypes.StartOrderButtonDefinition")=%5% + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Constant + + + + + + + + Constant + + + + + + + + Constant + + + + + + + + Constant + + + + + + + + Constant + + + + + + + diff --git a/modules/xdev/yang/XMOM/xmcp/yang/fman/DefineImportModuleCollectionDialog.xml b/modules/xdev/yang/XMOM/xmcp/yang/fman/DefineImportModuleCollectionDialog.xml new file mode 100644 index 000000000..914cef98c --- /dev/null +++ b/modules/xdev/yang/XMOM/xmcp/yang/fman/DefineImportModuleCollectionDialog.xml @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %1%.label="Application Name" + %1%.dataPath="%0%.text" + %2%.label="Application Version" + %2%.dataPath="%1%.text" + %3%.label="Datatype FQN" + %3%.dataPath="%2%.text" + %4%.label="Upload Yang Modules" + %4%.dataPath="%3%.id" + %5%.label="Create Yang Module Collection Application" + %5%.dataPath="%0%, %1%, %2%, %3%" + %5%.serviceRTC=%0% + %5%.serviceFQN="xmcp.yang.fman.ImportYangModuleCollectionApplication" + + + + + + + + + UserConnected + + + + + + + + + + UserConnected + + + + + + + + + + UserConnected + + + + + + + + + + + + + + + + + + + + + + %5%.children["0"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%0% + %5%.children["1"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%1% + %5%.children["2"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%2% + %5%.children["3"]#cast("xmcp.forms.datatypes.UploadButtonDefinition")=%3% + %5%.children["4"]#cast("xmcp.forms.datatypes.StartOrderButtonDefinition")=%4% + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Constant + + + + + + + + Constant + + + + + + + + Constant + + + + + + + + Constant + + + + + + + diff --git a/modules/xdev/yang/XMOM/xmcp/yang/fman/DefineImportYangDeviceDialog.xml b/modules/xdev/yang/XMOM/xmcp/yang/fman/DefineImportYangDeviceDialog.xml new file mode 100644 index 000000000..b342f7f64 --- /dev/null +++ b/modules/xdev/yang/XMOM/xmcp/yang/fman/DefineImportYangDeviceDialog.xml @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %1%.label="Application Name" + %1%.dataPath="%0%.text" + %2%.label="Application Version" + %2%.dataPath="%1%.text" + %3%.label="Datatype FQN" + %3%.dataPath="%2%.text" + %4%.label="Upload Capabilities File" + %4%.dataPath="%3%.id" + %5%.label="Create Yang Device Application" + %5%.dataPath="%0%, %1%, %2%, %3%" + %5%.serviceRTC=%0% + %5%.serviceFQN="xmcp.yang.fman.ImportYangDeviceApplication" + + + + + + + + + UserConnected + + + + + + + + + + UserConnected + + + + + + + + + + UserConnected + + + + + + + + + + + + + + + + + + + + + + %5%.children["0"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%0% + %5%.children["1"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%1% + %5%.children["2"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%2% + %5%.children["3"]#cast("xmcp.forms.datatypes.UploadButtonDefinition")=%3% + %5%.children["4"]#cast("xmcp.forms.datatypes.StartOrderButtonDefinition")=%4% + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Constant + + + + + + + + Constant + + + + + + + + Constant + + + + + + + + Constant + + + + + + + diff --git a/modules/xdev/yang/XMOM/xmcp/yang/fman/ImportYangDeviceApplication.xml b/modules/xdev/yang/XMOM/xmcp/yang/fman/ImportYangDeviceApplication.xml new file mode 100644 index 000000000..8e6f3f538 --- /dev/null +++ b/modules/xdev/yang/XMOM/xmcp/yang/fman/ImportYangDeviceApplication.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + UserConnected + + + + + + + + UserConnected + + + + + + + + UserConnected + + + + + + + + + + + + %4%.applicationName=%0%.text + %4%.versionName=%1%.text + %4%.dataTypeFQN=%2%.text + %4%.fileID=%3% + + + + + + + + + + + + + + diff --git a/modules/xdev/yang/XMOM/xmcp/yang/fman/ImportYangModuleCollectionApplication.xml b/modules/xdev/yang/XMOM/xmcp/yang/fman/ImportYangModuleCollectionApplication.xml new file mode 100644 index 000000000..34e48af31 --- /dev/null +++ b/modules/xdev/yang/XMOM/xmcp/yang/fman/ImportYangModuleCollectionApplication.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + UserConnected + + + + + + + + + + UserConnected + + + + + + + + + + UserConnected + + + + + + + + + + + + + + + + %4%.applicationName=%0%.text + %4%.versionName=%1%.text + %4%.dataTypeFQN=%2%.text + %4%.fileID=%3% + + + + + + + + + + + + + + + + diff --git a/modules/xdev/yang/XMOM/xmcp/yang/fman/SaveUseCaseAssignment.xml b/modules/xdev/yang/XMOM/xmcp/yang/fman/SaveUseCaseAssignment.xml new file mode 100644 index 000000000..5a381af4d --- /dev/null +++ b/modules/xdev/yang/XMOM/xmcp/yang/fman/SaveUseCaseAssignment.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseAssignmentTableInfo.xml b/modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseAssignmentTableInfo.xml new file mode 100644 index 000000000..dcc1cf510 --- /dev/null +++ b/modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseAssignmentTableInfo.xml @@ -0,0 +1,357 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Constant + xmcp.yang.UseCaseAssignmentTableData + + + + + Constant + + + + + + + + + + + + + + + + + + + + + + + + + + + + %1%=%0% + + + + + + + + + + + + + + + + + + + + + + + + + %1%=%0%.loadYangAssignmentsData + + + + + + + + + + + + + + + + + + + String + + + + + String + + + + + String + + + + + + + + + String + + Type + + + + String + + type + + + + String + + + + + String + + + + + boolean + + true + + + + boolean + + true + + + + boolean + + true + + + + boolean + + false + + + + boolean + + false + + + + String + + + + + + + + + String + + Yang Path + + + + String + + yangPath + + + + String + + + + + String + + + + + boolean + + true + + + + boolean + + true + + + + boolean + + true + + + + boolean + + false + + + + boolean + + false + + + + String + + + + + + + + + String + + Value + + + + String + + value + + + + String + + + + + String + + + + + boolean + + true + + + + boolean + + true + + + + boolean + + true + + + + boolean + + false + + + + boolean + + false + + + + String + + + + + + + + + + + + + + + + + + + + UserConnected + + + + + + + + + + + diff --git a/modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseAssignmentsDefinition.xml b/modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseAssignmentsDefinition.xml new file mode 100644 index 000000000..606743760 --- /dev/null +++ b/modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseAssignmentsDefinition.xml @@ -0,0 +1,191 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %1%.fQN="xmcp.yang.fman.UseCaseAssignmentsDefinition" + %1%.rTC=%0% + + + + + + + + + + + + + + + + + + + + + + + + + + + %3%.detailsDefinitionReference#cast("xmcp.forms.datatypes.DefinitionWorkflow")=%0% + %3%.tableWorkflowFQN="xmcp.yang.fman.UseCaseAssignmentTableInfo" + %3%.tableWorkflowRTC=%1% + %3%.label=%2%.yangPath + %3%.dataPath="%0%" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %1%.dataPath="%0%.value" + %2%.dataPath="%0%" + %2%.serviceFQN="xmcp.yang.fman.SaveUseCaseAssignment" + %2%.serviceRTC=%0% + %2%.label="Save" + + + + + + + + + + + + + + + + + + + + + + + + + + + %3%.children["0"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%0% + %3%.children["1"]#cast("xmcp.forms.datatypes.StartOrderButtonDefinition")=%1% + %3%.label=%2%.yangPath + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseDefinition.xml b/modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseDefinition.xml new file mode 100644 index 000000000..0bf7ffcc1 --- /dev/null +++ b/modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseDefinition.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %1%.label="add" + %1%.dialogDefinitionReference#cast("xmcp.forms.datatypes.DefinitionWorkflow").rTC=%0% + %1%.dialogDefinitionReference#cast("xmcp.forms.datatypes.DefinitionWorkflow").fQN="xmcp.yang.fman.DefineAddUsecaseDialog" + + + + + + + + + + + + + + + %1%.fQN="xmcp.yang.fman.UseCaseRootAssignmentsDefinition" + %1%.rTC=%0% + + + + + + + + + + + + + + + + + + + + + + + + + %3%.header.rightArea.children["0"]#cast("xmcp.forms.datatypes.OpenDialogButtonDefinition")=%0% + %3%.detailsDefinitionReference#cast("xmcp.forms.datatypes.DefinitionWorkflow")=%1% + %3%.tableWorkflowFQN="xmcp.yang.fman.UseCaseTableInfo" + %3%.tableWorkflowRTC=%2% + %3%.dataPath="%%" + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseRootAssignmentsDefinition.xml b/modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseRootAssignmentsDefinition.xml new file mode 100644 index 000000000..6a1b520ed --- /dev/null +++ b/modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseRootAssignmentsDefinition.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + %1%.type="Rpc" + %1%.loadYangAssignmentsData.totalYangPath=%0%.rpcName + %1%.loadYangAssignmentsData.fqn=%0%.usecaseGroup + %1%.loadYangAssignmentsData.usecase=%0%.useCase + %1%.loadYangAssignmentsData.workspaceName=%0%.runtimeContext + %1%.yangPath=%0%.rpcName + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UserConnected + + + + + + + diff --git a/modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseTableInfo.xml b/modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseTableInfo.xml new file mode 100644 index 000000000..58575dbb8 --- /dev/null +++ b/modules/xdev/yang/XMOM/xmcp/yang/fman/UseCaseTableInfo.xml @@ -0,0 +1,353 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Constant + xmcp.yang.UseCaseTableData + + + + + Constant + + + + + + + + + + + + + + + + + + + + + + + + + + + + %1%=%0% + + + + + + + + + + + + + + + + + + + + + + + + + + String + + + + + String + + + + + int + + 0 + + + + + + + + + + + boolean + + false + + + + String + + usecaseGroup + + + + boolean + + false + + + + boolean + + false + + + + boolean + + false + + + + String + + Use Case Group + + + + boolean + + false + + + + + + + + boolean + + false + + + + String + + useCase + + + + boolean + + false + + + + boolean + + false + + + + boolean + + false + + + + String + + Use Case + + + + boolean + + false + + + + + + + + boolean + + false + + + + String + + rpcName + + + + boolean + + false + + + + boolean + + false + + + + boolean + + false + + + + String + + Rpc + + + + boolean + + false + + + + + + + + boolean + + false + + + + String + + runtimeContext + + + + boolean + + false + + + + boolean + + false + + + + boolean + + false + + + + String + + Runtime Context + + + + boolean + + false + + + + + + + + String + + mappingCount + + + + String + + Mapping Count + + + + + + + + + + + + + UserConnected + + + + + + + + + + + diff --git a/modules/xdev/yang/XMOM/xmcp/yang/fman/YangImportDefinition.xml b/modules/xdev/yang/XMOM/xmcp/yang/fman/YangImportDefinition.xml new file mode 100644 index 000000000..b3d876ec5 --- /dev/null +++ b/modules/xdev/yang/XMOM/xmcp/yang/fman/YangImportDefinition.xml @@ -0,0 +1,210 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %2%.label="Import Yang module collection" + %2%.dialogDefinitionReference#cast("xmcp.forms.datatypes.DefinitionWorkflow").rTC=%1% + %2%.dialogDefinitionReference#cast("xmcp.forms.datatypes.DefinitionWorkflow").fQN="xmcp.yang.fman.DefineImportModuleCollectionDialog" + %3%.label="Import Yang device application" + %3%.dialogDefinitionReference#cast("xmcp.forms.datatypes.DefinitionWorkflow").rTC=%1% + %3%.dialogDefinitionReference#cast("xmcp.forms.datatypes.DefinitionWorkflow").fQN="xmcp.yang.fman.DefineImportYangDeviceDialog" + %4%.label="Open Use Cases" + %4%.detailsDefinitionReference#cast("xmcp.forms.datatypes.TablePanelDefinition")=%0% + + + + + + + + + + + %1%.label="Create Usecase" + %1%.dialogDefinitionReference#cast("xmcp.forms.datatypes.DefinitionWorkflow").rTC=%0% + %1%.dialogDefinitionReference#cast("xmcp.forms.datatypes.DefinitionWorkflow").fQN="xmcp.yang.fman.DefineAddUsecaseDialog" + + + + + + + + + + + %1%.fQN="xmcp.yang.fman.UseCaseRootAssignmentsDefinition" + %1%.rTC=%0% + + + + + + + + + UserConnected + + + + + + + + + + UserConnected + + + + + + + + + + UserConnected + + + + + + + + + + UserConnected + + + + + + + + + + + + + + + + %5%.dataPath="%%" + %5%.detailsDefinitionReference#cast("xmcp.forms.datatypes.DefinitionWorkflow")=%4% + %5%.header.rightArea.children["0"]#cast("xmcp.forms.datatypes.OpenDialogButtonDefinition")=%0% + %5%.header.rightArea.children["1"]#cast("xmcp.forms.datatypes.OpenDialogButtonDefinition")=%1% + %5%.header.rightArea.children["2"]#cast("xmcp.forms.datatypes.OpenDialogButtonDefinition")=%2% + %5%.label="Usecases" + %5%.tableWorkflowFQN="xmcp.yang.fman.UseCaseTableInfo" + %5%.tableWorkflowRTC=%3% + + + + + + + + + + + + + + + + + + + + + + + + + + + + UserConnected + + + + + + + diff --git a/modules/xdev/yang/application.xml b/modules/xdev/yang/application.xml index 018c4fc12..e1e514d64 100644 --- a/modules/xdev/yang/application.xml +++ b/modules/xdev/yang/application.xml @@ -15,17 +15,17 @@ * See the License for the specific language governing permissions and * limitations under the License. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ---> +--> - - Processing - 1.0.22 - YangBase 1.0.0 + + GuiHttp + 1.3.0 + @@ -34,6 +34,50 @@ + + xmcp.yang.UseCaseAssignmentTableData + DATATYPE + + + xmcp.yang.UseCaseTableData + DATATYPE + + + xmcp.yang.YangImportTableData + DATATYPE + + + xmcp.yang.fman.AddUseCase + WORKFLOW + + + xmcp.yang.fman.SaveUseCaseAssignment + WORKFLOW + + + xmcp.yang.fman.UseCaseAssignmentsDefinition + WORKFLOW + + + xmcp.yang.fman.UseCaseAssignmentTableInfo + WORKFLOW + + + xmcp.yang.fman.UseCaseDefinition + WORKFLOW + + + xmcp.yang.fman.UseCaseRootAssignmentsDefinition + WORKFLOW + + + xmcp.yang.fman.UseCaseTableInfo + WORKFLOW + + + xmcp.yang.fman.YangImportDefinition + WORKFLOW + xdev.yang.YangAppGeneration DATATYPE @@ -42,5 +86,29 @@ xdev.yang.YangAppGenerationInputParameter DATATYPE + + xmcp.yang.LoadYangAssignmentsData + DATATYPE + + + xmcp.yang.fman.DefineAddUsecaseDialog + WORKFLOW + + + xmcp.yang.fman.DefineImportModuleCollectionDialog + WORKFLOW + + + xmcp.yang.fman.DefineImportYangDeviceDialog + WORKFLOW + + + xmcp.yang.fman.ImportYangDeviceApplication + WORKFLOW + + + xmcp.yang.fman.ImportYangModuleCollectionApplication + WORKFLOW + diff --git a/modules/xdev/yang/build.xml b/modules/xdev/yang/build.xml index e8b9df334..436a5bbda 100644 --- a/modules/xdev/yang/build.xml +++ b/modules/xdev/yang/build.xml @@ -31,11 +31,11 @@ - + - + diff --git a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/build.xml b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/build.xml index a95d2d476..703e8bd1b 100644 --- a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/build.xml +++ b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/build.xml @@ -23,21 +23,26 @@ + + + + - - + - + + - + + diff --git a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/pom.xml b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/pom.xml index ba4b9df6c..138d5da3d 100644 --- a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/pom.xml +++ b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/pom.xml @@ -26,8 +26,8 @@ 4.0.0 com.gip.xyna - YangModuleCollectionImpl - 0.5.0 + YangAppGeneration + 1.0.0 jar UTF-8 diff --git a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/Constants.java b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/Constants.java new file mode 100644 index 000000000..057f08296 --- /dev/null +++ b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/Constants.java @@ -0,0 +1,45 @@ +/* + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Copyright 2024 Xyna GmbH, Germany + * + * 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 xdev.yang.impl; + + +public class Constants { + + public static final String ATT_YANG_TYPE = "type"; + public static final String ATT_MAPPING_YANGPATH = "yang"; + public static final String ATT_MAPPING_VALUE = "config"; + public static final String ATT_MAPPING_NAMESPACE = "namespace"; + + public static final String TAG_YANG = "Yang"; + public static final String TAG_RPC = "Rpc"; + public static final String TAG_DEVICE_FQN = "DeviceFqn"; + public static final String TAG_MAPPINGS = "Mappings"; + public static final String TAG_MAPPING = "Mapping"; + + public static final String TAG_HELLO = "hello"; + public static final String TAG_CAPABILITIES = "capabilities"; + public static final String TAG_CAPABILITY = "capability"; + + public static final String VAL_USECASE = "Usecase"; + public static final String VAL_MODULECOLLECTION = "ModuleCollection"; + public static final String VAL_DEVICE = "Capabilities"; + + public static final String TYPE_CONTAINER = "container"; + public static final String TYPE_LEAF = "leaf"; + public static final String TYPE_GROUPING = "grouping"; +} diff --git a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/PluginManagement.java b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/PluginManagement.java new file mode 100644 index 000000000..b4accd8c0 --- /dev/null +++ b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/PluginManagement.java @@ -0,0 +1,70 @@ +/* + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Copyright 2024 Xyna GmbH, Germany + * + * 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 xdev.yang.impl; + + + +import com.gip.xyna.xfmg.xfctrl.classloading.ClassLoaderBase; + +import base.math.IntegerNumber; +import xfmg.xfctrl.appmgmt.RuntimeContextService; +import xmcp.forms.plugin.Plugin; +import xprc.xpce.Application; +import xprc.xpce.RuntimeContext; + + + +public class PluginManagement { + + private static Plugin createPlugin(Class creator) { + Plugin.Builder result = new Plugin.Builder(); + result.definitionWorkflowFQN("xmcp.yang.fman.YangImportDefinition"); + RuntimeContext rtc = getOwnRtc(creator); + String entryName = "Yang"; + if (rtc == null) { + return null; + } + if (rtc instanceof Application) { + entryName = entryName + " " + ((Application) rtc).getVersion(); + } + result.navigationEntryLabel(entryName); + result.navigationEntryName(entryName); + result.path("manager"); + result.pluginRTC(rtc); + return result.instance(); + } + + + private static RuntimeContext getOwnRtc(Class creator) { + ClassLoaderBase clb = (ClassLoaderBase) creator.getClassLoader(); + Long revision = clb.getRevision(); + return RuntimeContextService.getRuntimeContextFromRevision(new IntegerNumber(revision)); + } + + + public static void registerPlugin(Class creator) { + Plugin plugin = createPlugin(creator); + xmcp.forms.plugin.PluginManagement.registerPlugin(plugin); + } + + + public static void unregisterPlugin(Class creator) { + Plugin plugin = createPlugin(creator); + xmcp.forms.plugin.PluginManagement.unregisterPlugin(plugin); + } +} diff --git a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/XmomDbInteraction.java b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/XmomDbInteraction.java new file mode 100644 index 000000000..305d5bc97 --- /dev/null +++ b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/XmomDbInteraction.java @@ -0,0 +1,70 @@ +/* + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Copyright 2024 Xyna GmbH, Germany + * + * 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 xdev.yang.impl; + + + +import java.util.ArrayList; +import java.util.List; + +import com.gip.xyna.XynaFactory; +import com.gip.xyna.xfmg.xfctrl.xmomdatabase.XMOMDatabase; +import com.gip.xyna.xfmg.xfctrl.xmomdatabase.XMOMDatabaseEntryColumn; +import com.gip.xyna.xfmg.xfctrl.xmomdatabase.XMOMDatabaseType; +import com.gip.xyna.xfmg.xfctrl.xmomdatabase.search.XMOMDatabaseSearchResult; +import com.gip.xyna.xfmg.xfctrl.xmomdatabase.search.XMOMDatabaseSearchResultEntry; +import com.gip.xyna.xfmg.xfctrl.xmomdatabase.search.XMOMDatabaseSelect; +import com.gip.xyna.xnwh.exceptions.XNWH_WhereClauseBuildException; + + + +public class XmomDbInteraction { + + + public List searchYangDTs(String baseClassFqn, List revisions) { + try { + List result = new ArrayList<>(); + XMOMDatabase xmomDb = XynaFactory.getInstance().getFactoryManagement().getXynaFactoryControl().getXMOMDatabase(); + for (Long revision : revisions) { + List selects = buildSelects(baseClassFqn); // new selects are required for every XMOM database search + XMOMDatabaseSearchResult xmomDbSearchResult = xmomDb.searchXMOMDatabase(selects, -1, revision); + List xmomDbResults = xmomDbSearchResult.getResult(); + result.addAll(xmomDbResults); + } + + return result; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + + private List buildSelects(String baseClassFqn) { + List selects = new ArrayList<>(); + XMOMDatabaseSelect select = new XMOMDatabaseSelect(); + select.addAllDesiredResultTypes(List.of(XMOMDatabaseType.SERVICEGROUP, XMOMDatabaseType.DATATYPE)); + try { + select.where(XMOMDatabaseEntryColumn.EXTENDS).isEqual(baseClassFqn); + } catch (XNWH_WhereClauseBuildException e) { + throw new RuntimeException(e); + } + selects.add(select); + + return selects; + } +} diff --git a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/YangAppGenerationInstanceOperationImpl.java b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/YangAppGenerationInstanceOperationImpl.java index f061aed29..d423deb7d 100644 --- a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/YangAppGenerationInstanceOperationImpl.java +++ b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/YangAppGenerationInstanceOperationImpl.java @@ -1,6 +1,6 @@ /* * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Copyright 2022 Xyna GmbH, Germany + * Copyright 2024 Xyna GmbH, Germany * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/YangAppGenerationServiceOperationImpl.java b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/YangAppGenerationServiceOperationImpl.java index cc2f7a8e0..d44831282 100644 --- a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/YangAppGenerationServiceOperationImpl.java +++ b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/YangAppGenerationServiceOperationImpl.java @@ -1,6 +1,6 @@ /* * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Copyright 2022 Xyna GmbH, Germany + * Copyright 2024 Xyna GmbH, Germany * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,29 +18,52 @@ package xdev.yang.impl; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.List; +import org.apache.log4j.Logger; + +import com.gip.xyna.CentralFactoryLogging; +import com.gip.xyna.XynaFactory; import com.gip.xyna.utils.exceptions.XynaException; import com.gip.xyna.xdev.xfractmod.xmdm.XynaObject.BehaviorAfterOnUnDeploymentTimeout; import com.gip.xyna.xdev.xfractmod.xmdm.XynaObject.ExtendedDeploymentTask; +import com.gip.xyna.xfmg.xfctrl.filemgmt.FileManagement; +import com.gip.xyna.xmcp.xfcli.generated.Importapplication; +import com.gip.xyna.xmcp.xfcli.impl.ImportapplicationImpl; +import com.gip.xyna.xprc.XynaOrderServerExtension; +import base.Text; import xdev.yang.YangAppGenerationInputParameter; import xdev.yang.YangAppGenerationServiceOperation; import xdev.yang.cli.generated.OverallInformationProvider; - +import xdev.yang.impl.YangApplicationGeneration.YangApplicationGenerationData; +import xdev.yang.impl.usecase.AddUsecase; +import xdev.yang.impl.usecase.DetermineUseCaseAssignments; +import xdev.yang.impl.usecase.LoadUsecasesTable; +import xdev.yang.impl.usecase.SaveUsecaseAssignmentAction; +import xmcp.yang.LoadYangAssignmentsData; +import xmcp.yang.UseCaseAssignmentTableData; +import xmcp.yang.UseCaseTableData; +import xprc.xpce.Workspace; public class YangAppGenerationServiceOperationImpl implements ExtendedDeploymentTask, YangAppGenerationServiceOperation { + private static final Logger logger = CentralFactoryLogging.getLogger(YangAppGenerationServiceOperationImpl.class); + public void onDeployment() throws XynaException { OverallInformationProvider.onDeployment(); + PluginManagement.registerPlugin(this.getClass()); } public void onUndeployment() throws XynaException { OverallInformationProvider.onUndeployment(); + PluginManagement.unregisterPlugin(this.getClass()); } - public Long getOnUnDeploymentTimeout() { // The (un)deployment runs in its own thread. The service may define a timeout // in milliseconds, after which Thread.interrupt is called on this thread. @@ -48,7 +71,6 @@ public Long getOnUnDeploymentTimeout() { return null; } - public BehaviorAfterOnUnDeploymentTimeout getBehaviorAfterOnUnDeploymentTimeout() { // Defines the behavior of the (un)deployment after reaching the timeout and if this service ignores a Thread.interrupt. // - BehaviorAfterOnUnDeploymentTimeout.EXCEPTION: Deployment will be aborted, while undeployment will log the exception and NOT abort. @@ -59,13 +81,64 @@ public BehaviorAfterOnUnDeploymentTimeout getBehaviorAfterOnUnDeploymentTimeout( return null; } + public void createYangDeviceApp(YangAppGenerationInputParameter yangAppGenerationInputParameter2) { + String id = null; + try (YangApplicationGenerationData appData = YangApplicationGeneration.createDeviceApp(yangAppGenerationInputParameter2)) { + id = appData.getId(); + } catch (IOException e) { + if (logger.isWarnEnabled()) { + logger.warn("Could not clean up temporary files for " + yangAppGenerationInputParameter2.getApplicationName(), e); + } + } + importApplication(id); -public void createYangDeviceApp(YangAppGenerationInputParameter yangAppGenerationInputParameter2) { - YangApplicationGeneration.createDeviceApp(yangAppGenerationInputParameter2); -} + } -public void importModuleCollectionApplication(YangAppGenerationInputParameter yangAppGenerationInputParameter1) { - YangApplicationGeneration.createModuleCollectionApp(yangAppGenerationInputParameter1); -} + public void importModuleCollectionApplication(YangAppGenerationInputParameter yangAppGenerationInputParameter1) { + String id = null; + try (YangApplicationGenerationData appData = YangApplicationGeneration.createModuleCollectionApp(yangAppGenerationInputParameter1)) { + id = appData.getId(); + } catch (IOException e) { + if (logger.isWarnEnabled()) { + logger.warn("Could not clean up temporary files for " + yangAppGenerationInputParameter1.getApplicationName(), e); + } + } + importApplication(id); + } + + private void importApplication(String id) { + FileManagement fileMgmt = XynaFactory.getInstance().getFactoryManagement().getXynaFactoryControl().getFileManagement(); + ImportapplicationImpl importApp = new ImportapplicationImpl(); + Importapplication importPayload = new Importapplication(); + importPayload.setFilename(fileMgmt.retrieve(id).getOriginalFilename()); + try (ByteArrayOutputStream stream = new ByteArrayOutputStream()){ + importApp.execute(stream, importPayload); + } catch (Exception e) { + throw new RuntimeException(e); + } + } -} \ No newline at end of file + @Override + public List loadUsecases() { + return new LoadUsecasesTable().loadUsecases(); + } + + @Override + public void addUsecase(XynaOrderServerExtension order, Text usecaseGroupFqn, Text usecaseName, Workspace workspace, Text rpc, Text deviceFqn) { + new AddUsecase().addUsecase(usecaseGroupFqn.getText(), usecaseName.getText(), workspace, order, rpc.getText(), deviceFqn.getText()); + + } + + @Override + public List loadAssignments(LoadYangAssignmentsData data) { + DetermineUseCaseAssignments executor = new DetermineUseCaseAssignments(); + return executor.determineUseCaseAssignments(data); + } + + + @Override + public void saveAssignment(XynaOrderServerExtension order, UseCaseAssignmentTableData data) { + SaveUsecaseAssignmentAction executor = new SaveUsecaseAssignmentAction(); + executor.saveUsecaseAssignment(order, data); + } +} diff --git a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/YangApplicationGeneration.java b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/YangApplicationGeneration.java index dde0c3ffc..62609b179 100644 --- a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/YangApplicationGeneration.java +++ b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/YangApplicationGeneration.java @@ -22,6 +22,7 @@ import java.io.Closeable; import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -29,6 +30,7 @@ import com.gip.xyna.FileUtils; import com.gip.xyna.XynaFactory; import com.gip.xyna.exceptions.Ex_FileAccessException; +import com.gip.xyna.utils.misc.Base64; import com.gip.xyna.xfmg.xfctrl.classloading.ClassLoaderBase; import com.gip.xyna.xfmg.xfctrl.filemgmt.FileManagement; import com.gip.xyna.xfmg.xfctrl.revisionmgmt.RevisionManagement; @@ -37,14 +39,8 @@ import com.gip.xyna.xprc.xfractwfe.generation.XMLUtils; import xdev.yang.YangAppGenerationInputParameter; -import org.dom4j.DocumentException; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.yangcentral.yangkit.model.api.schema.YangSchemaContext; -import org.yangcentral.yangkit.parser.YangParserException; -import org.yangcentral.yangkit.parser.YangYinParser; -import org.yangcentral.yangkit.writter.YinWriter; - import java.util.zip.ZipOutputStream; import java.io.FileOutputStream; @@ -64,12 +60,13 @@ public static YangApplicationGenerationData createModuleCollectionApp(YangAppGen files.add(unzipedApp); // directory with yang modules - String yangModulesDir = fileMgmt.retrieve(genParameter.getFileID().getId()).getOriginalFilename(); - if (yangModulesDir.endsWith(".zip")) { - yangModulesDir = decompressArchive(yangModulesDir); - files.add(new File(yangModulesDir)); + String originalFileName = fileMgmt.retrieve(genParameter.getFileID().getId()).getOriginalFilename(); + String fileAbsPath = fileMgmt.getAbsolutePath(genParameter.getFileID().getId()); + if (originalFileName.endsWith(".zip")) { + fileAbsPath = decompressArchive(fileAbsPath); + files.add(new File(fileAbsPath)); } - Document yinDocument = parseYangModules(yangModulesDir); + Document yinDocument = parseYangModules(fileAbsPath); createDatatype(genParameter.getDataTypeFQN(), "YangModuleCollection", yinDocument, unzipedApp.getAbsolutePath()); createApplicationXML(genParameter, unzipedApp.getAbsolutePath()); @@ -90,14 +87,14 @@ public static YangApplicationGenerationData createDeviceApp(YangAppGenerationInp File unzipedApp = new File("/tmp/" + appName); files.add(unzipedApp); - String capabilitiesFile = fileMgmt.retrieve(genParameter.getFileID().getId()).getOriginalFilename(); + String capabilitiesFile = fileMgmt.getAbsolutePath(genParameter.getFileID().getId()); Document capabilities; try { capabilities = XMLUtils.parse(capabilitiesFile); + capabilities = XMLUtils.parseString(""+XMLUtils.getXMLString(capabilities.getDocumentElement(), false)+""); } catch (Ex_FileAccessException | XPRC_XmlParsingException e) { throw new RuntimeException(e); } - createDatatype(genParameter.getDataTypeFQN(), "YangDevice", capabilities, unzipedApp.getAbsolutePath()); createApplicationXML(genParameter, unzipedApp.getAbsolutePath()); @@ -212,23 +209,24 @@ public static String buildApplication(String appName, File unzipedAppDir) { private static Document parseYangModules(String yangModulesDir) { + List files = new ArrayList(); + Document document = null; + FileUtils.findFilesRecursively(new File(yangModulesDir), files, (dir, name) -> name.endsWith(".yang")); try { - Document yinDocument = XMLUtils.parseString(""); - Element rootElement = yinDocument.getDocumentElement(); - YangSchemaContext schemaContext = YangYinParser.parse(yangModulesDir); - for (var entry : schemaContext.getParseResult().entrySet()) { - Document doc = XMLUtils.parseString(YinWriter.serialize(entry.getValue()).asXML()); - rootElement.appendChild(yinDocument.importNode(doc.getDocumentElement(), true)); + document = XMLUtils.parseString(""); + Element rootElement = document.getDocumentElement(); + for (File f : files) { + String encoded = Base64.encode(Files.readAllBytes(f.toPath())); + Element node = document.createElement("module"); + node.appendChild(document.createTextNode(encoded)); + rootElement.appendChild(node); } - - return yinDocument; - - } catch (IOException | YangParserException | DocumentException | XPRC_XmlParsingException e) { + } catch (Exception e) { throw new RuntimeException("Could not parse Yang modules", e); } + return document; } - public static String decompressArchive(String zipFile) { String unzipDir = "/tmp/" + new File(zipFile).getName().replace(".zip", "_unzipped"); try { diff --git a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/AddUsecase.java b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/AddUsecase.java new file mode 100644 index 000000000..17dcb75ce --- /dev/null +++ b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/AddUsecase.java @@ -0,0 +1,161 @@ +/* + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Copyright 2024 Xyna GmbH, Germany + * + * 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 xdev.yang.impl.usecase; + + + +import org.apache.log4j.Logger; + +import com.gip.xyna.CentralFactoryLogging; +import com.gip.xyna.XynaFactory; +import com.gip.xyna.xact.trigger.RunnableForFilterAccess; +import com.gip.xyna.xfmg.xfctrl.revisionmgmt.RevisionManagement; +import com.gip.xyna.xprc.XynaOrderServerExtension; +import com.gip.xyna.xprc.exceptions.XPRC_XMOMObjectDoesNotExist; +import com.gip.xyna.xprc.xfractwfe.generation.DOM; +import com.gip.xyna.xprc.xfractwfe.generation.GenerationBaseCache; + +import xact.http.URLPath; +import xact.http.enums.httpmethods.HTTPMethod; +import xact.http.enums.httpmethods.POST; +import xact.http.enums.httpmethods.PUT; +import xdev.yang.impl.Constants; +import xmcp.processmodeller.datatypes.response.GetDataTypeResponse; +import xprc.xpce.Workspace; + + + +public class AddUsecase { + + private static final Logger logger = CentralFactoryLogging.getLogger(AddUsecase.class); + + + public void addUsecase(String fqn, String usecaseName, Workspace workspace, XynaOrderServerExtension order, String rpc, String deviceFqn) { + try { + String workspaceName = workspace.getName(); + if (logger.isDebugEnabled()) { + logger.debug("addUsecase: " + usecaseName + " to " + fqn + " in workspace " + workspaceName + " using order: " + order.getId()); + } + RevisionManagement revMgmt = XynaFactory.getInstance().getFactoryManagement().getXynaFactoryControl().getRevisionManagement(); + Long revision = revMgmt.getRevision(null, null, workspaceName); + DOM dom = DOM.getOrCreateInstance(fqn, new GenerationBaseCache(), revision); + String label = fqn.substring(fqn.lastIndexOf(".") + 1); + String path = fqn.substring(0, fqn.lastIndexOf(".")); + String currentPath = path; + if (logger.isDebugEnabled()) { + logger.debug(order.getId() + ": Read from input: Workspace revision: " + revision + ", label: " + label + ", path: " + path); + } + try { + if (!doesDomExist(dom)) { + currentPath = createDatatype(label, workspaceName, order); + } + + if (logger.isDebugEnabled()) { + logger.debug(order.getId() + ": Adding service to datatype. Current datatype path: " + currentPath); + } + addParentToDatatype(currentPath, label, workspaceName, order); + addServiceToDatatype(currentPath, label, usecaseName, workspaceName, order, rpc, deviceFqn); + UseCaseAssignmentUtils.saveDatatype(currentPath, path, label, workspaceName, order); + } finally { + if (logger.isDebugEnabled()) { + logger.debug(order.getId() + ": Closing datatype."); + } + closeDatatype(currentPath, label, workspaceName, order); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private void addParentToDatatype(String path, String label, String workspace, XynaOrderServerExtension order) { + RunnableForFilterAccess runnable = order.getRunnableForFilterAccess("H5XdevFilter"); + String workspaceNameEscaped = UseCaseAssignmentUtils.urlEncode(workspace); + String fqnUrl = path + "/" + label; + String endPoint = "/runtimeContext/" + workspaceNameEscaped + "/xmom/datatypes/" + fqnUrl + "/objects/typeInfoArea/change"; + URLPath url = new URLPath(endPoint, null, null); + HTTPMethod method = new PUT(); + String payload = "{\"baseType\":\"xmcp.yang.YangUsecaseImplementation\"}"; + UseCaseAssignmentUtils.executeRunnable(runnable, url, method, payload, "Could not add supertype to datatype."); + } + + private boolean doesDomExist(DOM dom) { + try { + dom.parseGeneration(false, false); + return dom.exists(); + } catch(XPRC_XMOMObjectDoesNotExist e) { + return false; + } catch(Exception e) { + throw new RuntimeException(e); + } + } + + private void closeDatatype(String currentPath, String label, String workspaceName, XynaOrderServerExtension order) { + if (logger.isDebugEnabled()) { + logger.debug(order.getId() + ": Datatype does not exist"); + } + RunnableForFilterAccess runnable = order.getRunnableForFilterAccess("H5XdevFilter"); + String workspaceNameEscaped = UseCaseAssignmentUtils.urlEncode(workspaceName); + String endpoint = "/runtimeContext/" + workspaceNameEscaped + "/xmom/datatypes/" + currentPath + "/" + label + "/close"; + URLPath url = new URLPath(endpoint, null, null); + HTTPMethod method = new POST(); + String payload = "{\"force\":false,\"revision\":0}"; + UseCaseAssignmentUtils.executeRunnable(runnable, url, method, payload, "could not close datatype"); + + if (logger.isDebugEnabled()) { + logger.debug(order.getId() + ": Datatype created. Temporary path: " + currentPath); + } + } + + + private String createDatatype(String label, String workspaceName, XynaOrderServerExtension order) { + RunnableForFilterAccess runnable = order.getRunnableForFilterAccess("H5XdevFilter"); + String workspaceNameEscaped = UseCaseAssignmentUtils.urlEncode(workspaceName); + URLPath url = new URLPath("/runtimeContext/" + workspaceNameEscaped + "/xmom/datatypes", null, null); + HTTPMethod method = new POST(); + String payload = "{\"label\":\"" + label + "\"}"; + GetDataTypeResponse json; + json = (GetDataTypeResponse) UseCaseAssignmentUtils.executeRunnable(runnable, url, method, payload, "Could not create datatype."); + if (json == null) { + throw new RuntimeException("Could not create datatype."); + } + String fqn = json.getXmomItem().getFqn(); + return fqn.substring(0, fqn.lastIndexOf(".")); + } + + private void addServiceToDatatype(String path, String label, String service, String workspace, XynaOrderServerExtension order, String rpc, String deviceFqn) { + RunnableForFilterAccess runnable = order.getRunnableForFilterAccess("H5XdevFilter"); + String workspaceNameEscaped = UseCaseAssignmentUtils.urlEncode(workspace); + String fqnUrl = path + "/" + label; + String endPoint = "/runtimeContext/" + workspaceNameEscaped + "/xmom/datatypes/" + fqnUrl + "/objects/memberMethodsArea/insert"; + URLPath url = new URLPath(endPoint, null, null); + HTTPMethod method = new POST(); + String payload = "{\"index\":-1,\"content\":{\"type\":\"memberMethod\",\"label\":\"" + service + "\"},\"revision\":0}"; + UseCaseAssignmentUtils.executeRunnable(runnable, url, method, payload, "Could not add service to datatype."); + + // set meta tag + String serviceName = service; //TODO: read correct name from datatype + endPoint = "/runtimeContext/" + workspaceNameEscaped + "/xmom/datatypes/" + fqnUrl + "/services/" + serviceName + "/meta"; + url = new URLPath(endPoint, null, null); + method = new PUT(); + String mappings = "<" + Constants.TAG_MAPPINGS + "/>"; + String device = "<" + Constants.TAG_DEVICE_FQN + ">" + deviceFqn + ""; + String tag = ""+ rpc + ""+ device + mappings +""; + payload = "{\"$meta\":{\"fqn\":\"xmcp.processmodeller.datatypes.request.MetaTagRequest\"},\"metaTag\":{\"$meta\":{\"fqn\":\"xmcp.processmodeller.datatypes.MetaTag\"},\"deletable\":true,\"tag\":\"" + tag + "\"}}"; + UseCaseAssignmentUtils.executeRunnable(runnable, url, method, payload, "Could not add meta tag to service."); + } +} diff --git a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/DetermineUseCaseAssignments.java b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/DetermineUseCaseAssignments.java new file mode 100644 index 000000000..250484ef4 --- /dev/null +++ b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/DetermineUseCaseAssignments.java @@ -0,0 +1,162 @@ +/* + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Copyright 2024 Xyna GmbH, Germany + * + * 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 xdev.yang.impl.usecase; + + + +import java.util.ArrayList; +import java.util.List; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import com.gip.xyna.XynaFactory; +import com.gip.xyna.utils.collections.Pair; +import com.gip.xyna.xfmg.xfctrl.XynaFactoryControl; +import com.gip.xyna.xfmg.xfctrl.dependencies.RuntimeContextDependencyManagement; +import com.gip.xyna.xfmg.xfctrl.revisionmgmt.RevisionManagement; +import com.gip.xyna.xfmg.xfctrl.xmomdatabase.search.XMOMDatabaseSearchResultEntry; +import com.gip.xyna.xnwh.exceptions.XNWH_OBJECT_NOT_FOUND_FOR_PRIMARY_KEY; +import com.gip.xyna.xprc.xfractwfe.generation.DOM; +import com.gip.xyna.xprc.xfractwfe.generation.GenerationBaseCache; +import com.gip.xyna.xprc.xfractwfe.generation.XMLUtils; + +import xdev.yang.impl.Constants; +import xdev.yang.impl.XmomDbInteraction; + +import org.yangcentral.yangkit.model.api.stmt.Module; + +import xmcp.yang.LoadYangAssignmentsData; +import xmcp.yang.UseCaseAssignmentTableData; +import xmcp.yang.YangDevice; + + + +public class DetermineUseCaseAssignments { + + + public List determineUseCaseAssignments(LoadYangAssignmentsData data) { + String fqn = data.getFqn(); + String workspaceName = data.getWorkspaceName(); + String usecase = data.getUsecase(); + List result = new ArrayList(); + Pair meta = UseCaseAssignmentUtils.loadOperationMeta(fqn, workspaceName, usecase); + if(meta == null) { + return result; + } + String rpcName = readRpcName(meta.getSecond()); + if(rpcName == null) { + return result; + } + + List modules = UseCaseAssignmentUtils.loadModules(workspaceName); + List moduleCapabilities = loadCapabilities(meta.getSecond(), workspaceName); + modules.removeIf(x -> !isModuleInCapabilities(moduleCapabilities, x)); + result = UseCaseAssignmentUtils.loadPossibleAssignments(modules, rpcName, data); + fillValues(meta.getSecond(), modules, result); + + return result; + } + + private boolean isModuleInCapabilities(List capabilities, Module module) { + return capabilities.contains(module.getMainModule().getNamespace().getUri().toASCIIString()); + } + + private List loadCapabilities(Document usecaseMeta, String workspaceName) { + Element deviceFqnEle = XMLUtils.getChildElementByName(usecaseMeta.getDocumentElement(), Constants.TAG_DEVICE_FQN); + String deviceFqn = deviceFqnEle.getTextContent(); + DOM deviceDatatype = loadDeviceDatatype(deviceFqn, workspaceName); + List unknownMetaTags = deviceDatatype.getUnknownMetaTags(); + Document deviceMeta = loadDeviceMeta(unknownMetaTags); + Element ele = XMLUtils.getChildElementByName(deviceMeta.getDocumentElement(), Constants.TAG_HELLO); + ele = XMLUtils.getChildElementByName(ele, Constants.TAG_CAPABILITIES); + List capabilities = XMLUtils.getChildElementsByName(ele, Constants.TAG_CAPABILITY); + List result = new ArrayList(); + for(Element capability : capabilities) { + result.add(capability.getTextContent()); + } + return result; + } + + + private Document loadDeviceMeta(List unknownMetaTags) { + try { + for (String unknownMetaTag : unknownMetaTags) { + Document d = XMLUtils.parseString(unknownMetaTag); + boolean isYang = d.getDocumentElement().getTagName().equals(Constants.TAG_YANG); + boolean isDevice = Constants.VAL_DEVICE.equals(d.getDocumentElement().getAttribute(Constants.ATT_YANG_TYPE)); + if (isYang && isDevice) { + return d; + } + } + throw new RuntimeException("No Device Meta Tag found"); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private DOM loadDeviceDatatype(String deviceFqn, String workspace) { + XynaFactoryControl factoryControl = XynaFactory.getInstance().getFactoryManagement().getXynaFactoryControl(); + XmomDbInteraction interaction = new XmomDbInteraction(); + RevisionManagement rm = factoryControl.getRevisionManagement(); + Long revision; + try { + revision = rm.getRevision(null, null, workspace); + } catch (XNWH_OBJECT_NOT_FOUND_FOR_PRIMARY_KEY e) { + throw new RuntimeException(e); + } + RuntimeContextDependencyManagement rcdm = factoryControl.getRuntimeContextDependencyManagement(); + List revisions = new ArrayList<>(rcdm.getDependencies(revision)); + List candidates = interaction.searchYangDTs(YangDevice.class.getCanonicalName(), revisions); + for(XMOMDatabaseSearchResultEntry candidate : candidates) { + if(candidate.getFqName().equals(deviceFqn)) { + Long deviceRevision; + try { + deviceRevision = rm.getRevision(candidate.getRuntimeContext()); + DOM result = DOM.getOrCreateInstance(deviceFqn, new GenerationBaseCache(), deviceRevision); + result.parseGeneration(true, false); + return result; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + throw new RuntimeException("Could not find device datatype " + deviceFqn + " in " + workspace + " or dependencies"); + } + + + private void fillValues(Document meta, List modules, List entries) { + List mappings = UseCaseMapping.loadMappings(meta); + for (UseCaseAssignmentTableData entry : entries) { + for (UseCaseMapping mapping : mappings) { + if (mapping.getMappingYangPath().equals(entry.getLoadYangAssignmentsData().getTotalYangPath())) { + entry.unversionedSetValue(mapping.getValue()); + } + } + } + } + + private String readRpcName(Document meta) { + Element rpcElement = XMLUtils.getChildElementByName(meta.getDocumentElement(), Constants.TAG_RPC); + if(rpcElement == null) { + return null; + } + return rpcElement.getTextContent(); + } + +} diff --git a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/LoadUsecasesTable.java b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/LoadUsecasesTable.java new file mode 100644 index 000000000..15047716a --- /dev/null +++ b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/LoadUsecasesTable.java @@ -0,0 +1,158 @@ +/* + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Copyright 2024 Xyna GmbH, Germany + * + * 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 xdev.yang.impl.usecase; + + + +import java.util.ArrayList; +import java.util.List; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import com.gip.xyna.XynaFactory; +import com.gip.xyna.xprc.xfractwfe.generation.XMLUtils; + +import xdev.yang.impl.Constants; +import xdev.yang.impl.XmomDbInteraction; + +import com.gip.xyna.xfmg.xfctrl.appmgmt.WorkspaceInformation; +import com.gip.xyna.xfmg.xfctrl.revisionmgmt.RevisionManagement; +import com.gip.xyna.xfmg.xfctrl.workspacemgmt.WorkspaceManagement; +import com.gip.xyna.xfmg.xfctrl.xmomdatabase.search.XMOMDatabaseSearchResultEntry; +import com.gip.xyna.xnwh.exceptions.XNWH_OBJECT_NOT_FOUND_FOR_PRIMARY_KEY; +import com.gip.xyna.xprc.xfractwfe.generation.DOM; +import com.gip.xyna.xprc.xfractwfe.generation.GenerationBaseCache; +import com.gip.xyna.xprc.xfractwfe.generation.Operation; + +import xmcp.yang.UseCaseTableData; +import xmcp.yang.YangUsecaseImplementation; + + + +public class LoadUsecasesTable { + + + public List loadUsecases() { + try { + List result = new ArrayList<>(); + List usecaseGroupDts = determineUsecaseGroupDatatypes(); + for (UseCaseGroupDt usecaseGroupDt : usecaseGroupDts) { + List data = determineUsecasesOfGroup(usecaseGroupDt); + result.addAll(data); + } + + return result; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + + private List determineUsecasesOfGroup(UseCaseGroupDt dt) { + List result = new ArrayList<>(); + try { + DOM datatype = DOM.getOrCreateInstance(dt.getFqn(), new GenerationBaseCache(), dt.getRevision()); + datatype.parseGeneration(false, false); + List operations = datatype.getOperations(); + Document xml; + for (Operation operation : operations) { + xml = UseCaseAssignmentUtils.findYangTypeTag(operation); + if (!UseCaseAssignmentUtils.isYangType(xml, Constants.VAL_USECASE)) { + continue; + } + UseCaseTableData.Builder data = new UseCaseTableData.Builder(); + data.usecaseGroup(dt.getFqn()); + data.rpcName(readRpcName(xml)); + data.useCase(operation.getName()); + data.mappingCount(countMappings(xml)); + data.runtimeContext(datatype.getRuntimeContext().getName()); + result.add(data.instance()); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + + return result; + } + + private String readRpcName(Document xml) { + Element ele = XMLUtils.getChildElementByName(xml.getDocumentElement(), Constants.TAG_RPC); + if(ele == null) { + throw new RuntimeException("Could not determine rpc name"); + } + return ele.getTextContent(); + } + + private int countMappings(Document xml) { + Element mappingsNode = XMLUtils.getChildElementByName(xml.getDocumentElement(), Constants.TAG_MAPPINGS); + return XMLUtils.getChildElementsByName(mappingsNode, Constants.TAG_MAPPING).size(); + } + + + private List determineUsecaseGroupDatatypes() throws Exception { + List result = new ArrayList<>(); + RevisionManagement revMgmt = XynaFactory.getInstance().getFactoryManagement().getXynaFactoryControl().getRevisionManagement(); + List revisions = determineWorkspaceRevisions(); + XmomDbInteraction interaction = new XmomDbInteraction(); + List xmomDbResults = interaction.searchYangDTs(YangUsecaseImplementation.class.getCanonicalName(), revisions); + for (XMOMDatabaseSearchResultEntry entry : xmomDbResults) { + Long revision = revMgmt.getRevision(entry.getRuntimeContext()); + UseCaseGroupDt useCaseGroup = new UseCaseGroupDt(entry.getFqName(), revision); + result.add(useCaseGroup); + } + return result; + } + + private List determineWorkspaceRevisions() throws XNWH_OBJECT_NOT_FOUND_FOR_PRIMARY_KEY { + List result = new ArrayList<>(); + WorkspaceManagement workspaceMgmt = XynaFactory.getInstance().getFactoryManagement().getXynaFactoryControl().getWorkspaceManagement(); + RevisionManagement revMgmt = XynaFactory.getInstance().getFactoryManagement().getXynaFactoryControl().getRevisionManagement(); + List workspaces = workspaceMgmt.listWorkspaces(false); + for (WorkspaceInformation workspace : workspaces) { + Long revision = revMgmt.getRevision(workspace.asRuntimeContext()); + result.add(revision); + } + return result; + } + + + private static class UseCaseGroupDt { + + private final String fqn; + private final Long revision; + + + public UseCaseGroupDt(String fqn, Long revision) { + this.fqn = fqn; + this.revision = revision; + } + + + public String getFqn() { + return fqn; + } + + + public Long getRevision() { + return revision; + } + + + } +} diff --git a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/SaveUsecaseAssignmentAction.java b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/SaveUsecaseAssignmentAction.java new file mode 100644 index 000000000..574e0e0c2 --- /dev/null +++ b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/SaveUsecaseAssignmentAction.java @@ -0,0 +1,101 @@ +/* + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Copyright 2024 Xyna GmbH, Germany + * + * 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 xdev.yang.impl.usecase; + +import java.util.ArrayList; +import java.util.List; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import com.gip.xyna.utils.collections.Pair; +import com.gip.xyna.xact.trigger.RunnableForFilterAccess; +import com.gip.xyna.xprc.XynaOrderServerExtension; +import com.gip.xyna.xprc.xfractwfe.generation.XMLUtils; + +import xact.http.URLPath; +import xact.http.URLPathQuery; +import xact.http.enums.httpmethods.DELETE; +import xact.http.enums.httpmethods.GET; +import xact.http.enums.httpmethods.HTTPMethod; +import xact.http.enums.httpmethods.PUT; +import xmcp.yang.UseCaseAssignmentTableData; + +public class SaveUsecaseAssignmentAction { + + public void saveUsecaseAssignment(XynaOrderServerExtension order, UseCaseAssignmentTableData data) { + String fqn = data.getLoadYangAssignmentsData().getFqn(); + String workspaceName = data.getLoadYangAssignmentsData().getWorkspaceName(); + String usecase = data.getLoadYangAssignmentsData().getUsecase(); + String totalYangPath = data.getLoadYangAssignmentsData().getTotalYangPath(); + boolean update = false; + Pair meta = UseCaseAssignmentUtils.loadOperationMeta(fqn, workspaceName, usecase); + if(meta == null) { + return; + } + List mappings = UseCaseMapping.loadMappingElements(meta.getSecond()); + for(Element mappingEle : mappings) { + UseCaseMapping mapping = UseCaseMapping.loadUseCaseMapping(mappingEle); + mapping.setValue(data.getValue()); + if(mapping.getMappingYangPath().equals(totalYangPath)) { + mapping.updateNode(mappingEle); + update = true; + break; + } + } + if(!update) { + //TODO: name space + UseCaseMapping mapping = new UseCaseMapping(totalYangPath, "", data.getValue()); + mapping.createAndAddElement(meta.getSecond()); + } + + //write updated meta back to Datatype + String xml = XMLUtils.getXMLString(meta.getSecond().getDocumentElement(), false); + updateAssignmentsMeta(order, fqn, workspaceName, usecase, xml, meta.getFirst()); + } + + private void updateAssignmentsMeta(XynaOrderServerExtension order, String fqn, String workspaceName, String usecase, String xml, int oldMetaTagIndex) { + RunnableForFilterAccess runnable = order.getRunnableForFilterAccess("H5XdevFilter"); + String path = fqn.substring(0, fqn.lastIndexOf(".")); + String label = fqn.substring(fqn.lastIndexOf(".") + 1); + String workspaceNameEscaped = UseCaseAssignmentUtils.urlEncode(workspaceName); + + //open datatype + String endpoint = "/runtimeContext/" + workspaceNameEscaped + "/xmom/datatypes/" + path + "/" + label; + URLPath url = new URLPath(endpoint, null, null); + HTTPMethod method = new GET(); + UseCaseAssignmentUtils.executeRunnable(runnable, url, method, null, "could not open datatype"); + + //remove old meta tag + endpoint = "/runtimeContext/" + workspaceNameEscaped + "/xmom/datatypes/" + path + "/" + label + "/services/" + usecase + "/meta"; + List query = new ArrayList<>(); + query.add(new URLPathQuery.Builder().attribute("metaTagId").value("metaTag"+oldMetaTagIndex).instance()); + url = new URLPath(endpoint, query, null); + method = new DELETE(); + UseCaseAssignmentUtils.executeRunnable(runnable, url, method, "", "could not remove old meta tag"); + + //add new meta tag + url = new URLPath(endpoint, null, null); + method = new PUT(); + xml = xml.replaceAll("\n", "\\\\n").replaceAll("\"", "\\\\\""); + String payload = "{\"$meta\":{\"fqn\":\"xmcp.processmodeller.datatypes.request.MetaTagRequest\"},\"metaTag\":{\"$meta\":{\"fqn\":\"xmcp.processmodeller.datatypes.MetaTag\"},\"deletable\":true,\"tag\":\""+ xml +"\"}}"; + UseCaseAssignmentUtils.executeRunnable(runnable, url, method, payload, "could not add new meta tag"); + + UseCaseAssignmentUtils.saveDatatype(path, path, label, workspaceName, order); + } +} diff --git a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/UseCaseAssignmentUtils.java b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/UseCaseAssignmentUtils.java new file mode 100644 index 000000000..fe359ca3f --- /dev/null +++ b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/UseCaseAssignmentUtils.java @@ -0,0 +1,323 @@ +/* + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Copyright 2024 Xyna GmbH, Germany + * + * 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 xdev.yang.impl.usecase; + +import java.net.URLEncoder; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.yangcentral.yangkit.base.YangElement; +import org.yangcentral.yangkit.model.api.schema.YangSchemaContext; +import org.yangcentral.yangkit.model.api.stmt.Container; +import org.yangcentral.yangkit.model.api.stmt.Grouping; +import org.yangcentral.yangkit.model.api.stmt.Input; +import org.yangcentral.yangkit.model.api.stmt.Leaf; +import org.yangcentral.yangkit.model.api.stmt.Module; +import org.yangcentral.yangkit.model.api.stmt.Rpc; +import org.yangcentral.yangkit.model.api.stmt.SchemaNode; +import org.yangcentral.yangkit.model.api.stmt.YangStatement; +import org.yangcentral.yangkit.parser.YangYinParser; +import com.gip.xyna.XynaFactory; +import com.gip.xyna.utils.collections.Pair; +import com.gip.xyna.utils.exceptions.XynaException; +import com.gip.xyna.utils.misc.Base64; +import com.gip.xyna.xact.trigger.RunnableForFilterAccess; +import com.gip.xyna.xfmg.xfctrl.XynaFactoryControl; +import com.gip.xyna.xfmg.xfctrl.dependencies.RuntimeContextDependencyManagement; +import com.gip.xyna.xfmg.xfctrl.revisionmgmt.RevisionManagement; +import com.gip.xyna.xfmg.xfctrl.xmomdatabase.search.XMOMDatabaseSearchResultEntry; +import com.gip.xyna.xnwh.exceptions.XNWH_OBJECT_NOT_FOUND_FOR_PRIMARY_KEY; +import com.gip.xyna.xprc.XynaOrderServerExtension; +import com.gip.xyna.xprc.xfractwfe.generation.DOM; +import com.gip.xyna.xprc.xfractwfe.generation.GenerationBaseCache; +import com.gip.xyna.xprc.xfractwfe.generation.Operation; +import com.gip.xyna.xprc.xfractwfe.generation.XMLUtils; + +import xact.http.URLPath; +import xact.http.enums.httpmethods.HTTPMethod; +import xact.http.enums.httpmethods.POST; +import xdev.yang.impl.Constants; +import xdev.yang.impl.XmomDbInteraction; +import xmcp.yang.LoadYangAssignmentsData; +import xmcp.yang.UseCaseAssignmentTableData; +import xmcp.yang.YangModuleCollection; + +public class UseCaseAssignmentUtils { + + private static final Set> supportedYangStatementsForAssignments = setupSupportedAssignmentClasses(); + private static final Map, String> yangStatementIdentifiers = setupStatementIdentifiers(); + + private static Set> setupSupportedAssignmentClasses() { + Set> result = new HashSet>(); + result.add(Container.class); + result.add(Leaf.class); + result.add(Grouping.class); + return result; + } + + private static Map, String> setupStatementIdentifiers() { + Map, String> result = new HashMap, String>(); + result.put(Container.class, Constants.TYPE_CONTAINER); + result.put(Leaf.class, Constants.TYPE_LEAF); + result.put(Grouping.class, Constants.TYPE_GROUPING); + return result; + } + + public static List loadPossibleAssignments(List modules, String rpcName, LoadYangAssignmentsData data) { + Rpc rpc = findRpc(modules, rpcName); + Input input = rpc.getInput(); + List elements = traverseYang(modules, data.getTotalYangPath(), input); + return loadAssignments(elements, data); + } + + private static List traverseYang(List modules, String path, YangStatement element) { + String[] parts = path.split("\\/"); + for(int i=1; i getCandidates(YangStatement statement) { + List candidates = statement.getSubElements(); + List result = new ArrayList<>(); + for (YangElement candidate : candidates) { + if (isSupportedElement(candidate)) { + result.add((YangStatement) candidate); + } + } + return result; + } + + private static YangStatement traverseYangOneLayer(List modules, String pathStep, YangStatement statement) { + List candidates = statement.getSubElements(); + for(YangElement candidate : candidates) { + if(isSupportedElement(candidate)) { + if(((SchemaNode)candidate).getIdentifier().getLocalName().equals(pathStep)) { + return (YangStatement) candidate; + } + } + } + + throw new RuntimeException("Could not traverse from " + statement.getArgStr() + " to " + pathStep); + } + + + private static List loadAssignments(List subElements, LoadYangAssignmentsData data) { + List result = new ArrayList<>(); + for (YangStatement element : subElements) { + if (isSupportedElement(element)) { + String localName = ((SchemaNode) element).getIdentifier().getLocalName(); + UseCaseAssignmentTableData.Builder builder = new UseCaseAssignmentTableData.Builder(); + LoadYangAssignmentsData updatedData = data.clone(); + updatedData.unversionedSetTotalYangPath(updatedData.getTotalYangPath() + "/" + localName); + builder.loadYangAssignmentsData(updatedData); + builder.yangPath(localName); + builder.type(getYangType(element)); + result.add(builder.instance()); + } + } + return result; + } + + + private static boolean isSupportedElement(YangElement element) { + for (Class c : supportedYangStatementsForAssignments) { + if (c.isAssignableFrom(element.getClass())) { + return true; + } + } + return false; + } + + private static String getYangType(YangElement element) { + for(Entry, String> c : yangStatementIdentifiers.entrySet()) { + if(c.getKey().isAssignableFrom(element.getClass())) { + return c.getValue(); + } + } + return "Unknown: " + element.getClass().getCanonicalName(); + } + + private static Rpc findRpc(List modules, String rpcName) { + for(Module module : modules) { + Rpc result = module.getRpc(rpcName); + if(result != null) { + return result; + } + } + throw new RuntimeException("rpc " + rpcName + " not found."); + } + + public static List loadModules(String workspaceName) { + List result = new ArrayList<>(); + XynaFactoryControl xynaFactoryCtrl = XynaFactory.getInstance().getFactoryManagement().getXynaFactoryControl(); + XmomDbInteraction interaction = new XmomDbInteraction(); + RevisionManagement revMgmt = xynaFactoryCtrl.getRevisionManagement(); + RuntimeContextDependencyManagement rtcDepMgmt = xynaFactoryCtrl.getRuntimeContextDependencyManagement(); + Long revision; + try { + revision = revMgmt.getRevision(null, null, workspaceName); + } catch (XNWH_OBJECT_NOT_FOUND_FOR_PRIMARY_KEY e) { + throw new RuntimeException(e); + } + Set revisions = new HashSet(); + revisions.add(revision); + rtcDepMgmt.getDependenciesRecursivly(revision, revisions); + List revisionsList = new ArrayList<>(revisions); + List xmomDbResult = interaction.searchYangDTs(YangModuleCollection.class.getCanonicalName(), revisionsList); + for(XMOMDatabaseSearchResultEntry entry : xmomDbResult) { + Long entryRevision; + try { + entryRevision = revMgmt.getRevision(entry.getRuntimeContext()); + result.addAll(loadModulesFromDt(entry.getFqName(), entryRevision)); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + return result; + } + + private static List loadModulesFromDt(String fqName, Long entryRevision) throws Exception { + DOM dom = DOM.getOrCreateInstance(fqName, new GenerationBaseCache(), entryRevision); + dom.parseGeneration(true, false); + List metaTags = dom.getUnknownMetaTags(); + List result = new ArrayList(); + for(String meta : metaTags) { + Document xml = XMLUtils.parseString(meta, true); + if (!xml.getDocumentElement().getNodeName().equals(Constants.TAG_YANG)) { + continue; + } + Node yangTypeNode = xml.getDocumentElement().getAttributes().getNamedItem(Constants.ATT_YANG_TYPE); + if (yangTypeNode == null || !Constants.VAL_MODULECOLLECTION.equals(yangTypeNode.getNodeValue())) { + continue; + } + List modules = XMLUtils.getChildElementsByName(xml.getDocumentElement(), "module"); + for(Element module : modules) { + addModulesFromTag(module, result); + } + } + return result; + } + + + private static void addModulesFromTag(Element module, List modules) throws Exception { + java.io.ByteArrayInputStream is = new java.io.ByteArrayInputStream(Base64.decode(module.getTextContent())); + YangSchemaContext context = YangYinParser.parse(is, "module.yang", null); + context.validate(); + modules.addAll(context.getModules()); + } + + public static Pair loadOperationMeta(String fqn, String workspaceName, String usecase) { + try { + RevisionManagement revMgmt = XynaFactory.getInstance().getFactoryManagement().getXynaFactoryControl().getRevisionManagement(); + Long revision = revMgmt.getRevision(null, null, workspaceName); + DOM dom = DOM.getOrCreateInstance(fqn, new GenerationBaseCache(), revision); + dom.parseGeneration(false, false); + Operation operation = dom.getOperationByName(usecase); + List unknownMetaTags = operation.getUnknownMetaTags(); + if(unknownMetaTags == null) { + return null; + } + for(int i=0; i< unknownMetaTags.size(); i++) { + String unknownMetaTag = unknownMetaTags.get(i); + Document d = XMLUtils.parseString(unknownMetaTag); + boolean isYang = d.getDocumentElement().getTagName().equals(Constants.TAG_YANG); + boolean isUseCase = Constants.VAL_USECASE.equals(d.getDocumentElement().getAttribute(Constants.ATT_YANG_TYPE)); + if(isYang && isUseCase) { + return new Pair(i, d); + } + } + return null; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public static void saveDatatype(String path, String targetPath, String label, String workspace, XynaOrderServerExtension order) { + RunnableForFilterAccess runnable = order.getRunnableForFilterAccess("H5XdevFilter"); + String workspaceNameEscaped = urlEncode(workspace); + String baseUrl = "/runtimeContext/" + workspaceNameEscaped + "/xmom/datatypes/" + path + "/" + label; + URLPath url = new URLPath(baseUrl + "/save", null, null); + HTTPMethod method = new POST(); + String payload = "{\"force\":false,\"revision\":2,\"path\":\"" + targetPath + "\",\"label\":\"" + label + "\"}"; + executeRunnable(runnable, url, method, payload, "Could not save datatype."); + + //deploy + url = new URLPath(baseUrl + "/deploy", null, null); + payload = "{\"revision\":3}"; + executeRunnable(runnable, url, method, payload, "Could not deploy datatype."); + + //close + url = new URLPath(baseUrl + "/close", null, null); + payload = "{\"force\":false,\"revision\":4}"; + executeRunnable(runnable, url, method, payload, "Could not close datatype."); + } + + + public static Object executeRunnable(RunnableForFilterAccess runnable, URLPath url, HTTPMethod method, String payload, String msg) { + try { + return runnable.execute(url, method, payload); + } catch (XynaException e) { + throw new RuntimeException(msg, e); + } + } + + + public static String urlEncode(String in) { + return URLEncoder.encode(in, Charset.forName("UTF-8")); + } + + public static Document findYangTypeTag(Operation operation) { + if (operation.getUnknownMetaTags() == null) { + return null; + } + for (String unknownMetaTag : operation.getUnknownMetaTags()) { + try { + Document xml = XMLUtils.parseString(unknownMetaTag, false); + if (!xml.getDocumentElement().getNodeName().equals(Constants.TAG_YANG)) { + continue; + } + return xml; + } catch(Exception e) { + continue; + } + } + return null; + } + + + public static boolean isYangType(Document xml, String expectedYangType) { + if (xml == null) { + return false; + } + Node yangTypeNode = xml.getDocumentElement().getAttributes().getNamedItem(Constants.ATT_YANG_TYPE); + return yangTypeNode != null && expectedYangType.equals(yangTypeNode.getNodeValue()); + } +} diff --git a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/UseCaseMapping.java b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/UseCaseMapping.java new file mode 100644 index 000000000..8526d6d20 --- /dev/null +++ b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/src/xdev/yang/impl/usecase/UseCaseMapping.java @@ -0,0 +1,113 @@ +/* + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Copyright 2024 Xyna GmbH, Germany + * + * 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 xdev.yang.impl.usecase; + +import java.util.ArrayList; +import java.util.List; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import com.gip.xyna.xprc.xfractwfe.generation.XMLUtils; + +import xdev.yang.impl.Constants; + +public class UseCaseMapping { + + private String mappingYangPath; + private String namespace; + private String value; + + public UseCaseMapping(String mappingYangPath, String namespace, String value) { + this.mappingYangPath = mappingYangPath; + this.namespace = namespace; + this.value = value; + } + + public static List loadMappingElements(Document document) { + Element mappingsNode = XMLUtils.getChildElementByName(document.getDocumentElement(), Constants.TAG_MAPPINGS); + List mappingNodes = XMLUtils.getChildElementsByName(mappingsNode, Constants.TAG_MAPPING); + List result = new ArrayList(); + for(Element mappingNode : mappingNodes) { + result.add(mappingNode); + } + return result; + } + + public static List loadMappings(Document document) { + Element mappingsNode = XMLUtils.getChildElementByName(document.getDocumentElement(), Constants.TAG_MAPPINGS); + List mappingNodes = XMLUtils.getChildElementsByName(mappingsNode, Constants.TAG_MAPPING); + List result = new ArrayList(); + for(Element mappingNode : mappingNodes) { + UseCaseMapping mapping = loadUseCaseMapping(mappingNode); + result.add(mapping); + } + return result; + } + + public static UseCaseMapping loadUseCaseMapping(Element e) { + String yangPath = e.getAttribute(Constants.ATT_MAPPING_YANGPATH); + String namespace = e.getAttribute(Constants.ATT_MAPPING_NAMESPACE); + String value = e.getAttribute(Constants.ATT_MAPPING_VALUE); + return new UseCaseMapping(yangPath, namespace, value); + } + + public void updateNode(Element e) { + e.setAttribute(Constants.ATT_MAPPING_YANGPATH, mappingYangPath); + e.setAttribute(Constants.ATT_MAPPING_NAMESPACE, namespace); + e.setAttribute(Constants.ATT_MAPPING_VALUE, value); + } + + + public void createAndAddElement(Document meta) { + Element newMappingEle = meta.createElement(Constants.TAG_MAPPING); + updateNode(newMappingEle); + Element mappingsEle = XMLUtils.getChildElementByName(meta.getDocumentElement(), Constants.TAG_MAPPINGS); + mappingsEle.appendChild(newMappingEle); + } + + public String getMappingYangPath() { + return mappingYangPath; + } + + + public void setMappingYangPath(String mappingYangPath) { + this.mappingYangPath = mappingYangPath; + } + + + public String getNamespace() { + return namespace; + } + + + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + + public String getValue() { + return value; + } + + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/xmldefinition/YangAppGeneration.xml b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/xmldefinition/YangAppGeneration.xml index 6122a727c..18eb401d3 100644 --- a/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/xmldefinition/YangAppGeneration.xml +++ b/modules/xdev/yang/mdmimpl/YangAppGenerationImpl/xmldefinition/YangAppGeneration.xml @@ -22,6 +22,11 @@ YangAppGenerationImpl.jar yangkit + + + xmcp.forms.plugin.PluginManagement + + @@ -40,5 +45,47 @@ YangAppGenerationImpl.createYangDeviceApp(yangAppGenerationInputParameter2); + + + + + + + + + return xdev.yang.YangAppGenerationImpl.loadAssignments(loadYangAssignmentsData7); + + + + + + + + + return xdev.yang.YangAppGenerationImpl.loadUsecases(); + + + + + + + + + + + + + xdev.yang.YangAppGenerationImpl.addUsecase(correlatedXynaOrder, text2, text3, workspace5, text8, text9); + + + + + + + + + xdev.yang.YangAppGenerationImpl.saveAssignment(correlatedXynaOrder, UseCaseAssignmentTableData10); + +