I am trying to import an impex file. Currently, there is no such condition on the attributes. So, it is working fine.
However,I want to insert only those records for which the length of the value is not less than 10 characters but I haven't found any attribute modifiers in the Hybris documentation using which I can do that.
Below is my impex file:
Update Product;code[unique=true];value
;2055 ;ABCDEFGHIJKLMNOPQR
;2455 ;ABCDEFGH
Here, the first row should get inserted but not the second one since the length of value field is less than 10 characters.
Is there any way I can achieve this ?
Thanks
One way to do it is to create a ValidateInterceptor that would verify the condition you require.
Make sure impex.legacy.mode is set to false otherwise the interceptor will not be triggered.
basically you could leverage the translator on the particular column in impex file. By defining your customized translator to validate the length of that column. For example:
INSERT_UPDATE Media;mediaFormat(qualifier);code[unique=true];#media[translator=de.hybris.platform.impex.jalo.media.MediaDataTranslator][forceWrite=true];realfilename;altText;
Related
I have a dynamo script that exports schedules out of Revit. It uses a bit of Python also, (not relevant to this question, but I thought I would just include it all).
It all works great, but I notice if certain schedules get deleted from Revit, it could change the "Index" number of the schedules I need to export. I would like to use the schedule name instead of the dynamo index number, as this will help me maintain the connection without checking if it's exporting the correct schedule. Is this possible?
From the pure Revit API point of view I can only answer that yes, this is possible. You are calling the ViewSchedule.Export method. The ViewSchedule element can indeed be retrieved from the Revit database by name using a filtered element collection.
Here is the final solution that works well. Using the "==" node and "List.FilterByBoolMask" node I was able to filter down to just what's in the String. Now I can set the string node to be an input for the dynamo player and user just needs to input the exact name of their schedule. Thank you Michael Kilkelly from ArchSmarter for this helpful video.
How to Dynamo: Filter List by Element Name
I know how to write and use Cell Decorator and Translators during impex imports
in hybris, However, I am not sure when the one is preferred over the other?
For example, I have used Cell Decorator to change the value of an attribute slightly like if a customer is from US I will append an '_US' at the end of customer number while inserting in the DB.
Similarly, I have used Translator when I need to find a status of a product Available/Out of stock based on product ID.
However, I am not 100% positive is this the only differentiation.
Any explanation with example will be appreciated.
What is a translator?
(from SAP documatentation):
A translator class is a converter between ImpEx-related CSV files and values of attributes of Hybris Commerce items
The translator is a "converter" it is used when you need to modify your data into some other kind of data.
What is a decorator?
(From Wikipedia)
The decorator pattern is a design pattern that allows behavior to be added to an individual object, dynamically, without affecting the behavior of other objects from the same class
What should be used in hybris
For Impex most of the time you want to use a translator because you want to use simple syntax in the Impex file and convert( ie. translate/modify) it to the target format using code.
When you need to add functionality to an existing feature use a decorator. It can be used in Impex too if you want to add data.
For example you can read the Wikipedia article for decorator, in hybris you can look at ChineseLogisticCellDecorator. For translators, you have the list in hybris documentation (mentioned above)
I want to right one XML schema(XSD)
in which
element have multiple occurences and have one attribute ID
I want validate if borrower's ID attribute have a value equal to 1 then all its subelement must have some value.
is this possible with XSD?
Please suggest me if their is a way to achieve this
thanks
Not possible as far as I can remember, but it is totally OK to first validate the XML using XSD and then have some additional, application-specific validation logic on top of that.
first of all I'm totally new to FAST but I already have a couple of issues I need to solve, so I'm sorry if my questions are very basic =)
Well, the problem is that I have a field in the FAST index which in the source document is something like "ABC 12345" (please note the intentional whitespaces) but when stored in the index is in the form "ABC 123456" (please note that now there is a single space).
If I retrieve all the document values then this specific value is OK (with all the whitespaces), my only problem is with the way the value is stored in the index since I need to retrieve and display it to my user just like it appears in the original document, and I don't want to go to the full document just for this value, I want the value that I already have in the index. I think I need to update one of the FAST XML configuration files but I don't have enough documentation at hand in order to decide where to perform the change, index_profile.xml? in the XMLMapper file?
I've found the answer by myself. I'm using a XMLMapper for my collection, all I had to do was to add the ignore-whitespace attribute to the Mapping element and then set this attribute value to "false". This solved the problem and the raw data now when retrieved from the index contains the expected inner whitespaces.
Thanks.
I'm starting to do some test on SubSonic 3 and I'm missing some stuff.
1st: Where's the Table names constants? The place where we could ask for the same of a certain table using intelisense...
2nd: Same as the above but for the table columns... where are they?
This is very useful mostly when you need to pass those names as string... it you need to refactor your DB we don't need to look through all the code to find where was I using that column!! Once you re-generate the code the compiler tells you!
3rd: Now how can I perform an ExecuteReader on a certain table like I'm used to on 2.x through the Query object? I used this a lot for list where I really don't need the business objects (BO) overhead... When I needed a BO (for showing a grid row details) I create it from the row itself...
I'm using ActiveRecord btw...
Thanks guys!
Alex
1st: Where's the Table names constants? The place where we could ask for the same of a certain table using intelisense...
In Structs.tt find the following line of code at line 47:
<# foreach(var col in tbl.Columns){#>
Add the following code above it:
public static string TableName { get { return "<#=tbl.Name#>"; } }
Now you'll have a property that returns the name of the table.
2nd: Same as the above but for the table columns... where are they?
In the generated Structs.cs file, this is included in the 3.0.0.3 version
3rd: Now how can I perform an ExecuteReader on a certain table like I'm used to on 2.x through the Query object? I used this a lot for list where I really don't need the business objects (BO) overhead... When I needed a BO (for showing a grid row details) I create it from the row itself...
If you're using SqlQuery object you can call ExecuteReader on it. Alternatively you can use Linq syntax to generate return custom shaped objects and they'll get mapped automatically.
1st and 2nd: It's not implemented in the default tt-files.
A similiar question:
SubSonic 3 Simple Query Tool
Problem is that's not a correct implementation if you want the 2.x way - the XColumn properties used to be column objects and not string constants, those were found under the Columns struct. So I hope that check-in will not be accepted and that someone will 2.x-ify it correctly.
Anyway as you can see it seems pretty easy to fix it on your own.