setting distinguished fields in a biztalk message - biztalk

The issue:
I'm trying to transform and route a message based on its input file name. The file name gives hints about how the data should be processed. Being a noob I'm reasonably sure I'm doing this the hard way...
I created an orchestration. I transform the message from the input schema to the output schema. I'd like to examine the file name and add a little logic to classify the input message. That works just fine.
What I tried:
I added an expression shape after the transformation. I added logic to classify the message and assign that to a property. It won't allow me to change the property (messages are immutable?)
I added a construct message shape. I can set properties in a new message within this shape but it doesn't allow "if" statements or conditional assignments in the expression. I need conditional logic to search the file name string and set the property to one of several choices.
Any suggestions?

You can either wrap your logic into a .net helper method and call this from the assignment shape, or you can use the conditional flow control shapes provided by biztalk, such as the decide shape, and have multiple contruct shapes in your branches.
Let me know if you need more detail about either approach via a comment and I will expand the answer to include.
Hope this helps.

You could use a helper class to take the file name and return the value to set in the property.
Alternatively, you could use the decide shape for your if..then..else.
Have I understood your question?
HTH...

Related

What would be the best method of creating a block which outputs a Redstone Signal

I'm wondering what would be the best way to allow a block to send out a specific amount of Redstone output conditionally. While looking through other blocks that gave a Redstone output, I noticed that they were mostly using the getWeakPower() method. However, I noticed that this was a Deprecated method and my IDE formats the method with a strikethrough. Additionally, I also found another method named getStrongPower() (also Deprecated). Which one of these two method would be best to override or would there be a better way to set the Redstone output of a block.
Although these blocks have the #Deprecated annotation to them, the JavaDoc comment states that "Implementing/overriding is fine". These getWeakPower() and getStrongPower() methods are only flagged as being deprecated in the net.minecraft.block.Block class because they are not meant to be accessed from the Block class, instead they are supposed to be accessed from the net.minecraft.block.BlockState class as that will contain the most up to date state of a given block instance.
It seems that most blocks which use Redstone functionality override the getWeakPower() method to control the Redstone output of the block by returning a specific value from 0 to 15 from the method. It’s also possible to separately control the output of each side (only output on one side or different outputs on each side), by using the Direction parameter passed into the method to determine the returned value.
Note: You must override the canProvidePower() method to return true. Otherwise, neighboring blocks will not check the block for a Redstone output and the desired functionality won’t work.

Can you map a fixed value using the standard BizTalk mapper

Normally, I create my BizTalk mappings in the XSL. Today I was playing around with the mapper but I am failing to do the most basic thing and googling it fails me (I find unrelated questions or the basic way to do it in XSL)
The question is simple though, I want to use the BizTalk mapper (btm file) to map one element to another and fill a second element with a fixed value.
Looking at the functoids, I have a date functoid which gets today's date but nothing to just type some text and map it.
Am I missing something very obvious?
The "built in" way to do this is to set the Value property on the destination node in the map (you can also use this property to desginate that an empty node should be created for this destination node). Unfortunately, this method offers no visual representation that the node is being set this way, except that it will prevent you from linking other nodes/functoids to that destination node. This may lead future devs (or your future self) to think the node isn't being set, or be confused as to why it's being set when it has no inputs.
To get around this, I've frequently used either a String Concatenate functoid (with the fixed value as the only parameter, manually typed in) or a Value Mapping functoid (set "true" as the first parameter and the fixed value as the second parameter). This offers a few benefits:
Visually shows that node is being set by the map
Allows you to set a meaningful label and/or comment on the functoid to denote why you're setting that value.

Generating switch-case function out of State chart

Although my question is very simple I can't find an answer for it.
I created a class in Rhapsody and associated a statechart to this class but when I generate the code I can't find and code in the class related to the state chart.
Is there any function that needs to be created as a trigger or am I missing something?
my example state chart:
After searching for a long while I could find the option that was preventing the generation.
First of all, you need to define a reactive class to be able to generate a code for a state machine. This point was OK for me and I thought this was only what matters until I found this property here:
The _CG::Statechart::StatechartStateOperations property
determines whether the code is generated for this feature. The
possible values for this property are:
None (default value) where code is not generated for the feature.
WithoutReactive where the product does not generate calls to OMReactive
WithReactive where the product generates calls to OMReactive

Adding a callback when reading from an object in Twig

Let's say I have a basic entity called Entity which is mapped to a database table. This entity has got two properties: propertyA and propertyB.
One particularity of this entity is, although we may store whatever we want in these properties, when using the value of propertyB on a Twig template with entity.propertyB we want to systematically truncate the value to 100 characters.
Now, this is perfectly doable in several ways:
Truncate the value directly in the getPropertyB() method;
Register a Twig extension and create a dedicated filter;
Add a lifecycle callback on the entity to truncate the value before the object is actually created.
As this is strictly a display rule, and not a business rule on our entity, the second solution seems to be the best IMHO. However, it demands we apply the filter every time we need to use the value of propertyB in a template. Should an unaware developer come by, the value may not be truncated.
So my question is: is there a way to register some kind of callback, strictly restricted to the view model wrapping our entity, which would allow us to apply some filters on the fly on some of its properties ?
Since you never need to access anything beyond 100 characters, you can truncate the property in its setter. This doesn't really pollute Entity code, because this is some logic inherent to it.

Is it possible possible to add an object to the ObjectDataSource's InsertParameters collection? [as opposed to a string]

I'm invoking the ObjectDataSource InsertMethod programmatically. I've tried so save a couple of text boxes' value to the DB using the InsertParameters.Add() method, and it worked perfectly.
SqlDataSource1.InsertParameters.Add("CoName", CompanyNameBox.Text);
SqlDataSource1.InsertParameters.Add("Phone", PhoneBox.Text);
SqlDataSource1.Insert();
Now, given that I have an important number of variables, I've regrouped those variables in one object.
Now, it looks like there's no overload method that allow me to add a parameter accepting an object to the collection.
What the best way to do that? Any other alternative?
Thanks for helping.
All your paramaters will have to be provided one by one in your code, that is to say one call to add a parameter per property of your custom object.

Resources