Skip to content

Commit 2a52009

Browse files
committed
Add Target Config Names
1 parent a4a9269 commit 2a52009

File tree

6 files changed

+57
-17
lines changed

6 files changed

+57
-17
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
---
44

5+
## [v0.0.14](https://github.com/phil1436/ownobjectscriptextension/tree/0.0.14) (2023-5-9)
6+
7+
- Configuartion `Create > Service: Add Target Config Names` added
8+
9+
---
10+
511
## [v0.0.13](https://github.com/phil1436/ownobjectscriptextension/tree/0.0.13) (2023-5-3)
612

713
- Command `Create New Class` added

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ A [Visual Studio Code](https://code.visualstudio.com/) extension that supplies t
77
---
88

99
- [Features](#features)
10-
- [Create New Class](#create-new-class)
10+
- [Create New Class](#create-new-class-_beta_)
1111
- [Add ObjectScript Modifier](#add-objectscript-modifier)
1212
- [Add Method Description Template](#add-method-description-template)
1313
- [Make Select Statement](#make-select-statement)
14-
- [Translate Embedded Python _BETA_](#translate-embedded-python-_beta_)
14+
- [Translate Embedded Python](#translate-embedded-python-_beta_)
1515
- [Requirements](#requirements)
1616
- [Installation](#installation)
1717
- [Workspace](#workspace)
@@ -24,19 +24,22 @@ A [Visual Studio Code](https://code.visualstudio.com/) extension that supplies t
2424
- [Configuration](#configuration)
2525
- [Sql](#sql)
2626
- [Comment](#comment)
27+
- [Create](#create)
2728
- [Bugs](#bugs)
2829
- [Release Notes](#release-notes)
2930

3031
---
3132

3233
## Features
3334

34-
### `Create New Class`
35+
### `Create New Class` _BETA_
3536

3637
Creates a new ObjectScript Class, Message, Business Service or Business Operation similar to the InterSystems Studio Wizard. Just execute the command and follow the instructions.
3738

3839
![DemoCreateNewClass](resources/DemoCreateNewClass.gif)
3940

41+
> This feature is still in beta.
42+
4043
### `Add ObjectScript Modifier`
4144

4245
This command automatically adds `Set`, `Do` and `Write` to your InterSystems ObjectScript code.
@@ -69,7 +72,7 @@ Translate an ObjectSCript Method to embedded python. Will generate a new method
6972

7073
![demoTranslateEmbeddedPython](https://github.com/phil1436/ownobjectscriptextension/raw/master/resources/demoTranslateEmbeddedPython.gif)
7174

72-
> **This feature is still in beta.**
75+
> This feature is still in beta.
7376
7477
---
7578

@@ -103,7 +106,7 @@ This extension will create a directory named _ownobjectscriptextension-workspace
103106

104107
### Own ObjectScript Create
105108

106-
- `Create New Class`: Creates a new ObjectScript class. See [here](#create-new-class) for more information.
109+
- `Create New Class`: Creates a new ObjectScript class. See [here](#create-new-class-beta) for more information.
107110

108111
### Own ObjectScript Modifier
109112

@@ -148,6 +151,7 @@ Go to `File > Preferences > Settings` and than navigate to `Extensions > OwnObje
148151
### Create
149152

150153
- `Ask For Package First`: Set if the extension should ask for the package first (Default: _disabled_).
154+
- `Service: Add Target Config Names`: If enabled a property called `TargetConfigNames` will be added to your service, that represent the business partners inside of the production. (Default: _disabled_).
151155

152156
---
153157

@@ -159,9 +163,9 @@ Go to `File > Preferences > Settings` and than navigate to `Extensions > OwnObje
159163

160164
## [Release Notes](https://github.com/phil1436/ownobjectscriptextension/blob/master/CHANGELOG.md)
161165

162-
### [v0.0.13](https://github.com/phil1436/ownobjectscriptextension/tree/0.0.13)
166+
### [v0.0.14](https://github.com/phil1436/ownobjectscriptextension/tree/0.0.14)
163167

164-
- Command `Create New Class` added
168+
- Configuartion `Create > Service: Add Target Config Names` added
165169

166170
---
167171

extension.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -693,22 +693,27 @@ function activate(context) {
693693
// get the code
694694
switch (kind) {
695695
case 'Class':
696-
text = await wizard.createClass(className, packageName);
696+
text = await wizard.createClass(packageName, className);
697697
break;
698698
case 'Business Service':
699699
text = await wizard.createBusinessService(
700+
packageName,
700701
className,
701-
packageName
702+
vscode.workspace
703+
.getConfiguration(
704+
'ownobjectscriptextension.create.service'
705+
)
706+
.get('AddTargetConfigNames')
702707
);
703708
break;
704709
case 'Business Operation':
705710
text = await wizard.createBusinessOperation(
706-
className,
707-
packageName
711+
packageName,
712+
className
708713
);
709714
break;
710715
case 'Message':
711-
text = await wizard.createMessage(className, packageName);
716+
text = await wizard.createMessage(packageName, className);
712717
break;
713718
default:
714719
vscode.window.showErrorMessage('Something went wrong!');

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "Philipp B.",
66
"publisher": "Philipp B.",
77
"license": "MIT",
8-
"version": "0.0.13",
8+
"version": "0.0.14",
99
"repository": {
1010
"type": "github",
1111
"url": "https://github.com/phil1436/ownobjectscriptextension"
@@ -112,6 +112,11 @@
112112
"default": false,
113113
"markdownDescription": "If enabled the command `Own ObjectScript Create: Create New Class` will first ask for the package name and then for the class name."
114114
},
115+
"ownobjectscriptextension.create.service.AddTargetConfigNames": {
116+
"type": "boolean",
117+
"default": false,
118+
"markdownDescription": "If enabled the command `Own ObjectScript Create: Create New Class` will add a TargetConfigName property to the service class."
119+
},
115120
"ownobjectscriptextension.comment.InLineCommentCount": {
116121
"type": "number",
117122
"default": 5,

wizard.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ async function createClass(packageName, className) {
7070
* @param {string} className The class name
7171
* @returns {Promise<string>} The class text
7272
*/
73-
async function createBusinessService(packageName, className) {
73+
async function createBusinessService(
74+
packageName,
75+
className,
76+
addTargetConfigNames
77+
) {
7478
// TODO add types of method parameters dependend of the adapter
7579
const inboundAdapterSuggestion = [
7680
'None',
@@ -123,6 +127,17 @@ async function createBusinessService(packageName, className) {
123127
} else {
124128
inboundAdapter = 'Parameter ADAPTER = "' + inboundAdapter + '";';
125129
}
130+
131+
let onGetConnectionMethod =
132+
'/// Return an array of connections for drawing lines on the config diagram\nClassMethod OnGetConnections(Output pArray As %String, pItem As Ens.Config.Item)\n{\n Do ##super(.pArray,pItem)\n If pItem.GetModifiedSetting("TargetConfigNames",.tValue) {\n For i=1:1:$L(tValue,",") { Set tOne=$ZSTRIP($P(tValue,",",i),"<>W") Continue:""=tOne Set pArray(tOne)="" }\n }\n}';
133+
134+
let targetConfigNamesProperty =
135+
'/// Configuration item(s) to which to send file stream messages\nProperty TargetConfigNames As %String(MAXLEN = 1000);\n\nParameter SETTINGS = "TargetConfigNames:Basic:selector?multiSelect=1&context={Ens.ContextSearch/ProductionItems?targets=1&productionName=@productionId}";\n\n';
136+
137+
let onProcessInputImpl = addTargetConfigNames
138+
? ' #dim tSC As %Status = $$$OK\n #dim pRequest As Ens.Request\n\n // TODO\n\n For iTarget=1:1:$L(..TargetConfigNames, ",") {\n Set tOneTarget=$ZSTRIP($P(..TargetConfigNames,",",iTarget),"<>W")\n Continue:""=tOneTarget\n $$$sysTRACE("Sending message to \'"_tOneTarget_"\'")\n Set tSC = ..SendRequestAsync(tOneTarget, pRequest)\n }\n\n Quit tSC'
139+
: ' Quit $$$ERROR($$$NotImplemented)';
140+
126141
let text =
127142
'Class ' +
128143
packageName +
@@ -131,8 +146,13 @@ async function createBusinessService(packageName, className) {
131146
' Extends Ens.BusinessService' +
132147
' \n{ \n\n' +
133148
inboundAdapter +
149+
(addTargetConfigNames ? targetConfigNamesProperty : '') +
134150
'\n\nMethod OnProcessInput(pInput As %RegisteredObject, Output pOutput As %RegisteredObject) As %Status\n' +
135-
'{\n\n Quit $$$ERROR($$$NotImplemented)\n}\n\n}';
151+
'{\n' +
152+
onProcessInputImpl +
153+
'\n}\n' +
154+
(addTargetConfigNames ? onGetConnectionMethod : '') +
155+
'\n}';
136156
return text;
137157
}
138158

0 commit comments

Comments
 (0)