Skip to content

Commit 33a4495

Browse files
committed
multiple nspace support added
1 parent 3510309 commit 33a4495

9 files changed

Lines changed: 151 additions & 9 deletions

File tree

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ ENV IRISNAMESPACE "DPIPE"
3737
# run iris.script
3838
RUN iris start IRIS \
3939
&& iris session IRIS < /opt/irisapp/iris.script \
40+
&& iop --init \
4041
&& iop -m /opt/irisapp/src/python/Demo/settings.py \
4142
&& iris stop IRIS quietly

README.md

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@ Usually you will add:
116116

117117
Have a look at a full example in [DataPipe.Test.Production.cls](src/DataPipe/Test/Production.cls)
118118

119+
# Installation
120+
1) Install [IPM package manager](https://github.com/intersystems/ipm) if you don't have already done it.
121+
2) Create a new namespace (e.g. `DPIPE`)
122+
3) Switch to the namespace you want to install DataPipe.
123+
4) Install DataPipe using ipm:
124+
125+
```objectscript
126+
zpm "install iris-datapipe"
127+
```
128+
129+
5) Set up users and roles as needed (see next section).
130+
119131
## Users and privileges
120132

121133
DataPipe uses different security resources you can assign to InterSystems IRIS user account:
@@ -154,15 +166,64 @@ write ##class(Security.Users).Create("dpadmin","DataPipe_Admin","demo")
154166

155167
You can also check out the [DataPipe_Admin](http://localhost:52773/csp/sys/sec/%25CSP.UI.Portal.Role.zen?PID=DataPipe_Admin) role definition in InterSystems IRIS.
156168

157-
# Installation
158-
1) Install [IPM package manager](https://github.com/intersystems/ipm) if you don't have already done it.
159-
2) Create a new namespace (e.g. `DPIPE`)
160-
3) Switch to the namespace you want to install DataPipe.
161-
4) Install DataPipe using ipm:
169+
## Using DataPipe in multiple namespaces
170+
171+
You can install DataPipe in one namespace and use it in different namespaces using the same UI.
172+
173+
To do so, you need to:
174+
* Install DataPipe in source namespace
175+
* Map DataPipe and Restforms2 package and globals to target namespace
176+
* Grant access to tables and views on target namespace
177+
178+
The following example uses the **quickstart container** to configure Datapipe also in `USER` namespace:
179+
180+
1) DataPipe is already installed in `DPIPE` namespace.
181+
2) Map DataPipe and Restforms2 package and globals from `DPIPE` to `USER`:
162182

163183
```objectscript
164-
zpm "install iris-datapipe"
184+
zn "%SYS"
185+
186+
// package mapping
187+
set props("Database")="DPIPE-DATA"
188+
write ##class(Config.MapPackages).Create("USER", "DataPipe", .props)
189+
write ##class(Config.MapPackages).Create("USER", "Form", .props)
190+
191+
// global mapping
192+
write ##class(Config.MapGlobals).Create("USER", "DataPipe*", .props)
193+
write ##class(Config.MapGlobals).Create("USER", "Form*", .props)
194+
195+
// routine mapping
196+
write ##class(Config.MapRoutines).Create("USER", "Form*", .props)
197+
```
198+
199+
3) Grant access to tables and views on `USER` namespace:
200+
201+
```sql
202+
GRANT INSERT,SELECT,UPDATE ON DataPipe_Data.Pipe, DataPipe_Data.Preference TO DataPipe_Admin
203+
```
204+
205+
```sql
206+
GRANT SELECT ON DataPipe_Data.VInbox, DataPipe_Data.VIngestion, DataPipe_Data.VStaging, DataPipe_Data.VOper TO DataPipe_Admin
165207
```
208+
209+
4) Load a sample production in `USER` which already have DataPipe components:
210+
211+
```objectscript
212+
zn "USER"
213+
do $system.OBJ.Load("/app/install/SampleProduction.cls", "ck")
214+
```
215+
216+
5) Start the production
217+
218+
6) Send a test message
219+
220+
```objectscript
221+
zn "USER"
222+
write ##class(DataPipe.Test.REST.Helper).SendHTTPRequests(1, "/test/user/api/message")
223+
```
224+
225+
6) Check datapipeUI
226+
166227
## DataPipeUI considerations
167228

