Will ModelMapper create intermediate objects? - modelmapper

From the example in the documentation...
map().customer.setName(source.getPerson().firstName);
If "customer" does not exist (is null) will ModelMapper create a new Customer object and setCustomer automatically, or do I have to create it beforehand?

ModelMapper will create intermediate objects for you, including customer in that example.

Related

how to create an object (call the constructor) from a BOM member in a BAL rule? IBM ODM

I have requirement in BAL rule to create objects and add them to a list
For instance, Customer is a class with below members
1. Name
2. Location
Based on the 'if' condition of the BAL rule, need to create objects of Type Customer and add them to Customerlist.
I tried to create objects by creating method in the Customer class in BOM editor by following steps provided under this link
how to create an object (call the constructor) from a BOM member on a decision table action column?
But I'm getting below error:
'Incompatible value in the 'return' instruction'
Can anyone please provide detailed steps to create objects and add them to a list in BAL?
Constructors are not directly verbalized in the BOM. You can create a method in XOM which creates the object via constructor and you can map this method onto BOM and verbalize it to be used in rule artifacts.
My suggestion to your scenario would be:
Create a verbalization in the XOM to receive the elements that will be added to the main list (Composite pattern).
Verbalize it
Add it in your Action Column (i.e. within a Decision Table)
I used this approach with great success in several scenarios, with no lack of performance.
Hope this helps.
Create an object and adding it to a list should be two separate methods.
Create: Assuming you followed the recipe for the link you provided, you should have a BOM method called createCustomer() on the Customer BOM class. Since there is no XOM to back that BOM method, you must supply B2X code for that method. Most people refer to such as a method as a virtual BOM method. It would be helpful to see the B2X code for that method. Are your BOM and XOM classes the same type? If not, you would have specified an execution name for the Customer BOM class. In that case, you may need to cast the return value of the createCustomer() BOM method to the Customer BOM class.
// Verbalize as: new customer
Customer Customer.createCustomer()
return (Customer) new OtherCustomerClassFromXOM();
Add: Define another virtual BOM method on some class, and name the method addCustomer(Customer customer). Usually it would be on the class that contained the list variable as a member. But if the list variable is a global variable (i.e., a ruleset variable), then the method could be a static member on any class, even your Customer class.
// Verbalize as: add {0} to {1}
void Customer.addCustomer(Customer customer, java.util.Collection customerList)
if (customerList == null) {
customerList = new java.util.ArrayList();
}
customerList.add(customer);

Pre-allocation of attributes by creating new entity

While creating new entity in CRM, some fields will be pre-allocated. Exmaple: for a new contact - transactioncurrency and ownerid will be filled with values. Haw can I programmatically find out, which rules will be used for such pre-allocation. I can't call "initializefromrequest" to find it out, because I want to build offline DB and there apply the rules
thanks
Get the EntityMetadata for your entity then examine AttributeMetadata for each Attribute to determine if the IsCustomAttribute Property is true
Retrieve Entity metadata using EntityFilters = EntityFilters.Attributes
Iterate the Attribute collection of the EntityMetadata in the response
Check the IsCustomAttribute property on each AttributeMetadata

Sharepoint workflow create task properties: when to create fields and when to create depepndency properties?

I'm new to SharePoint workflows.
When creating a new task and assign the TaskId I have two options:
To create a new field to hold the TaskId
To create a new property to hold the TaskId.
The new property is a dependency property.
My question is what is the difference between assigning the task as a field or as a property?
Thanks
Based on my (short) experience, WF DP can be useful in two cases :
you wan to split your workflow into subactivities, or you create custom activities. In this case, you have to use DP in order to pass data from the container to your activity in design mode (in code you can also with a public field).
you want to enhance the design time experience and/or apply some validation. You can apply some validation rules, editors, description, etc. that can help the developer to correctly use the property.
hth

Adding properties to an existing object retrieved using SubSonic

I think this is more of a polymorphism question but it applies to SubSonic table objects...
Here's the thing (and I love this one):
TblUser userObj = new TblUser(1);
Which fills userObj's properties with all of PK=1's goodies.
Now, I'd like to add more properties to the existing user object, for example, an ArrayList property of say, account numbers.
I've seen questions like this around - "add a property to an existing object...", but in this case, would it be most-recommended to create a user wrapper object, then have a TblUser property type, and my own other additional properties in this?
Ok, so it looks like once-again I have come up with a solution to this, but am still curious about the possibility of adding properties to existing objects.
All the generated SubSonic classes are partials so all you need to do to add extra properties/methods to them is to create your own partial class with the same name in the same namespace and the two will be merged at compile time. For example for your TblUser class:
public partial class TblUser
{
public List<AccountNumber> AccountNumbers
{
get
{
// Get and return the AccountNumbers
}
}
}

Can I add object field to SPItem, to attach some kind of object to item?

I have an SPListItem object. Can I add a field to store some kind of object like ArrayList or Dictionary, or whatever?
Thank you.
You can use SPListItem.Properties to store custom information which does not belong to a specific SPField. Dont forget to call Update()/SystemUpdate() after setting a property.

Resources