Eduard Lebedyuk · Sep 27, 2017 go to post

This condition is insufficient for multi-level inheritance (C is a subclass of B, B is subclass of A. So C is subclass of A but Super wouldn't show this information). More on that in here.

Eduard Lebedyuk · Sep 27, 2017 go to post

SMP -> Ensemble -> Build -> Business Processes -> [Open your BP] -> Show print friendly version of diagram -> Print that page.

EnsPortal.SVG.SVGPrint.zen page outputs the SVG image so if you need you can subclass it to print SVG to file or inject into some document.

Eduard Lebedyuk · Sep 26, 2017 go to post

SQL gateway connections settings are stored in %SQLConnection class and the corresponding %Library.sys_SQLConnection table. Note that passwords are stored in encrypted form, so you can't get them as a plaintext. Also password may be stored as a part of system ODBC configuration, so there would be no password at all stored in Caché.

Eduard Lebedyuk · Sep 22, 2017 go to post

Assuming  you're on 2016.2+:

set payload = "{""profile_id"":""9XOzzcI8NfSUjxAhEt0cTLRejwmp6HPi"",""biometrics"":[{""timestamp"":""2017-05-17T13:45:40"",""utc_offset"":""+02:00"",""resting_heartrate"":120.0,""spo2"":98.0,""activity_id"":""591c540aac8f295479ee14ce""}]}"
set obj = {}.%FromJSON(payload)
write obj."profile_id"
>9XOzzcI8NfSUjxAhEt0cTLRejwmp6HPi
write obj.biometrics.%Get(0).timestamp
>2017-05-17T13:45:40
Eduard Lebedyuk · Sep 21, 2017 go to post

It's really not.

You can have "On Demand" task and call it from %ZSTART. This way you can have task scheduler reporting and execute task only when it's required.

Eduard Lebedyuk · Sep 20, 2017 go to post

Is there any reason to use Task Manager instead of %ZSTART?

Anyway you can have a task that runs hourly, and checks for existence of ^CacheTemp.MyTask global. If the global does not exist, set it and execute the task. If the global exists - quit. Since restart wipes CacheTemp, the global wouldn't exist on startup.

Eduard Lebedyuk · Sep 20, 2017 go to post

What if I have extra properties such as InsertTime in the Test.cvs class?

What about them? When you call %SQL.Util.Procedures:CSVTOCLASS you need to specify rowtype, corresponding to your CSV structure. If you have InsertTime property you need to reflect it and any other properties CSV has in your rowtype.

Eduard Lebedyuk · Sep 20, 2017 go to post

In Ensemble Visual Trace you can filter by Business Host. To do that:

  1. Open Ensemble Visual Trace
  2. Click on the Business Host you need
  3. In Apply Filter dropdown choose the  filter you need (Host or Corresponding)
  4. Visual trace would be filtered to messages sent to/from specified Business Host

 

Eduard Lebedyuk · Sep 20, 2017 go to post

 Here's how:

  1. SMP > Ensemble > Production Configuration > Your Business Service > Settings > Additional Settings > Schedule > Press on the the looking glass
  2. In Schedule Spec Editor press "New"
  3. Specify Schedule name and press OK
  4. Set "Raw String" schedule or use "Add action" specify a schedule
  5. Press "Save spec"
  6. Schedule setting in your Business Service should be set now
  7. Restart your Business Service
Eduard Lebedyuk · Sep 20, 2017 go to post

To run Business Service once an hour:

  1. Specify Ens.InboundAdapter as an adapter for your Business Service
  2. On Production Configuration page, in Business Service configuration set Call Interval to 3600.
  3. Restart Business Service. It would now be run once an hour (every 36000 seconds)
Eduard Lebedyuk · Sep 20, 2017 go to post

To convert string of any format into $horolog, use TO_DATE function:

w $SYSTEM.SQL.TODATE("20160105125915","YYYYMMDD")
>63922

To convert string of any format to timestamp use TO_TIMESTAMP function:

w $SYSTEM.SQL.TOTIMESTAMP("20160105125915","YYYYMMDDHHMISS")
>2016-01-05 12:59:15

These functions are available in Caché ObjectScript and SQL.

Eduard Lebedyuk · Sep 20, 2017 go to post

Provided you have this csv:

car,2000,100.51,27.10.2016,
phone,2003,65.8,15.01.2017,

You can import it into class Test.CSV:

1. Generate a persistent class Test.CSV

set rowtype = "name VARCHAR(50),year INTEGER,amount NUMERIC(9,2),date DATE"
set filename = "D:\data.csv"
do ##class(%SQL.Util.Procedures).CSVTOCLASS(2, .rowtype, filename,,,,"Test.CSV")

2. Import file or files

do ##class(Test.CSV).Import(2,filename)

 

Usually you can't import your CSV right away - the dates are in a different format, etc. You need to modify Import method and property definitions. For example I often:

  • Add FORMAT=4 property parameter for dates to import dates in dd/mm/yyyy format.
  • Find&replace Library.
  • Add this else line in Import method:
if $$$ISOK(tStatus) { set tCounter = tCounter + 1 } else { w $System.Status.GetErrorText(tStatus) return}

 

If you have a tab separated file, you need to change Import method signature from:

pDelimiter As %String = ","

to:

pDelimiter As %String = {$c(9)}
Eduard Lebedyuk · Sep 19, 2017 go to post

Check out Demo.ZenService.Zen.WeatherReportForm class in ENSDEMO namespace. GetWeatherReport method there creates a BS and sends a message to a BP outside of Ensemble context. You need to send an object and not a datatype, so in your example:

Set tSC = tService.ProcessInput(datePurge,.output)

Should be instead:

Set message = ##class(Ens.StringContainer).%New(datePurge)
Set tSC = tService.ProcessInput(message,.output)

If you want to send a message to a BP or BO you can do that too, just create an Ensemble message and use SendSync or SendAsync to send it from BS:

Set message = ##class(Ens.StringContainer).%New(datePurge)
Set targetHostName = "Name of BP or BO"
Set description = "My request description"
// Set timeout = 10 // how long to wait for a Sync call response, skip to wait forever
// Set tSC = tService.SendRequestSync(targetHostName, message, .response, timeout, description)
Set tSC = tService.SendRequestAsync(targetHostName, message, description)

That said, Ensemble hosts can run on schedule so you can use built-in Ensemble scheduler and not a system task manager.

Eduard Lebedyuk · Sep 19, 2017 go to post

How does Vue.JS stacks against other popular JS frameworks like Angular2, React, etc.?

Eduard Lebedyuk · Sep 19, 2017 go to post

I prefer %SQL.Util.Procedures because it is easier to use and it generates classes and methods that can be easily modified.

Eduard Lebedyuk · Sep 18, 2017 go to post

Ensure that user, which you are using to access the database has apropriate permissions to connect and access data.

Eduard Lebedyuk · Sep 16, 2017 go to post

> Would you have three branches for the code or 3 repo's.


Please describe differences between your DEV, TEST, PROD code. Still, I'd probably recommend one repo and 3 branches.

>Would you have three projects in Atelier to communicate with the environments and GitHub?


No, there would be one Atelier project for DEV. All other code propagation should be done automatically by Continuous Integration/Continuous Delivery solution.

Eduard Lebedyuk · Sep 12, 2017 go to post

That may mean one of the several things:

  • You're not specifying or specifyiong incorrectly one or several request header parameters. One of the most often encountered errors is not specifying ContentType as application/json.
  • Request content is formed incorrectly

Anyway, to solve this problem you need to make a correct request to the target system, record it and compare to the Ensemble request. Here's an article on that.

Eduard Lebedyuk · Sep 11, 2017 go to post

Same as with modifying a rule:

Business Rule Definition is stored as XML in XData block named RuleDefinition inside rule class and can be (de)serialized as an object of Ens.Rule.Model.ruleDefinition class. Some utility methods are available there.

Here's an example of modifying Demo.ComplexMap.Rule.SemesterBatchRouting rule in ENSDEMO class. It modifies "when" condition from 1 to 0.

zn "ENSDEMO"
set ruleClass = "Demo.ComplexMap.Rule.SemesterBatchRouting"
set sc = ##class(Ens.Rule.Model.ruleDefinition).LoadFromClass(ruleClass, .rule)
set rule.ruleSets.GetAt(1).actions.GetAt(1).whens.GetAt(1).condition=0
w rule.SaveAs(ruleClass)
set sc=$system.OBJ.Compile(ruleClass,"k-d")

But instead of:

set sc = ##class(Ens.Rule.Model.ruleDefinition).LoadFromClass(ruleClass, .rule)

You need to create and fill rule object manually.

Relevant discussion.

Eduard Lebedyuk · Sep 11, 2017 go to post

In any place (but preferably in the beginning) of your REST handler method add these lines:

set %response.ContentType = "text/html"
do ##class(%CSP.Utils).DisplayAllObjects()
quit $$$OK

and then open REST Url to see all current objects, including %request.

Eduard Lebedyuk · Sep 10, 2017 go to post

You can use %Dictionary package to modify classes.

For example you can open property which is an object of %Dictionary.PropertyDefinition, modify it and save. Recompile the class to see new class definition.

Here's an example of %Dictionary modification to create new method.

Eduard Lebedyuk · Sep 7, 2017 go to post
  1. Source control
  2. Code
    • Sure, I've done something similar. Here's the code.
    • Missed that, sorry.
  3. Ensemble
    • Sure, Inside your production you have access to all BO properties, including retry-relevant:  ..RetryCount, ..%LastReportedError and many others. So first you determine if the current message is a retry (..RetryCount>0) or not and then you can decide what to do with your request based on that.

Code for the custom adapter that specifies Content type:

Class Production.Adapter.HTTPOutboundAdapter Extends EnsLib.HTTP.OutboundAdapter
{

Method Post(Output pHttpResponse As %Net.HttpResponse, pFormVarNames As %String, pData...) As %Status
{
    quit ..SendFormDataArray(.pHttpResponse, "POST", ..GetRequest(), .pFormVarNames, .pData)
}

ClassMethod GetRequest() As %Net.HttpRequest
{
    set request = ##class(%Net.HttpRequest).%New()
    set request.ContentType = "application/json"
    quit request
}

}

Note that this way only one-line method Post gets redefined (you'll also need to redefine Get method, but still - these are small one-line methods). ContentType may be further refactored as a setting.

Eduard Lebedyuk · Sep 7, 2017 go to post

Some comments

  1. Source control
    • Each class should be in a separate file. There are many source control hooks available.
    • When redefining system methods like SendFormDataArray method in DLS.HTTP.OutboundAdapter class it's better to do it in two commits - in a first one you just copy method as is and in a second you modify it. It's easier to understand "what changed?" that way (via git blame).
  2. Code
    • Do not subclass/modify system methods if it's possible. What was modified SendFormDataArray?
    • Add comments to the parts you change when you must subclass/modify system methods.
    • $CLASSNAME($THIS) is equal to $CLASSNAME()
  3. Ensemble