168229
When enabling [datapipeUI](https://github.com/intersystems-ib/iris-datapipeUI), you must consider the following:

install/SampleProduction.cls

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Class Test.SampleProduction Extends Ens.Production
2+
{
3+
4+
XData ProductionDefinition
5+
{
6+
<Production Name="Test.SampleProduction" TestingEnabled="true" LogGeneralTraceEvents="true">
7+
<Description></Description>
8+
<ActorPoolSize>2</ActorPoolSize>
9+
<Setting Target="Adapter" Name="ShutdownTimeout">5</Setting>
10+
<Setting Target="Adapter" Name="UpdateTimeout">5</Setting>
11+
<Item Name="REST API In" Category="" ClassName="DataPipe.Test.REST.BS.ApiService" PoolSize="0" Enabled="true" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
12+
</Item>
13+
<Item Name="REST Ingestion" Category="Ingestion" ClassName="DataPipe.Test.REST.BP.RESTIngestion" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
14+
</Item>
15+
<Item Name="REST Staging" Category="Staging" ClassName="DataPipe.Staging.BP.StagingManager" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
16+
<Setting Target="Host" Name="TargetConfigName">REST Oper</Setting>
17+
</Item>
18+
<Item Name="REST Oper" Category="Oper" ClassName="DataPipe.Oper.BP.OperManager" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
19+
</Item>
20+
<Item Name="Person Operation" Category="Oper" ClassName="DataPipe.Oper.BO.OperationHandler" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
21+
</Item>
22+
<Item Name="REST Delayed Oper Update" Category="" ClassName="DataPipe.Test.REST.BP.DelayedProcessing" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="true" Schedule="">
23+
</Item>
24+
</Production>
25+
}
26+
27+
}

install/roles.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
<Name>%DB_DPIPE</Name>
1212
<Permission>3</Permission>
1313
</Resource>
14+
<Resource>
15+
<Name>%DB_USER</Name>
16+
<Permission>3</Permission>
17+
</Resource>
1418
<Resource>
1519
<Name>%DB_HSLIB</Name>
1620
<Permission>3</Permission>

install/webapps.xml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,35 @@
3131
<UserCookieScope>2</UserCookieScope>
3232
<Version>2</Version>
3333
</Applications>
34+
<Applications>
35+
<AutheEnabled>32</AutheEnabled>
36+
<AutoCompile>true</AutoCompile>
37+
<CookiePath>/test/user/api/</CookiePath>
38+
<CSPZENEnabled>true</CSPZENEnabled>
39+
<CSRFToken>false</CSRFToken>
40+
<DeepSeeEnabled>false</DeepSeeEnabled>
41+
<DispatchClass>DataPipe.Test.REST.BS.ApiService</DispatchClass>
42+
<Enabled>true</Enabled>
43+
<HyperEvent>0</HyperEvent>
44+
<iKnowEnabled>false</iKnowEnabled>
45+
<InbndWebServicesEnabled>true</InbndWebServicesEnabled>
46+
<IsNameSpaceDefault>false</IsNameSpaceDefault>
47+
<JWTAuthEnabled>false</JWTAuthEnabled>
48+
<JWTAccessTokenTimeout>60</JWTAccessTokenTimeout>
49+
<JWTRefreshTokenTimeout>900</JWTRefreshTokenTimeout>
50+
<LockCSPName>true</LockCSPName>
51+
<Name>/test/user/api/</Name>
52+
<NameSpace>USER</NameSpace>
53+
<Recurse>true</Recurse>
54+
<RedirectEmptyPath>false</RedirectEmptyPath>
55+
<ServeFiles>1</ServeFiles>
56+
<ServeFilesTimeout>3600</ServeFilesTimeout>
57+
<Timeout>900</Timeout>
58+
<TwoFactorEnabled>false</TwoFactorEnabled>
59+
<Type>2</Type>
60+
<UseCookies>2</UseCookies>
61+
<SessionScope>2</SessionScope>
62+
<UserCookieScope>2</UserCookieScope>
63+
<Version>2</Version>
64+
</Applications>
3465
</ApplicationsExport>

module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Document name="iris-datapipe.ZPM">
44
<Module>
55
<Name>iris-datapipe</Name>
6-
<Version>2.0.2</Version>
6+
<Version>2.0.3</Version>
77
<Description>DataPipe an interoperability framework to ingest data in InterSystems IRIS in a flexible way.</Description>
88
<Keywords>datapipe ingestion staging validation</Keywords>
99
<Author>

src/DataPipe/Data/Inbox.cls

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ Property LastStaging As Staging(%JSONREFERENCE = "ID");
3535
/// Ref. to last Oper
3636
Property LastOper As Oper(%JSONREFERENCE = "ID");
3737

38+
/// Namespace where this record is processed
39+
/// This is useful when different namespaces map DataPipe package
40+
Property Namespace As %String [ InitialExpression = {$namespace} ];
41+
3842
/// *Calculated* StagingStatus (from LastStaging). Used in queries from app
3943
Property StagingStatus As %String(MAXLEN = "") [ SqlComputeCode = { set {StagingStatus} = ##class(DataPipe.Data.Inbox).CalcSqlFieldById("LastStaging->Status", "N/A", {%%ID})
4044
}, SqlComputed, SqlComputeOnChange = %%UPDATE ];
@@ -80,6 +84,8 @@ Index ElementIdx On Element;
8084

8185
Index SubjectIdx On Subject;
8286

87+
Index NamespaceIdx On Namespace [ Type = bitmap ];
88+
8389
/// Open callback. Check user can access record in view
8490
Method %OnOpen() As %Status [ Private, ServerOnly = 1 ]
8591
{
@@ -224,6 +230,9 @@ Storage Default
224230
<Value name="18">
225231
<Value>OperErrors</Value>
226232
</Value>
233+
<Value name="19">
234+
<Value>Namespace</Value>
235+
</Value>
227236
</Data>
228237
<DataLocation>^DataPipe.Data.InboxD</DataLocation>
229238
<DefaultData>InboxDefaultData</DefaultData>

src/DataPipe/REST/Main.cls

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ ClassMethod multiRepeat() As %Status
100100
set %response.Status=..#HTTP401UNAUTHORIZED
101101
quit
102102
}
103+
new $namespace
104+
set defaultNs = $namespace
103105

104106
// parse body
105107
set input = {}.%FromJSON(%request.Content)
@@ -126,6 +128,13 @@ ClassMethod multiRepeat() As %Status
126128
$$$ThrowStatus($$$ERROR($$$GeneralError, "Invalid type"))
127129
}
128130

