Retrieve culture specific value of definition field in uCommerce - umbraco-ucommerce

We're creating some custom fields by adding new definition fields to category and product definition items in uCommerce.
When we retrieve an instance of the ctegory or prouduct from the uCommerce.Entitiesv2 we're having trouble getting the culture specific value for these fields when multilingual is selected?
There is a collection on the Product object called ProductDefinitionField but not sure whether .Value returns the culture specific version of whether we need to call another method (extention method maybe)
Has anyone got a code snipper for this?

When accessing or retrieving Multilingual properties on a uCommerce you can use the GetProperty method on a product.
It has two overloads, one taking name (string) and another one taking name (string) and culturecode (string).
If you want to retrieve the full collection of multilinqual properties you can use GetProperties which also have two overloads. One without parameters and the other with a string culturecode.
Depending on the version of uCommerce you're using some of them might be missing/not a part of the API.
Best regards Martin

Related

How to form URL for different entity in Dynamics 365?

I am building up url for different entity in Dynamics 365 crm. I found this for crm 2011 but I want more elaborate solution than that.
Observed URL:
For Quote Entity: https:**[instance url]**.com/main.aspx?etc=1084&extraqs=&histKey=254156564&id=%7b[**GUID**]%7d&newWindow=true&pagetype=entityrecord&sitemappath=SFA%7cCollateral%7cnav_quotes#765575448
For Order Entity: https:**[instance url]**.com/main.aspx?etc=1088&extraqs=&histKey=653905533&id=%7b[**GUID**]%7d&newWindow=true&pagetype=entityrecord&sitemappath=SFA%7cCollateral%7cnav_orders#817364929
I created other url for other entities and observed the query parameter value of the url as like below:
1. etc is constant for different entity. eg. for quote(1084) and order(1088)
2. extraqs is empty.
3. histKey is variable for an entity. It is appearing in different value for a same entity record.
4. id is the unique identifier of a record (i have no question about this)
5. sitemappath is different for different entity.
Now I want to know about -
1. what is etc and why it remains same for a entity always?
2. what is histKey(why it gives random value every time) and sitemappath?
We are using these in our Dynamics 365 CRM application without issues. Read more
Simple record form using etc (entity type code):
https://myorg.crm.dynamics.com/main.aspx?etc=1&id=%7b[GUID]%7d&pagetype=entityrecord
Same record using etn (entity type name):
https://myorg.crm.dynamics.com/main.aspx?etn=account&id=%7b[GUID]%7d&pagetype=entityrecord
Same record in UCI:
https://myorg.crm.dynamics.com/apps/appname/main.aspx?etc=1&id=%7b[GUID]%7d&pagetype=entityrecord
Particular form using formid:
https://myorg.crm.dynamics.com/main.aspx?etc=1&id=%7b[GUID]%7d&pagetype=entityrecord&extraqs=formid%3d[formGUID]
sitemap can be ignored as the pagetype param will render the top navigation bar & histkey can also be ignored as its for internal platform/browser usage for previous/forward navigation. extraqs is any extra query string param you want to pass that pre-populate the form attribute.
https://myorg.crm.dynamics.com/main.aspx?etc=1&id=%7b[GUID]%7d&pagetype=entityrecord&extraqs=fullname%3DNew%20Contact
Documentation says:
Do not use the etc (entity type code) parameter that contains an integer code for the entity. This integer code varies for custom entities in different organizations
But if you are not creating a custom entity directly in any non-development environment, only the solution is being used to port the customizations across different environment then that should not be an issue.
To open a Particular Record for Account Entity, Where etn is Entity Schema name.
http://myorg.crm.dynamics.com/main.aspx?etn=account&pagetype=entityrecord&id=%7B91330924-802A-4B0D-A900-34FD9D790829%7D
For Example you have a Custom Entity let's call it Account Plan and your entity schema name is new_accountplan, so your url will be something like below
http://myorg.crm.dynamics.com/main.aspx?etn=new_accountplan&pagetype=entityrecord&id=%7B81440924-802A-4B0D-A900-34FD9D790829%7D
Similar way to open a particular Form for user to fill information
https://myorg.crm.dynamics.com/main.aspx?etc=1&id=%7b[GUID]%7d&pagetype=entityrecord&extraqs=formid%3d[formGUID]
You can use Power Pane Chrome addon which is a helper tool , help you to show entities urls

In DDD, how to create/edit domain ValueObjects ASP.NET MVC?