131+
// change namespace, this is used when DataPipe is mapped to multiple namespaces
132+
if obj.Namespace'="" {
133+
set $namespace = obj.Namespace
134+
} else {
135+
set $namespace = defaultNs
136+
}
137+
129138
// resend interop message
130139
;do $system.Security.Login("_Ensemble")
131140
$$$ThrowOnError(##class(Ens.MessageHeader).NewDuplicatedMessage(.duplicatedHeader, headerId, ""))

src/DataPipe/Test/REST/Helper.cls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Parameter USERNAME = "superuser";
1111

1212
Parameter PASSWORD = "SYS";
1313

14-
ClassMethod SendHTTPRequests(pNumRequests As %Integer = 1) As %Status
14+
ClassMethod SendHTTPRequests(pNumRequests As %Integer = 1, appName = "/test/api/message") As %Status
1515
{
1616
set ret = $$$OK
1717
try {
@@ -27,7 +27,7 @@ ClassMethod SendHTTPRequests(pNumRequests As %Integer = 1) As %Status
2727
set headers("X-Forwarded-For") = "client-"_##class(%PopulateUtils).Syllable()
2828
set headers("X-Request-ID") = $system.Util.CreateGUID()
2929

30-
set sc = ..Post("/test/api/message", .headers, body, .resp)
30+
set sc = ..Post(appName, .headers, body, .resp)
3131
$$$ThrowOnError(sc)
3232

3333
if resp.StatusCode '= 200 {

0 commit comments

Comments
 (0)