We have identified a Location entity in a database as a value object in our domain (DDD). Locations are used by other domain objects, but don't really "stand alone" -- they always belong to another entity.
Now we are trying to edit a list of these values in a simple MVC web application. So the view would show a list of locations in a view model LocationViewModel.
However, the value object is by definition immutable, yet does hold a reference to another entity (Business).
Domain:
public class Location : ValueObject<Location>
{
readonly locationId;
public int LocationId {get{return _locationId;}}
public Business Business {get;set;}
}
My problem is understanding how you can simply edit a bunch of value objects in a UI and change, e.g. what Business the location belongs to.
A value object is not supposed to have an "identity", but it does need an ID so the repository can update the database.
I also don't think you can make Location an entity just because you want to edit it in the UI. Or is Location, in this scenario indeed an Entity?
What am I not understanding?
Thank you!
It's a classic problem. In one context it's an entity and in another a value object. I found the example of a telephone number helpful to understanding this sort of problem.
In a CRM for example, a telephone number is a value object. The same one can be associated with multiple contacts. It varies by value (key concept here). So in this context it's a value object. In this example, I could store telephone numbers in the database and the 'ID' would be the telephone number itself. If the value object was made up of multiple parts then they would form a composite key.
If however we looked at a telephone number at a telephone company. That would most likely be an Entity. It could have all manor of information attached to it. All that info would vary by ID (which in this case would be the number).
In your case, Location sounds like a value object. If you need to save it in a database as a thing rather than just as part of an entity then use it's parts as a composite key. You will need to handle what happens when you 'change' one as it's not a change but the creation of new value object. One approach is to remove the old and insert the new. Or just keep all versions. It depends on your domain.
Hope that's helpful.
You don't change a value object. You create a new one with different values. If the value object has few properties that you want often to change, some helper methods are usefull. myObject.WithX(4711) will create a new instance with all properties the same as myObject but the X Property changed to 4711 for example.
To "edit" a value object in an UI you use a viewmodel. The Viewmodel is not a value object (and no entity by the way) and is not part of your domain. It's purely in the Presentation Layer. It is editable and mutable. It could have a constructor, taking your (immutable) value object to copy its values from and it could have a ToXXX Method to create a new (immutable) value object with its current (and changed) values.
If you want to store your value objects in a separate table (instead of roll out the fields in the table that stores the owning entity) this is purely data access layer related and not part of your domain model. This could be done by mapping. In the value object the database id is immutable and has no meaning in the domain model.

How to create a dictionary list type property for document type in Umbraco?

I am quite new to Umbraco. I want to create a new property in my document type. This property is a list which contains items like dictionary type which has a key and a value. User can select multiple of these. For example
My document type is "Product", The property I want to create is "Related Items". Each related item will have an name & a url.
Can someone please give me an idea how to do this?
Cheers
You can use the default data types of Umbraco for it: http://our.umbraco.org/wiki/reference/default-datatypes (The wiki doesn't seem updated, but an the ultimate picker will get you the result you need, for example) You can do this in the developer section, create a new one from the defaults and add it to your document type afterwards.
You can also build a custom one, wich is becoming more and more easy, but the approach of doing it is now different in the new umbraco 7 version. Which version are you using?

Can't understand, what does method getSingularObjectFromString do?

I'm developing own custom field type in JIRA.
My class is very simple, it extends GenericTextCFType.
My goal is to store some identifier (ID) of field value in database but to show human-readable caption of the field value on Issue form.
I searched methods of GenericTextCFType class and found method getSingularObjectFromString, and I don't understand, what it does.
JIRA javadoc says: "Returns a Singular Object, given the string value as passed by the presentation tier"
But what is the Singular Object and what is it needed for?
Yes, it's not a great name. I wrote about it in detail in "Practical JIRA Plugins"
(O'Reilly). Here's an extract from there describing many of the methods in detail (sorry about the formatting). The book also has worked examples available at https://bitbucket.org/mdoar/practical-jira-plugins
CustomFieldType Methods
The example’s custom field type class will implement the CustomFieldType interface as usual, but instead will extend a class higher up in the inheritance hierarchy than NumberCFType. The class we will extend is AbstractCustomFieldType and it’s at the root of most classes that implement CustomFieldType.
The methods in the CustomFieldType interface with “SingularObject” in their name refer to the singular object, in this example a Carrier object. All other methods in JIRA 4 custom fields that refer to an Object are referring the transport object, e.g., a Collection of Carrier objects. JIRA 5 removed the use of Object in most custom field methods.
For more information about what changed in JIRA 5.0 with custom fields see https://developer.atlassian.com/display/JIRADEV/Java+API+Changes+in+JIRA+5.0#JavaAPIChangesinJIRA5.0-CustomFieldTypes. There were some major changes in the class hierarchy, and most classes now have a Java generic as a parameter instead of just using an Object as before.
There are two objects that are typically injected into the constructor of a custom field type’s class. The first is a CustomFieldValuePersister persister object, which is what will actually interact with the database. The second is a GenericConfigManager object that is used for storing and retrieving default values for the custom field. Other objects are injected into the constructor as needed—for example, the DoubleConverter in Example 2-2.
The first set of methods to consider are the ones that the custom field type uses to interact with the database in some way.
getSingularObjectFromString()
This method converts a string taken from the database such as “42.0###The answer” into a Carrier object. A null value means that there is no such object defined.
Fields with Multiple Values
Collection<Carrier> getValueFromIssue(CustomField field, Issue issue)
This is the main method for extracting what a field contains for a given issue. It uses the persister to retrieve the values from the database for the issue, converts each value into a Carrier object and then puts all the Carrier objects into a trans- port object Collection. A null value means that this field has no value stored for the given issue. This is one of the methods that used to return an Object before JIRA 5.0
createValue(CustomField field, Issue issue, Collection<Carrier> value)
updateValue(CustomField field, Issue issue, Collection<Carrier> value)
These methods create a new value or update an existing value for the field in the given issue. The persister that does this expects a Collection of Strings to store, so both of these methods call the method getDbValueFromCollection to help with that.
getDbValueFromCollection()
A private convenience method found in many custom field type classes, sometimes with a different name. It is used to convert a transport object (e.g., a Collection of Carrier objects) to a Collection of Strings for storing in the database.
setDefaultValue(FieldConfig fieldConfig, Collection<Carrier> value)
Convert a transport object (a Collection of Carrier objects) to its database repre- sentation and store it in the database in the genericconfiguration table.
Collection<Carrier> getDefaultValue(FieldConfig fieldConfig)
Retrieve a default value, if any, from the database and convert it to a transport object (a Collection of Carrier objects). The FieldConfig object is what represents the context of each default value in a custom field.
The next set of methods to consider are the ones that interact with a web page in some way. All values from web pages arrive at a custom field type object as part of a Custom FieldParams object, which is a holder for a Map of the values of the HTML input elements.
validateFromParams(CustomFieldParams params, ErrorCollection errors, FieldConfig config)
This is the first method that is called after a user has edited a custom field’s value. Any errors recorded here will be nicely displayed next to the field in the edit page.
getValueFromCustomFieldParams(CustomFieldParams customFieldParams)
This method is where a new value for a field that has been accepted by validate FromParams is cleaned and converted into a transport object. The custom FieldParams object will only contain strings for the HTML elements with a name attribute that is the custom field ID—e.g., customfield_10010. A null value means that there is no value for this field.
getStringValueFromCustomFieldParams(CustomFieldParams parameters)
This method returns an object that may be a String, a Collection of Strings or even a CustomFieldParams object. It’s used to populate the value variable used in Chapter 3: Advanced Custom Field Types Velocity templates. It’s also used in the Provider classes that are used by custom field searchers.
String getStringFromSingularObject(Carrier singularObject)
This method is not the direct opposite of getSingularObjectFromString as you might expect. Instead, it is used to convert a singular object (Carrier) to the string that is used in the web page, not to the database value. The returned String is also sometimes what is stored in the Lucene indexes for searching (“More Complex Searchers” on page 57). The singular object was passed into this method as an Object before JIRA 5.0.
The final set of CustomFieldType methods to consider are:
Set<Long> remove(CustomField field)
This method is called when a custom field is entirely removed from a JIRA instance, and returns the issue ids that were affected by the removal. The correct method to use for deleting a value from a field is updateValue.
String getChangelogValue(CustomField field, Object value)
String getChangelogString(CustomField field, Object value)
These methods are how the text that is seen in the History tab of an issue is gen- erated. When a custom field of this type changes, these methods are called with the before and after values of the field. The difference between the two methods is that the if the value later becomes invalid, the string will be shown instead (https://developer.atlassian.com/display/JIRADEV/Database+Schema#DatabaseSchema-ChangeHistory).
extractTransferObjectFromString()
extractStringFromTransferObject()
These methods are not from the CustomFieldType interface but they exist in the standard Multi fields for use during project imports.
Other Interfaces
There are a few other interfaces that are commonly implemented by custom field types.
ProjectImportableCustomField
The getProjectImporter method from this interface is used to implement how the custom field is populated during importing a project from an XML backup. If you don’t implement this interface then project imports will not import values for your custom field.
MultipleCustomFieldType
MultipleSettableCustomFieldType
These two interfaces are used by custom fields with options and that furthermore can have more than one option. For these classes, the values can be accessed using the Options class, which is a simple subclass of a Java List. These interfaces are not really intended for use by general-purpose multiple value custom field types.
Fields with Multiple Values | 41
SortableCustomField
This interface contains a compare method for comparing two singular objects. This is used by the Issue Navigator when you click on a column’s heading to sort a page of issues. This is actually a slower fallback for custom fields that don’t have a searcher associated with them (see Chapter 4).
RestAwareCustomFieldType
RestCustomFieldTypeOperations
These two interfaces are how the JIRA REST API knows which fields can be retrieved or updated. New in JIRA 5.0.

Custom properties

I have a requirement from a client to give them the option to add custom fields to a program i am going to write for them. The custom fields will be on a per/poco basis. What is the best way of handling custom properties like this. I am going to use SQL Server and ASP.NET MVC4.
Just need a starting point..
thanks in advance.
The way we handle this where I work is storing the information in a database table. We store the field name, the value, and some identifier for which object it belongs to. Sometimes we have an additional table stores the specific list of available values.
When it's pulled out of the db, we place it in a dictionary list. If you set up some conventions then it's not too bad building validation for the fields. I.E. any field name with "phone" in the name gets validated as a phone number.

Resources